Wednesday, October 9, 2013

Hooks to adapt a notebook to different conditions

So, I use Ubuntu 12.04 on my notebook.

Here a list of (shell) hooks I implemented to make the system adapt to "the environment". Only the minimum relevant code

  • Open/close lid -> internal screen on/off
  • grep -q closed /proc/acpi/button/lid/*/state
    xrandr -display $DISPLAY --output $internal --off

  • When (un)docked -> external monitor on/off.  un/docking detected by AC online. No other way found (with Dell latitude e*)


    if [ $(cat /sys/class/power_supply/AC/online) = "1" ]; then
    DISPLAY=:0 xrandr --output DP-1 --auto --rotate left 
  • Turn audio off/on  when on office network/at home:
    /etc/dhcp/dhclient-enter-hooks.d/  does not work with NM (see )
    So /etc/network/if-up.d/mute-in-office

     if [ ${DHCP4_DOMAIN_NAME-} = '' ];
       amixer set Master mute
     elif [ ${CONNECTION_ID-} = "home-ssid" ];
            amixer set Master unmute
            amixer set Front unmute
            amixer set Headphone unmute

  • prevent Skype from animating (in gnome-panel) when offline
    skype without any dbus  access?

    sleep 10s
    killall -STOP skype

    killall -CONT skype
  • keep cpu at minimum
    case "$1" in
            resume | thaw)
    sudo cpufreq-set --governor powersave
    foreach dir (/sys/devices/system/cpu/cpu*/cpufreq/) {
       echo powersave | sudo tee $dir/scaling_governor
       echo 1199000 | sudo tee $dir/scaling_min_freq
    #sudo hdparm -Y /dev/sdb

No comments:

Post a Comment