cze 8, 2010

ASUS M6N Notebook


Here you will find advanced ACPI configuration for my old ASUS M6N notebook. Configuration includes the kernel and scripts for supporting multimedia control buttons in KDE.
Kategoria: ACPI
Napisał: kardasa

Foreword

From the times when I started my adventure in the world of Linux I remember that getting full support for the features offered by mobile computers was rather difficult to achieve. Today those kind of problems are over. We have direct support for both suspend and hibernate functions a long side with vendor specific ACPI drivers available in Kernel. Most of modern binary distributions work on mobile devices without any problems giving users ability to fully control advanced ACPI functions. There are also available specific distributions for mobile computers like Ubuntu Netbook Edition or created by Intel and Nokia MeeGo platform. Today Linux sets new trends in mobile computers market.

I have a quite old Asus M6N notebook which I'm using mostly for browsing Internet, connecting to remote servers and running presentations. I use my notebook only If I'm away from my main computer. It's not a speed daemon especially for todays standards but for those kind of tasks my notebook is perfect and I don't need a better one. I could use any Linux distribution and they would work well but fortunately I'm Gentoo Linux user and thanks to this I'm able to make my notebook work perfect. Here you can find my configuration for mobile computer, including kernel, advanced ACPI, multimedia keys and KDE desktop environment configurations that let me use my notebook the way I want to. Some of the provided here information are specific for both my distribution and my notebook but some of them should be applicable not only for any distribution but with small changes also for any notebook. I hope you will find some of provided here information useful. I will start with kernel configuration.

TuxOnIce Kernel Configuration

Default Linux kernel for my distribution has the same support for suspend and hibernation that most of Linux distribution has. It's working well but it can be done better. This better way is kernel patchset called TuxOnIce. It gives the user additional features like ability to cancel hibernation or image restoration by pressing escape, nice user interface, fast multithreaded compression support and many others. To use TuxOnIce you have to patch your distribution kernel, but in Gentoo we already have a kernel with TuxOnIce patchset available in portage tree. So for Gentoo Linux all you have to do is to run this command in terminal:

USE="symlink" emerge -av sys-kernel/tuxonice-source

To use nice TuxOnIce GUI interface I additionally installed tuxonice-userui package by running following command in terminal:

USE="fbsplash" emerge -av sys-apps/tuxonice-userui

To configure my new kernel I had to enter kernel catalog and start menuconfig by running following commands in terminal:

cd /usr/src/linux
make menuconfig

Next I had to mark all kernel options needed to run TuxOnIce suspend and hibernate functions. Below you will find list of those options.

Linux Kernel Configuration: Enable TuxOnIce features
Power management and  ACPI options  --->
  [*] Suspend to RAM and standby
  [*] Hibernation (aka 'suspend to disk')
  (/dev/sda8) Default resume partition
  <*>   Enhanced Hibernation (TuxOnIce)  --->
          *** Image Storage (you need at least one allocator)
    < >   File Allocator
    <*>   Swap Allocator
          *** General Options
    <*>   Compression support
    <*>   Userspace User Interface support
    (/sbin/tuxoniceui_fbspalsh) Default userui program location
    [ ]   Allow Keep Image Mode
    [*]   Replace swsusp by default
    [ ]   Wait for initrd/ramfs to run, by default
    (25)  Default waiting time for emergency boot messages
    (2000) Default extra pages allowance
    [*]   Checksum pageset2

-*- Cryptographic API  --->
  <*>   LZO compression algorithm

As you can see I'm using both suspend to Ram and hibernate functions. Very important thing is to provide correct swap partition location, my swap is located on /dev/sda8. In TuxOnIce configuration I'm not using file allocator, I will use swap hibernation only. I'm also providing a fbsplash user interface location to have graphical information during suspend and resume operation. This will require additional configuration of my graphical boot up splash, more information you will find below. Last important thing is compression which will lower suspend image capacity. It's highly important to build LZO compression algorithm directly into kernel not as a module.

After marking all necessary kernel modules I'm ready to recompile, install and use new kernel. I usually do it by running this commands in terminal:

cd /usr/src/linux
make && make modules_install install

Now I can take care of my system splash image to make it compatible with TuxOnIce suspend GUI. Normally I would create graphical bootup splash using natural_gentoo theme by running following commands in terminal:

emerge -av splashutils splash-themes-gentoo
splash_geninitramfs --verbose --res 1024x768 --generate /boot/fbsplash-natural_gentoo-1024x768 natural_gentoo

To make my splash use installed earlier TuxOnIce GUI I have to decompressed it and copy tuxoneice_fbsplash into it. To do it I need to run following commands in terminal:

mkdir ~/initrd.d
cp /boot/fbsplash-natural_gentoo-1024x768 ~/initrd.d/
cd ~/initrd.d
gunzip -c fbsplash-natural_gentoo-1024x768 | cpio -idm --quiet -H newc
rm fbsplash-natural_gentoo-1024x768
cp /sbin/tuxoniceui_fbsplash sbin/
find . | cpio --quiet --dereference -o -H newc | gzip -9 > /boot/fbsplash-natural_gentoo-1024x768

Now I have TuxOnIce graphical notification during both hibernation and system resume.

The suspend to Ram and hibernation should work without any problem with this configuration in graphical desktop environment. I'm using KDE 4.x and KDE is using pm-utils and hal to suspend and hibernate system. This was working for me but I thought I could make it work better. To do it I use hibernate-script which has some advantages over core pm-utils implementation. Some of them are: easy to use complex plug-in based configuration with ability to suspend virtual machines before core system suspend, ability to change grub splash for suspended system, ability to unmount network file system before suspend, ability to restart chosen system services after resume and ability to change instant messengers status on suspend. To use hibernate script I have to install it. In Gentoo Linux we would do it like this:

emerge -av sys-power/hibernate-script

Main problem for me with using hibernate script is that there is no way (except changing the source code) to force KDE desktop environment to use hibernate-script instead of pm-utils and hal. But there is no need to change KDE behavior because you can force pm-utils to make a special hal script which will use hibernate-script. This solution is taken from Gentoo Linux Wiki pm-utils HowTo. Below you can find a full script which should be saved as /etc/pm/sleep.d/01HibernateScripts.

View the full /etc/pm/sleep.d/01HibernateScripts file
  1. #!/bin/bash
  2.  
  3. HAL_HIBERNATE="/usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux"
  4. HAL_SUSPEND="/usr/lib/hal/scripts/linux/hal-system-power-suspend-linux"
  5.  
  6. case $1 in
  7. hibernate)
  8. /bin/mv ${HAL_HIBERNATE} ${HAL_HIBERNATE}.original
  9. /bin/echo "#!/bin/bash" >> ${HAL_HIBERNATE}
  10. /bin/echo "/usr/sbin/hibernate" >> ${HAL_HIBERNATE}
  11. /bin/echo "exit \$?" >> ${HAL_HIBERNATE}
  12. /bin/chmod +x ${HAL_HIBERNATE}
  13. /usr/bin/killall pm-hibernate
  14. /usr/bin/chvt 7
  15. /usr/sbin/hibernate
  16. ;;
  17. suspend)
  18. /bin/mv ${HAL_SUSPEND} ${HAL_SUSPEND}.original
  19. /bin/echo "#!/bin/bash" >> ${HAL_SUSPEND}
  20. /bin/echo "/usr/sbin/hibernate-ram" >> ${HAL_SUSPEND}
  21. /bin/echo "exit \$?" >> ${HAL_SUSPEND}
  22. /bin/chmod +x ${HAL_SUSPEND}
  23. /usr/bin/killall pm-suspend
  24. /usr/bin/chvt 7
  25. /usr/sbin/hibernate-ram
  26. ;;
  27. esac

As you can see this file is creating special hal script which will use hibernate script commands whenever the hibernate and suspend actions are taken by user. The reason for such weird behavior is that during the system update the self created hal scripts can be overwritten. When you will create above script the hal scripts using hibernate-script will always be available in system. Now I can use hibernate script. To make full use of it I should make sure that a system service provided with the hibernate-script will be run on every computer boot. This service is called hibernate-cleanup. To make it run on every system boot I should run following command in terminal:

rc-update add hibernate-cleanup boot

The last thing to make my suspend and resume work as I would like it, is to configure hibernate-script itself. To do it I had to edit the /etc/hibernate/common.conf file. Below you can find my common.conf configuration file.

View the full /etc/hibernate/common.conf file
  1. # Configuration options common for suspending to disk or RAM.
  2. # Options are not case sensitive.
  3. #
  4. # See hibernate.conf(5) for help on the configuration items.
  5.  
  6. ##############################################################################
  7. ### Some global settings
  8. ##############################################################################
  9.  
  10. Verbosity 1
  11. LogFile /var/log/hibernate.log
  12. LogVerbosity 4
  13. LogTimestamp yes
  14. # AlwaysForce yes
  15. AlwaysKill yes
  16. # HibernateVT 15
  17. Distribution gentoo
  18. # XDisplay :0
  19.  
  20. ##############################################################################
  21. ### Scriptlets
  22. ### Scriptlets provide support for doing all sorts of things before and after
  23. ### suspending. The defaults settings here should work for most people, but
  24. ### you may wish to edit these to taste. Consult "hibernate -h" for help on
  25. ### the configuration settings.
  26. ##############################################################################
  27.  
  28. ### bootsplash
  29. ## If you use bootsplash, also enabling SwitchToTextMode is recommended if
  30. ## you use X, otherwise you may end up with a garbled X display.
  31. #Bootsplash on
  32. #BootsplashConfig /etc/splash/tuxonice/1024x768.cfg
  33.  
  34. ### clock
  35. SaveClock restore-only
  36. #DirectIsa
  37.  
  38. ### devices
  39. # IncompatibleDevices /dev/dsp /dev/video*
  40.  
  41. IncompatibleDevices /dev/video*
  42.  
  43. ### diskcache
  44. DisableWriteCacheOn /dev/sda
  45.  
  46. ### fbsplash (enable SwitchToTextMode if you use this)
  47. FBSplash on
  48. FBSplashTheme natural_gentoo
  49.  
  50. ### filesystems
  51. # Unmount /nfsshare /windows /mnt/sambaserver
  52. UnmountFSTypes smbfs nfs vfs
  53. # UnmountGraceTime 1
  54. # Mount /windows
  55.  
  56. ### grub
  57. ChangeGrubMenu yes
  58. GrubMenuFile /boot/grub/grub.conf
  59. AlternateGrubMenuFile /boot/grub/menu-suspended.lst
  60. BackupGrubMenuFile /boot/grub/grub.conf.bak
  61.  
  62. # see http://bugs.debian.org/317479
  63. # RemountXFSBoot yes
  64.  
  65. ### hardware_tweaks
  66. # IbmAcpi yes
  67. RadeonTool yes
  68. # Runi915resolution yes
  69. FullSpeedCPU yes
  70.  
  71. ### lilo
  72. # EnsureLILOResumes yes
  73.  
  74. ### lock (generally you only want one of the following options)
  75. ## For console you need vlock available.
  76. ## For x you need xscreensaver-command-command available.
  77. ## For gnome you need gnome-screensaver-command available.
  78. ## For kde you need dcop, kscreensaver available.
  79. ## For XAuto you need xautolock available.
  80. ## For Xtr you need xtrlock available.
  81. ## For Freedesktop (for example KDE4) you need dbus-send available
  82. # LockConsoleAs root
  83. # LockXScreenSaver yes
  84. # LockGnomeScreenSaver yes
  85. # LockFreedesktop
  86. # LockKDE yes
  87. # LockXLock yes
  88. # LockXAutoLock yes
  89. # LockXtrLock yes
  90.  
  91. ### misclaunch
  92. OnSuspend 20 echo "Idę Spać Co się dziwisz czasami trzeba :D!"
  93. OnResume 20 echo "Gotów do roboty. No dalej co robimy!"
  94.  
  95. ### modules
  96. UnloadModules sd_ricoh
  97. # UnloadAllModules yes
  98. UnloadBlacklistedModules yes
  99. LoadModules auto
  100. # LoadModulesFromFile /etc/modules
  101.  
  102. ### modules-gentoo
  103. # GentooModulesAutoload yes
  104.  
  105. ### network
  106. DownInterfaces
  107. UpInterfaces auto
  108.  
  109. ### networkmanager
  110. EnableNMReconnect yes
  111.  
  112. ### pause_audio
  113. MuteAudio no
  114. PauseAudio yes
  115.  
  116. ### pcmcia
  117. EjectCards yes
  118.  
  119. ### programs
  120. #IncompatiblePrograms
  121.  
  122. ### services
  123. RestartServices hsf samba nfs nfsmount numlock lm_sensors sensord smartd hddtemp vixie-cron avahi-daemon irda ntpd distccd moblock sshd ulogd iptables laptop_mode acpi
  124. # StopServices alsasound
  125. # StartServices aumix
  126.  
  127. ### vbetool
  128. #EnableVbetool yes
  129. #RestoreVbeStateFrom /var/lib/vbetool/vbestate
  130. #VbetoolPost yes
  131. #RestoreVCSAData yes
  132.  
  133. ### xhacks
  134. SwitchToTextMode yes
  135. # UseDummyXServer yes
  136. # DummyXServerConfig xorg-dummy.conf
  137.  
  138. ### xstatus
  139. ## This can be set to gnome, kde or x:
  140. ## For gnome you need zenity available.
  141. ## For kde you need dcop, kstart, kdialog available.
  142. ## For x you need to have xosd OR xmessage available.
  143. # XStatus x
  144. # XmessageDisable yes
  145. # XSuspendText Preparing to suspend...
  146. # XResumeText Resuming from suspend...
  147. ## When using XStatus x, and you have xosd installed:
  148. # XosdSettings --font '-misc-fixed-medium-r-semicondensed--*-120-*-*-c-*-*-*' --colour=Green --shadow 1 --pos bottom --align center --offset 50
  149.  
  150. ### xbacklight
  151. # BackLight yes
  152.  
  153. ### gaim
  154. ## You need to have dbus, gaim_remote available.
  155. # LogoutGaim yes
  156. # GaimRestoreStatus yes
  157. # GaimLogoutMessage Hibernating
  158. # GaimLoginMessage Back from hibernation
  159.  
  160. ### pidgin
  161. LogoutPidgin yes
  162. PidginRestoreStatus yes
  163. PidginLogoutMessage Hibernating - bye!
  164. # PidginLoginMessage I'm back!
  165.  
  166. ### SSH and PGP keys
  167. # AgentsClearGPG yes
  168. # AgentsClearSSH yes
  169.  
  170. ### Virtualbox
  171. SuspendVirtualbox yes

These file is quite easy to read. On the top you will find logging configuration, lower you can see list of network file systems that need to be unmounted before suspend. Then you can see grub menu configuration, I wil provide grub menu information later. The important thing is also list of kernel modules that should be unloaded. I'm unloading module for my SD card reader. Litter lower you can see list of system services that should be restarted after system resume. As you can see I'm restarting mostly network services to make sure they will work all right. I'm also locking my X environment before suspend this way after resume I will be forced to provide password to get back to normal work. Another important thing is making use of utility named radeontool. This is special tool for power management of my graphics card. With proper graphics card configuration this tool should be installed as dependency to pm-utils. Of course you can always install this tool manually by running following command in terminal:

emerge -av app-laptop/radeontool

Last thing I need to do is to create grub configuration files. First file /boot/grub/grub.conf will be responsible for normal system start. Below you can see my grub.conf file.

View the full /boot/grub/grub.conf file
  1. default 0
  2. timeout 10
  3.  
  4. splashimage=(hd0,0)/boot/grub/gentoo.xpm.gz
  5.  
  6. title Gentoo Linux TuxOnIce 2.6.32-r9 (Main)
  7. root(hd0,0)
  8. kernel /boot/vmlinuz-2.6.32-tuxonice-r9 root=/dev/sda2 resume=swap:/dev/sda8 video=uvesafb:1024x768-24@60,mtrr:2,ywrap splash=kdgraphics,silent,fadein,theme:natural-gentoo quiet CONSOLE=/dev/tty1 fbcon=scrollback:256K acpi=on lapic=yes
  9. initrd (hd0,0)/boot/fbsplash-natural_gentoo-1024x768
  10.  
  11. title Gentoo Linux TuxOnIce 2.6.32-r9 (Rescue)
  12. kernel /boot/vmlinuz-2.6.32-tuxonice-r9 root=/dev/sda2 init=/bin/bb
  13.  
  14. title Memtest86Plus
  15. root(hd0,0)
  16. kernel --type=netbsd /boot/memtest86plus/memtest

You can see one important information for suspend and resume, a kernel parameter resume pointing to my swap partition location. This parameter is required only if I would not provide proper swap partition information during my kernel configuration. Second grub configuration file is /boot/grub/menu-suspended.lst. This file will be responsible for system start after hibernation. The hibernate script will take care of replacing the grub files during hibernation process. Below you can see my menu-suspended.lst file.

View the full /boot/grub/menu-suspended.lst
  1. default 0
  2. timeout 10
  3.  
  4. splashimage=(hd0,0)/boot/grub/gentoo.xpm.gz
  5.  
  6. title Gentoo Linux TuxOnIce 2.6.32-r9 (RESUME SUSPENDED SYSTEM)
  7. root(hd0,0)
  8. kernel /boot/vmlinuz-2.6.32-tuxonice-r9 root=/dev/sda2 resume=swap:/dev/sda8 video=uvesafb:1024x768-24@60,mtrr:2,ywrap splash=kdgraphics,silent,fadein,theme:natural-gentoo quiet CONSOLE=/dev/tty1 fbcon=scrollback:256K acpi=on lapic=yes
  9. initrd (hd0,0)/boot/fbsplash-natural_gentoo-1024x768
  10.  
  11. title Gentoo Linux TuxOnIce 2.6.32-r9 (START UNSUSPENDED SYSTEM)
  12. root(hd0,0)
  13. kernel /boot/vmlinuz-2.6.32-tuxonice-r9 root=/dev/sda2 resume=swap:/dev/sda8 noresume video=uvesafb:1024x768-24@60,mtrr:2,ywrap splash=kdgraphics,silent,fadein,theme:natural-gentoo quiet CONSOLE=/dev/tty1 fbcon=scrollback:256K acpi=on lapic=yes
  14. initrd (hd0,0)/boot/fbsplash-natural_gentoo-1024x768
  15.  
  16. title Gentoo Linux TuxOnIce 2.6.32-r9 (Rescue)
  17. kernel /boot/vmlinuz-2.6.32-tuxonice-r9 root=/dev/sda2 init=/bin/bb
  18.  
  19. title Memtest86Plus
  20. root(hd0,0)
  21. kernel --type=netbsd /boot/memtest86plus/memtest

As you can see there are two kernel configurations on this file. First one which should boot up and load suspended system from a swap partition and second one which has special kernel parameter noresume which will start up system in a normal way. The third grub configuration file /boot/grub/grub.conf.bak is just a copy of the first file. This is all I did to make my suspend and hibernate work as I want to. Next thing is ACPI configuration for my notebook.

ACPI configuration

ACPI configuration is two-stage process. First stage is kernel configuration, second one is installation and configuration of tools which will make use of features available in kernel. Below you will find ACPI kernel configuration for my notebook.

Linux Kernel Configuration: Enable ACPI features
Power management and  ACPI options  --->
  [*] Power Management support 
  [*] Run-time PM core functionality 
  [*] ACPI (Advanced Configuration and Power Interface) Support  --->
    [*]   Deprecated /proc/acpi files
    [*]   Deprecated power /proc/acpi directories
    < >   ACPI 4.0 power meter
    [*]   Future power /sys interface
    [*]   Deprecated /proc/acpi/event support
    <M>   AC Adapter
    <M>   Battery
    <M>   Button
    <M>   Fan
    -*-   Dock
    <*>   Processor
    < >    Processor Aggregator
    (0)   Disable ACPI for systems before Jan 1st this year 
    <M>   Smart Battery System
      CPU Frequency scaling  --->
    [*] CPU Frequency scaling
    [*]   Enable CPUfreq debugging
    <M>   CPU frequency translation statistics
    [*]     CPU frequency translation statistics details
           Default CPUFreq governor (userspace)  --->
    <*>   'performance' governor
    <*>   'powersave' governor
    <*>   'userspace' governor for userspace frequency scaling
    <*>   'ondemand' cpufreq policy governor
    <*>   'conservative' cpufreq governor
    <M>   ACPI Processor P-States driver
 -*- CPU idle PM support
Device Drivers  --->
 [*] X86 Platform Specific Device Drivers  --->
    <M>   Asus Laptop Extras
    < >   ASUS/Medion Laptop Extras (DEPRECATED)

As you can see I marked most of available in kernel ACPI features including all possible CPU frequency scaling governors. Very important thing is marking direct support for ACPI features typical for a notebook vendor. For Asus notebooks it's highly important not to use old deprecated kernel module even if you have as old notebook as mine. The new support will work just fine. Now we can install some programs to use advanced capabilities of mobile computer.

If you already installed system with graphical desktop environment, you most likely has all needed software. For Gentoo Linux system is important to add two USE flags that affect advanced power management to /etc/make.conf file. Those flags are: acpi and laptop. After this you should make sure all packages using those tools will be rebuild. To do it in Gentoo Linux system we need to run following command in terminal:

emerge --deep --newuse --update world

This should end up in installing most important package for power management functions, which is pm-utils. This package should be installed as dependency to hal hardware abstraction layer package or as dependency to desktop environment power management utility. This packages can be also installed manually by running following commands in terminal:

emerge -av sys-power/pm-utils

There are also another power management tools you may want to have in your system. First one is acpid daemon for advanced power management, second is laptop-mode-tools third is cpufrequtils. You can install all those tools by running following command in terminal:

emerge -av sys-power/acpid app-laptop/laptop-mode-tools sys-power/cpufrequtils

After installing all those tools you also need to add its system services to default run level. To do it in Gentoo Linux you can run following commands in terminal:

rc-update add acpid default
rc-update add laptop-mode-tools default
rc-update add cpufrequtils default

Today most of the power management tasks are executed by graphical desktop environment power management utility. KDE the desktop environment I use have really good tool called PowerDevil. I added all those services to default run level because I prefer to have power management support even if I'm not logged to the graphical environment. One of those tools require additional configuration. For cpufrequtils you need to provide a CPU governor that should be setup on start and stop of the system service. This configuration should go to /etc/conf.d/cpufrequtils. Below you can find my /etc/conf.d/cpufrequtils file.

View the full /etc/conf.d/cpufrequtils file
  1. # /etc/conf.d/cpufrequtils: config file for /etc/init.d/cpufrequtils
  2.  
  3. # Options when starting cpufreq (given to the `cpufreq-set` program)
  4. START_OPTS="--governor ondemand"
  5.  
  6. # Options when stopping cpufreq (given to the `cpufreq-set` program)
  7. STOP_OPTS="--governor performance"

This way I have dynamic CPU frequency scaling before logging into graphical desktop environment. Now I have all tools I need the last thing to do is to setup my multimedia keys.

Multimedia Keys Configuration

Setting up multimedia keys in Linux is much easier today that it was before. Thanks to support build directly into the hal, multimedia keys for most of the notebooks are recognized as normal keys and they can be configured by any key setup utility. Earlier the setup wasn't so hard but it required a little more work to create special acpi events scripts which were performing defined actions when keys were pressed. Unfortunately not all of my notebook keys could be configured the new way. Sadly one of them wasn't recognized and another one was acting not the way I would like it. Thats why my configuration is using both approaches the new one for those buttons that were corectly recognized and old one for 2 buttons that wasn't recognized. Below you will find list of my multimedia keys and the actions I would like them to perform.

List of my keys:
  • Sleep button - Suspend system to ram - this button was working in KDE without the need of additional configuration.
  • Wireless button (2 buttons) - Switch off and on wireless network interface.
  • Brightness Up - This button has hardware support. Brightness up function is working even without operating system loaded.
  • Brightness Down - This button has hardware support. Brightness down function is working even without operating system loaded.
  • LCD button - This button has hardware support toggle between LCD on and off function is working even without operating system loaded.
  • LCD - CRT button - Toggle between dual screen setups.
  • Mute Sound button - Mute sound mixer - this button was working in KDE without the need of additional configuration.
  • Volume Up button - Volume up - this button was working in KDE without the need of additional configuration.
  • Volume Down button - Volume down - this button was working in KDE without the need of additional configuration.
  • Mail button - lunch Kmail mail client.
  • WWW button - lunch Chromium web browser.
  • Touchpad button - Switch on and off the touchpad - this button wasn't recognized as normal key.
  • Performance button - Toggle between available performance profiles - this button was recognized as screen saver button.
  • Play | Pause button - Toggle between play and pause in Amarok player.
  • Next track button - Next track in Amarok player.
  • Previous track button - Previous track in Amarok player.
  • Stop button - Stop playback in Amarok player.
  • Lunch media button - Start Amarok media player.

As you can see some of my notebook buttons were working without the need of additional configuration. Default configuration of KDE desktop environment assumes that those buttons will be available in system. For other correctly recognized buttons I used buttons settings utility provided by KDE. For multimedia buttons: Play | Pause, Next track, Previous Track and Stop buttons I used Global keyboard Shortcuts settings for Amarok player. All I need to do was to choose Amarok action matching my key and press my multimedia key to bound it to this function. 30 seconds of work. For Mail, WWW and Media Start buttons I used Keyboard Actions settings utility. I created three new Global Shortcuts for Command/URL actions first one command /usr/bin/chromium bound to WWW button, second /usr/bin/kmail bound to Email key and last one /usr/bin/amarok bound to Media Start button. This way I'm able to lunch my Internet browser, mail client and favorite multimedia player using my notebook buttons. This was the easy part. I must admit I had more problems with setting up wireless and performance buttons. The main problem was that I couldn't find simple system or dbus commands which could help simply achieve task I would like to bound to those buttons. But where is a will there is a way. For wireless button I found a great script created by Poul Sladen for Ubuntu acpi-support package. I used his functions for checking wireless device state and toggling wireless devices on and off. I used this functions a little different that original acpi-support package was making use of it. I created 3 scripts. First one I called wireless-toggle.sh. Below you can see this script.

View the full wireless-toggle.sh file
  1. #Function to toggle wireless interfaces originaly created by Paul Sladen for Ubuntu acpi-support package
  2. for DEVICE in /sys/class/net/* ; do
  3. if [ -d $DEVICE/wireless ] ; then
  4. # $DEVICE is a wireless device.
  5.  
  6. FOUND=
  7. # Yes, that's right... the new interface reverses the truth values.
  8. ON=1
  9. OFF=0
  10. for CONTROL in $DEVICE/device/rfkill/rfkill*/state; do
  11. if [ -w "$CONTROL" ]; then
  12. FOUND=1
  13.  
  14. if [ "$(cat "$CONTROL")" = "$ON" ] ; then
  15. # It's powered on. Switch it off.
  16. echo -n "$OFF" > "$CONTROL"
  17. else
  18. # It's powered off. Switch it on.
  19. echo -n "$ON" > "$CONTROL"
  20. fi
  21. fi
  22. done
  23. # it might be safe to assume that a device only supports one
  24. # interface at a time; but just in case, we short-circuit
  25. # here to avoid toggling the power twice
  26. if [ -n "$FOUND" ]; then
  27. continue
  28. fi
  29.  
  30. ON=0
  31. OFF=1 # 1 for rf_kill, 2 for power/state
  32. for CONTROL in $DEVICE/device/rf_kill $DEVICE/device/power/state ; do
  33. if [ -w $CONTROL ] ; then
  34. # We have a way of controlling the device, lets try
  35. if [ "`cat $CONTROL`" = 0 ] ; then
  36. # It's powered on. Switch it off.
  37. if echo -n $OFF > $CONTROL ; then
  38. break
  39. else
  40. OFF=2 # for power/state, second time around
  41. fi
  42. else
  43. # It's powered off. Switch it on.
  44. if echo -n $ON > $CONTROL ; then
  45. break
  46. fi
  47. fi
  48. fi
  49. done
  50. fi
  51. done

This script is using Poul Sladen function for toggling on and off all wireless devices in the system. Important thing is to remember that this script need to be run with higher system privileges. Normal user want be able to use it. A long side with toggling on and off wireless devices the user should be also informed about the current state of wireless devices by system led placed on the front side of the notebook. To do it I created the second script called wireless-led.sh. Below you can see this script.

View the full wireless-led.sh file
  1. #/bin/sh
  2.  
  3. echo $1 > /sys/devices/platform/asus_laptop/wlan

As you can see this script is very basic it just passes the first script parameter to system wireless led device. To light on the led I need to run this script like this: ./wireless-led.sh 1. To light off the led I need to run this script like this: ./wireless-led.sh 0. This script also needs a higher system privileges. I saved both scripts in /usr/local/bin catalog. To make both mentioned above scripts available to normal user I used sudo utility. In Gentoo Linux you can install sudo by running following command in terminal.

emerge  -av app-admin/sudo

With sudo installed in system all I needed to do is run visudo utility and create belows configuration to let anyone logged on my notebook use wireless scripts with higher privileges without the need of providing password.

ALL notebook = NOPASSWD: /usr/local/bin/wireless-led.sh
ALL notebook = NOPASSWD: /usr/local/bin/wireless-toggle.sh

Last thing I did to make my wireless devices manageable by notebook buttons is providing the script which will use mentioned above scripts to toggle wireless state and notebook led. I called this script wireless.sh and saved it in /usr/local/bin catalog. Below you can see wireless.sh script.

View the full wireless.sh file
  1. #!/bin/sh
  2. #Function to check status originaly created by Paul Sladen for Ubuntu acpi-support package
  3. isAnyWirelessPoweredOn()
  4. {
  5. for DEVICE in /sys/class/net/* ; do
  6. if [ -d $DEVICE/wireless ]; then
  7. # Hurray for stable interfaces... now the rfkill is scarcely
  8. # associated with the network device at all (!)
  9. for RFKILL in $DEVICE/device/rfkill/rfkill*/state; do
  10. if [ -r "$RFKILL" ] && [ "$(cat "$RFKILL")" -eq 1 ]
  11. then
  12. return 0
  13. fi
  14. done
  15. # if any of the wireless devices are turned on then return success
  16. if [ -r $DEVICE/device/power/state ] && [ "`cat $DEVICE/device/power/state`" -eq 0 ]
  17. then
  18. return 0
  19. fi
  20. if [ -r $DEVICE/device/rf_kill ] && [ "`cat $DEVICE/device/rf_kill`" -eq 0 ]
  21. then
  22. return 0
  23. fi
  24. fi
  25. done
  26.  
  27. # otherwise return failure
  28. return 1
  29. }
  30.  
  31. if (isAnyWirelessPoweredOn); then
  32. kdialog --passivepopup "Wyłączam Interfejsy bezprzewodowe" --title "Wciśnięty przycisk Wifi"
  33. else
  34. kdialog --passivepopup "Włączam Interfejsy bezprzewodowe" --title "Wciśnięty przycisk Wifi"
  35. fi
  36.  
  37. sudo /usr/local/bin/wireless-toggle.sh
  38.  
  39. if (isAnyWirelessPoweredOn); then
  40. sudo /usr/local/bin/wireless-led.sh 1
  41. else
  42. sudo /usr/local/bin/wireless-led.sh 0
  43. fi

This script is using Poul Sladen function to check wireless device state, then is informing user by KDE popup passive dialog about action that will be taken, then is using sudo to perform wireless device and notebook led toggle. This script is the script I bound with my notebook wireless button by creating new Global Shortcut for Command/URL in Keyboard Actions utility. This way I can switch on and off my wireless devices using one of two available wireless buttons on my notebook.

Fortunately performance button required only one script. As I wrote above I would like this button to toggle between defined in system power profiles. KDE desktop environment has great PowerDevil utility to configure and manage power profiles. I created a script which is using Dbus command provided by PowerDevil to switch profile. Below you can see my performance.sh script.

View the full performance.sh file
  1. #!/bin/sh
  2.  
  3. PROFILES="/usr/local/bin/profiles"
  4.  
  5. test -f ${PROFILES} || exit 0
  6.  
  7. TEMPFILE=/tmp/${USER}-profile.tmp
  8.  
  9. if (test -f ${TEMPFILE}) then
  10. read line < ${TEMPFILE}
  11. PROFILE=${line}
  12. else
  13. PROFILE=Dynamic
  14. fi
  15.  
  16. i=0
  17. flaga=0
  18.  
  19. while read line
  20. do
  21. i=`expr $i + 1`
  22. if (test "${line}" = "${PROFILE}") then
  23. flaga=$i
  24. fi
  25. done < ${PROFILES}
  26.  
  27. if (test $flaga -eq $i) then
  28. flaga=1
  29. else
  30. flaga=`expr $flaga + 1`
  31. fi
  32.  
  33. j=0
  34.  
  35. while read line
  36. do
  37. j=`expr $j + 1`
  38. if (test $flaga -eq $j) then
  39. PROFILE=${line}
  40. fi
  41. done < ${PROFILES}
  42.  
  43. CMD="dbus-send --print-reply --session --dest=org.kde.powerdevil /modules/powerdevil org.kde.PowerDevil.setProfile string:"
  44.  
  45. ${CMD}"${PROFILE}"
  46.  
  47. echo ${PROFILE} > ${TEMPFILE}

This script loops thought profile list defined in additional file, marking currently chosen profile and switching to the next one on the list using PowerDevil Dbus setProfile command. To make use of this script I need to define additional file containing all defined in my system power profiles. Below you can see my profiles list file.

View the profiles file
  1. Performance
  2. Performance No3D
  3. Dynamic
  4. Presentation
  5. Powersave
  6. Aggressive Powersave
  7. Xtreme Powersave

I bound performance.sh script with performance button the same way I did this for wireless button by creating new Global Shortcut for Command/URL in Keyboard Actions utility.

There are only two buttons left. But those buttons I configured using older approach. Unfortunately my TouchPad button wasn't recognized the same way the others buttons were. Probably configuration of my quite old notebook isn't fully supported by new hal mappings. That's why I need additional tool created especially for Asus notebooks. This tool is called acpi4asus. To install this tool in Gentoo Linux system I had to run following commands in terminal:

echo "app-laptop/acpi4asus ~x86" > /etc/portage/package.keywords
emerge -av app-laptop/acpi4asus

This tool provides small program which helps recognized pressed button as acpi events. Thanks to this I can configure my last two buttons. First I need to make sure that this little program will be started when ever I logged into my KDE desktop environment. To do it I created a small script which will lunch this program and I save this script inside my home in ~/.kde4/Autostart catalog. You can see my asusacpid.sh file below.

  1. #!/bin/sh
  2.  
  3. /usr/bin/asus_acpid

This way every time I will log to my KDE graphical desktop environment this small application will be lunched and ready to support my configuration. The configuration of this tool should go to hidden catalog inside my home called .asus_acpi. The configuration is fairly simple first thing we need to do is to provide a file which will map keycode acpi event with the script performing desired by user action. Below you can see my mapping file for TouchPad button.

View the ~/.asus_acpi/events/asus-touchpad file
  1. # /etc/acpi/events/asus-touchpad
  2. # This is called when the user presses the touchpad button and calls
  3. # /etc/acpi/asus-touchpad.sh for further processing.
  4.  
  5. event=hotkey (ATKD|HOTK) 0000006a
  6. action=~/.asus_acpi/actions/asus-touchpad.sh &

As you can see my key is mapped to acpid event code 0000006a. When ever I press this button asus_acpid helper program should lunch ~/.asus_acpi/actions/asus-touchpad.sh script. The script of course should be responsible for toggling on and off my touchpad. Below you can see my ~/.asus_acpi/actions/asus-touchpad.sh.

View the ~/.asus_acpi/events/asus-touchpad file
  1. #!/bin/bash
  2. state=$(synclient -l | grep TouchpadOff | awk -F"= " '{print $2}')
  3. if [ "$state" = "0" ]; then
  4. kdialog --passivepopup "Wyłączam TouchPad" --title "Wciśnięty przycisk TouchPad"
  5. synclient TouchpadOff=1
  6. else
  7. kdialog --passivepopup "Włączam TouchPad" --title "Wciśnięty przycisk TouchPad"
  8. synclient TouchpadOff=0
  9. fi

As you can see this script is fairly simple. It reads the state of the touchpad and depending on the current state it informs the user using KDE passive popup dialog of action that will be performed and performing switching on and off the touchpad using synclient command. This script should work. However I found out that my synaptics touchpad driver need to be specially configured in Xorg.conf X server configuration file. Without this additional configuration the synclient command line tool wasn't able to access my touchpad. Below you can see part of my Xorg.conf file affecting synaptics driver configuration.

View the part of /etc/X11/Xorg.conf file
  1. Section "InputDevice"
  2. Identifier "Synaptics0"
  3. Driver "synaptics"
  4. Option "Protocol" "auto"
  5. Option "SendCoreEvents" "true"
  6. Option "Protocol" "auto"
  7. Option "SHMConfig" "on"
  8. EndSection

The most important part of this configuration is Option "SHMConfig" "on". This settings make touchpad accessible to synclient settings command. This is all that need to be done to make my touchpad button work.

The last button to configure is LCD - CRT button. I want to use this button to toggle between dual screen configurations. I found out that pressing this button generate 3 different acpi event codes. First time I pressed the button it generates the code 00000061, second time it generates the code 00000062 and the third time i press it it generates the code 00000063. Thanks to this behavior I can easily assign 3 different actions and toggle between them using one key. First thing I need to do is to provide event mappings. First one I called asus-screen1. Below you can see this file.

View the ~/.asus_acpi/events/asus-screen1 file
  1. # ~/.asus_acpi/events/asus-screen1
  2. # This is called when the user is presing screen lcd/crt button,
  3.  
  4. event=hotkey (ATKD|HOTK) 00000061
  5. action=~/.asus_acpi/actions/screen1.sh &

Second one I called asus-screen2. Below you can see this file.

View the ~/.asus_acpi/events/asus-screen2 file
  1. # ~/.asus_acpi/events/asus-screen2
  2. # This is called when the user is presing screen lcd/crt button,
  3.  
  4. event=hotkey (ATKD|HOTK) 00000062
  5. action=~/.asus_acpi/actions/screen2.sh &

Third one I called asus-screen3. Below you can see this file.

View the ~/.asus_acpi/events/asus-screen3 file
  1. # ~/.asus_acpi/events/screen3
  2. # This is called when the user is presing screen lcd/crt button,
  3.  
  4. event=hotkey (ATKD|HOTK) 00000063
  5. action=~/.asus_acpi/actions/screen3.sh &

Every action mapping file is pointing to script created in actions catalog. First one of this scripts is called screen1.sh. Below you can see this file.

View the ~/.asus_acpi/actions/screen1.sh file
  1. #!/bin/sh
  2.  
  3. kdialog --passivepopup "Wyłączam drugi ekran" --title "Wciśnięty przycisk Screen"
  4.  
  5. xrandr --output LVDS --auto --output VGA-0 --off

This script is disabling possibly attached to my notebook second screen and setting the main screen into default resolution using command line xrandr tool. Second one of this scripts is called screen2.sh. Below you can see this file.

View the ~/.asus_acpi/actions/screen2.sh file
  1. #!/bin/sh
  2.  
  3. kdialog --passivepopup "Ustawiam oba ekrany w tryb klonowania" --title "Wciśnięty przycisk Screen"
  4.  
  5. xrandr --output LVDS --mode 1024x768 --output VGA-0 --mode 1024x768 --same-as LVDS

This script is setting both screen resolution to 1024x768 and setting positioning one over another enabling cloning mode. Third one of this scripts is called screen3.sh. Below you can see this file.

View the ~/.asus_acpi/actions/screen3.sh file
  1. #!/bin/sh
  2.  
  3. kdialog --passivepopup "Uaktywniam oba ekrany w trybie domyślnej rozdzielczości " --title "Wciśnięty przycisk Screen"
  4.  
  5. xrandr --output LVDS --auto --output VGA-0 --auto --right-of LVDS

This script is setting both screens into it's default resolutions and placing 2nd screen on the right of the 1st screen. Now I can toggle between screen configurations using only one button. This is highly important for me as I'm very often using my computer to show something to larger audience.

This is it I have all my multimedia keys configured exactly the way I wanted. Thats why I love Gentoo Linux. If I want to achieve something I can do it I'm not bound to any default configuration. At the end I add one more quite obvious thing. All mentioned above scrips has to be made executable before you can use them. To do it you can run following command in terminal:

chmod +x /path-to-script/script-name.sh

Additional Information

To make my configuration complete I must point that I did one more thing. My notebook has a mail notification led. I would like this led to light up when my default mail client downloads new mail from one of my mailboxes. To achieve this goal I created a mailledon.sh script. Below you can see this file.

View the mailledon.sh file
  1. #!/bin/sh
  2.  
  3. echo 1 > /sys/class/leds/asus\:\:mail/brightness

This script is passing 1 value to mail led device, which should turn on the led. Unfortunately this script has to be lunched using higher system privileges. I additionally had to run visudo utility and add belows line to sudo configuration.

ALL notebook = NOPASSWD: /usr/local/bin/mailledon.sh

This will let any user logged to my notebook use this script without the need of providing the password. I attached this script in Kmail mail client configuration in Detailed mail notification section this way:

sudo /usr/local/bin/mailledon.sh

When I'm receiving new mail the notification led is lighting now.

I copied all my configuration to /etc/skel catalog. To by more specific I copied whole ~/.asus_acpi catalog content a long side with ~/.kde4/Autostart/asusacpid.sh, ~/.kde4/share/config/khotkeysrc, ~/.kde4/share/config/kglobalshortcutsrc, ~/.kde4/share/config/powerdevilprofilesrc and ~/.kde4/share/config/powerdevilprofilesrc. This way when I was creating new user account for my girlfriend she already had all needed multimedia keys configuration in her profile. No need of painful additional configuration for her.

Most of mentioned above scripts are avaiable on my svn server. Below you can find direct links to them.

Prove that it's working

Sources

titlepl: Notebook ASUS M6N
summarypl: Tutaj znajdziesz zaawansowaną konfigurację ACPI dla mojego starego notebooka ASUS M6N. Konfiguracja obejmuje kernel oraz skrypty zapewniające obsługę przycisków multimedialnych w środowisku KDE.
contentpl: 

Wstęp

Z czasów, kiedy zaczynałem moją przygodę w świecie Linuxa pamiętam, że skonfigurowanie funkcji oferowanych przez komputery mobilne było dość ciężkim zadaniem. Dzisiaj tego typu problemy nie występują. Mamy bezpośrednie wsparcie zarówno dla funkcji wstrzymania jak i hibernacji systemu, także obsługa sterowników zarządzania energią typowych dla różnych dostawców sprzętu jest dostępna w kernelu. Większość nowoczesnych binarnych dystrybucji systemu pracuje na komputerach mobilnych bez problemu dając użytkownikom pełną możliwość kontrolowania zaawansowanych funkcji zarządzania energią. Dostępne są także dystrybucje dedykowane dla komputerów mobilnych takie jak Ubuntu Netbook Edition czy stworzona przez Intela i Nokię platforma MeeGo. Dzisiaj to Linux wyznacza nowe trendy na rynku komputerów mobilnych.

Posiadam starego notebooka Asus M6N, którego wykorzystuję do przeglądania Internetu, łączenia się ze zdalnymi serwerami i uruchamiania prezentacji. Wykorzystuję mojego notebooka tylko jeśli nie jestem w pobliżu mojego głównego komputera. Nie jest on na pewno demonem szybkości, szczególnie jak na dzisiejsze standardy ale do tego typu zadań jest idealny i nie potrzebuję lepszego. Mógłbym używać na nim dowolnej dystrybucji Linuxa i zapewne działała by ona poprawnie ale na szczęście jestem użytkownikiem Gentoo Linuxa i dzięki temu mogę sprawić, żeby mój notebook działał doskonale. Tutaj znajdziesz opis konfiguracji komputera mobilnego, obejmujący konfigurację kernela, zaawansowanego zarządzania energią (ACPI), przycisków multimedialnych i środowiska graficznego KDE, która pozawala mi korzystać z mojego notebooka w pożądany przeze mnie sposób. Niektóre z podanych tutaj informacji są typowe zarówno dla mojej dystrybucji jak i notebooka ale niektóre informacje powinno dać się wykorzystać nie tylko w dowolnej dystrybucji ale także z małymi zmianami na dowolnym notebooku. Mam nadzieje, że niektóre z tych informacji okażą się użyteczne. Rozpocznę od konfiguracji kernela.

Konfiguracja kernela TuxOnIce

Domyślne jądro dla mojej dystrybucji Linuxa posiada to samo wsparcie dla usypiania i hibernacji sytemu co jadra większości dystrybucji. Zarówno usypiania jak i hibernacja działa dobrze ale może działać jeszcze lepiej. To lepsze działanie może zapewnić zestaw poprawek jądra zwany TuxOnIce. Daje on użytkownikowi dodatkowe funkcje takie jak np: możliwość anulowanie procesu hibernacji czy odtwarzania obrazu poprzez wciśnięcie klawisza escape, przyjazny interfejs użytkownika, szybkie wielowątkowe kompresowanie obrazu oraz wiele innych. Aby skorzystać z TuxOnIce trzeba ręcznie nałożyć poprawki na aktualne jądro dystrybucji, na szczęście w Gentoo mamy w drzewie portage kernel z nałożonymi poprawkami TuxOnIce. Tak więc w Gentoo Linuxie wszystko co należy zrobić to zainstalować nowy kernel wykonując następującą komendę w terminalu:

USE="symlink" emerge -av sys-kernel/tuxonice-source

Aby wykorzystać przyjazny interfejs użytkownika TuxOnIce dodatkowo zainstalowałem pakiet tuxonice-userui wykonując następującą komendę terminalu:

USE="fbsplash" emerge -av sys-apps/tuxonice-userui

Aby skonfigurować mój nowy kernel musiałem wejść do jego katalogu i uruchomić menuconfig wykonując następujące komendy w terminalu:

cd /usr/src/linux
make menuconfig

Następnie musiałem zaznaczyć wszystkie opcje niezbędne do wykorzystania funkcji uśpienia i hibernacji TuxOnIce. Poniżej znajdziesz listę tych opcji.

Konfiguracja Kernela Linuxa: Włączenie funkcji TuxOnIce
Power management and  ACPI options  --->
  [*] Suspend to RAM and standby
  [*] Hibernation (aka 'suspend to disk')
  (/dev/sda8) Default resume partition
  <*>   Enhanced Hibernation (TuxOnIce)  --->
          *** Image Storage (you need at least one allocator)
    < >   File Allocator
    <*>   Swap Allocator
          *** General Options
    <*>   Compression support
    <*>   Userspace User Interface support
    (/sbin/tuxoniceui_fbspalsh) Default userui program location
    [ ]   Allow Keep Image Mode
    [*]   Replace swsusp by default
    [ ]   Wait for initrd/ramfs to run, by default
    (25)  Default waiting time for emergency boot messages
    (2000) Default extra pages allowance
    [*]   Checksum pageset2

-*- Cryptographic API  --->
  <*>   LZO compression algorithm

Jak widzisz wykorzystuję zarówno funkcję wstrzymania do Ramu jak i hibernację. Bardzo ważną rzeczą jest podanie poprawnej lokalizacji partycji wymiany. Mój swap jest zlokalizowany na /dev/sda8. W konfiguracji TuxOnIce nie będę wykorzystywał zapisywania stanu do pliku, wykorzystam jedynie zapisywanie stanu systemu na obszarze partycji wymiany. Podaję położenie interfejsu użytkownika fbspalsh aby mieć graficzne powiadamiania podczas procesu wstrzymania i przywracania sytemu. Będzie to wymagało dodatkowej konfiguracji mojego rozruchowego interfejsu powiadamiania, więcej informacji na ten temat znajdziesz poniżej. Ostatnią ważną rzeczą jest kompresja, która zmniejszy pojemność obrazu przechowującego stan systemu. Kluczowe jest aby obsługę algorytmu kompresji LZO wbudować bezpośrednio w kernel a nie skompilować jako odrębny moduł.

Po dokonaniu niezbędnych zmian w konfiguracji kernela, można przejść do jego kompilacji, instalacji i wykorzystania. Zwykle dokonuje tej operacji wykonując następujące komendy w terminalu:

cd /usr/src/linux
make && make modules_install install

Teraz mogę sprawić aby mój interfejs rozruchowy stał się kompatybilny z interfejsem TuxOnIce. W normalnych warunkach utworzyłbym interfejs rozruchowy wykorzystujący temat graficzny natural_gentoo wykonując następujące komendy w terminalu:

emerge -av splashutils splash-themes-gentoo
splash_geninitramfs --verbose --res 1024x768 --generate /boot/fbsplash-natural_gentoo-1024x768 natural_gentoo

Aby mój interfejs rozruchowy używał zainstalowanego interfejsu TuxOnIce muszę rozpakować jego obraz i skopoować do niego tuxoneice_fbsplash. Aby tego dokonać muszę wykonać następujące komendy w terminalu:

mkdir ~/initrd.d
cp /boot/fbsplash-natural_gentoo-1024x768 ~/initrd.d/
cd ~/initrd.d
gunzip -c fbsplash-natural_gentoo-1024x768 | cpio -idm --quiet -H newc
rm fbsplash-natural_gentoo-1024x768
cp /sbin/tuxoniceui_fbsplash sbin/
find . | cpio --quiet --dereference -o -H newc | gzip -9 > /boot/fbsplash-natural_gentoo-1024x768

Teraz mam graficzne powiadomienia TuxOnIce zarówno podczas procesu hibernacji jak i podczas procesu przywracania stanu systemu.

Ta konfiguracja powinna zapewnić działanie wstrzymania do ramu i hibernacji z poziomu środowiska graficznego użytkownika. Osobiście używam KDE 4.x a KDE wykorzystuje narzędzia pm-utils i hal w celu wstrzymywania i hibernowania system. Hibernacja działała niemniej uznałem, że mogę sprawić aby zaczęła działać lepiej. Aby zapewnić lepszą pracę wykorzystałem hibernate-script, który posiada pewne zalety w porównaniu z czystą implementacją pm-utils. Niektóre z tych zalet to: prosta w użyciu oparta na wtyczkach konfiguracja zapewniająca możliwość wstrzymywania maszyn wirtualnych przed zatrzymaniem systemu, możliwość zmiany interfejsu programu rozruchowego grub dla wstrzymanego systemu, możliwość odłączeniu sieciowych systemów plików przed wstrzymaniem, możliwość automatycznego restartu wybranych usług systemowych po wznowieniu systemu, możliwość automatycznej zmiany statusu komunikatorów internetowych przed wstrzymaniem. Aby wykorzystać hibernate-script musiałem go zainstalować. W Gentoo Linux zrobilibyśmy to w ten sposób:

emerge -av sys-power/hibernate-script

Największym problemem z wykorzystaniem skryptu hibernacji jest brak możliwości (poza zmianą kodu źródłowego) zmuszenia środowiska graficznego KDE do wykorzystania tego skryptu zamiast pm-utils i hala. Tak naprawdę nie trzeba zmieniać sposobu zachowania KDE dlatego, że można spowodować aby pm-utils tworzyło specjalny skrypt hala, który będzie wykorzystywał skrypt hibernacji. To rozwiązanie pochodzi ze archiwum Gentoo Linux Wiki z artykułu dotyczącego konfiguracji pm-utils. Poniżej możesz znaleźć pełny skrypt, który powinien być zapisany jako /etc/pm/sleep.d/01HibernateScripts.

Wyświetl pełny plik /etc/pm/sleep.d/01HibernateScripts
  1. #!/bin/bash
  2.  
  3. HAL_HIBERNATE="/usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux"
  4. HAL_SUSPEND="/usr/lib/hal/scripts/linux/hal-system-power-suspend-linux"
  5.  
  6. case $1 in
  7. hibernate)
  8. /bin/mv ${HAL_HIBERNATE} ${HAL_HIBERNATE}.original
  9. /bin/echo "#!/bin/bash" >> ${HAL_HIBERNATE}
  10. /bin/echo "/usr/sbin/hibernate" >> ${HAL_HIBERNATE}
  11. /bin/echo "exit \$?" >> ${HAL_HIBERNATE}
  12. /bin/chmod +x ${HAL_HIBERNATE}
  13. /usr/bin/killall pm-hibernate
  14. /usr/bin/chvt 7
  15. /usr/sbin/hibernate
  16. ;;
  17. suspend)
  18. /bin/mv ${HAL_SUSPEND} ${HAL_SUSPEND}.original
  19. /bin/echo "#!/bin/bash" >> ${HAL_SUSPEND}
  20. /bin/echo "/usr/sbin/hibernate-ram" >> ${HAL_SUSPEND}
  21. /bin/echo "exit \$?" >> ${HAL_SUSPEND}
  22. /bin/chmod +x ${HAL_SUSPEND}
  23. /usr/bin/killall pm-suspend
  24. /usr/bin/chvt 7
  25. /usr/sbin/hibernate-ram
  26. ;;
  27. esac

Jak widzisz ten plik tworzy specjalny skrypt hala, który wykorzysta komendy skryptu hibernacji do hibernowania i wstrzymywania sytemu. Powodem tak dziwnego sposobu postępowania jest fakt, że podczas aktualizacji systemu samodzielnie tworzone skrypty hala mogą zostać nadpisane. Kiedy utworzysz powyższy skrypt, skrypty hala wykorzystujące hibernate-script zawsze będą dostępne w systemie. Teraz mogę skorzystać ze skryptu hibernacji. Aby w pełni wykorzystać jego możliwości muszę się upewnić, że usługa systemowa instalowana wraz ze skryptem będzie uruchamiania wraz ze startem systemu. Ta usługa nosi nazwę hibernate-cleanup. Aby startowała ona automatycznie podczas uruchamiania powinienem wykonać następującą komendę w terminalu:

rc-update add hibernate-cleanup boot

Ostatnią rzeczą jakiej muszę dopilnować aby wstrzymywanie i wznawianie systemu działało tak jak sobie tego życzę, jest konfiguracja samego skryptu hibernacji. Aby tego dokonać musiałem poddać edycji plik /etc/hibernate/common.conf. Poniżej możesz znaleźć mój plik konfiguracyjny common.conf.

Wyświetl pełny plik /etc/hibernate/common.conf
  1. # Configuration options common for suspending to disk or RAM.
  2. # Options are not case sensitive.
  3. #
  4. # See hibernate.conf(5) for help on the configuration items.
  5.  
  6. ##############################################################################
  7. ### Some global settings
  8. ##############################################################################
  9.  
  10. Verbosity 1
  11. LogFile /var/log/hibernate.log
  12. LogVerbosity 4
  13. LogTimestamp yes
  14. # AlwaysForce yes
  15. AlwaysKill yes
  16. # HibernateVT 15
  17. Distribution gentoo
  18. # XDisplay :0
  19.  
  20. ##############################################################################
  21. ### Scriptlets
  22. ### Scriptlets provide support for doing all sorts of things before and after
  23. ### suspending. The defaults settings here should work for most people, but
  24. ### you may wish to edit these to taste. Consult "hibernate -h" for help on
  25. ### the configuration settings.
  26. ##############################################################################
  27.  
  28. ### bootsplash
  29. ## If you use bootsplash, also enabling SwitchToTextMode is recommended if
  30. ## you use X, otherwise you may end up with a garbled X display.
  31. #Bootsplash on
  32. #BootsplashConfig /etc/splash/tuxonice/1024x768.cfg
  33.  
  34. ### clock
  35. SaveClock restore-only
  36. #DirectIsa
  37.  
  38. ### devices
  39. # IncompatibleDevices /dev/dsp /dev/video*
  40.  
  41. IncompatibleDevices /dev/video*
  42.  
  43. ### diskcache
  44. DisableWriteCacheOn /dev/sda
  45.  
  46. ### fbsplash (enable SwitchToTextMode if you use this)
  47. FBSplash on
  48. FBSplashTheme natural_gentoo
  49.  
  50. ### filesystems
  51. # Unmount /nfsshare /windows /mnt/sambaserver
  52. UnmountFSTypes smbfs nfs vfs
  53. # UnmountGraceTime 1
  54. # Mount /windows
  55.  
  56. ### grub
  57. ChangeGrubMenu yes
  58. GrubMenuFile /boot/grub/grub.conf
  59. AlternateGrubMenuFile /boot/grub/menu-suspended.lst
  60. BackupGrubMenuFile /boot/grub/grub.conf.bak
  61.  
  62. # see http://bugs.debian.org/317479
  63. # RemountXFSBoot yes
  64.  
  65. ### hardware_tweaks
  66. # IbmAcpi yes
  67. RadeonTool yes
  68. # Runi915resolution yes
  69. FullSpeedCPU yes
  70.  
  71. ### lilo
  72. # EnsureLILOResumes yes
  73.  
  74. ### lock (generally you only want one of the following options)
  75. ## For console you need vlock available.
  76. ## For x you need xscreensaver-command-command available.
  77. ## For gnome you need gnome-screensaver-command available.
  78. ## For kde you need dcop, kscreensaver available.
  79. ## For XAuto you need xautolock available.
  80. ## For Xtr you need xtrlock available.
  81. ## For Freedesktop (for example KDE4) you need dbus-send available
  82. # LockConsoleAs root
  83. # LockXScreenSaver yes
  84. # LockGnomeScreenSaver yes
  85. # LockFreedesktop
  86. # LockKDE yes
  87. # LockXLock yes
  88. # LockXAutoLock yes
  89. # LockXtrLock yes
  90.  
  91. ### misclaunch
  92. OnSuspend 20 echo "Idę Spać Co się dziwisz czasami trzeba :D!"
  93. OnResume 20 echo "Gotów do roboty. No dalej co robimy!"
  94.  
  95. ### modules
  96. UnloadModules sd_ricoh
  97. # UnloadAllModules yes
  98. UnloadBlacklistedModules yes
  99. LoadModules auto
  100. # LoadModulesFromFile /etc/modules
  101.  
  102. ### modules-gentoo
  103. # GentooModulesAutoload yes
  104.  
  105. ### network
  106. DownInterfaces
  107. UpInterfaces auto
  108.  
  109. ### networkmanager
  110. EnableNMReconnect yes
  111.  
  112. ### pause_audio
  113. MuteAudio no
  114. PauseAudio yes
  115.  
  116. ### pcmcia
  117. EjectCards yes
  118.  
  119. ### programs
  120. #IncompatiblePrograms
  121.  
  122. ### services
  123. RestartServices hsf samba nfs nfsmount numlock lm_sensors sensord smartd hddtemp vixie-cron avahi-daemon irda ntpd distccd moblock sshd ulogd iptables laptop_mode acpi
  124. # StopServices alsasound
  125. # StartServices aumix
  126.  
  127. ### vbetool
  128. #EnableVbetool yes
  129. #RestoreVbeStateFrom /var/lib/vbetool/vbestate
  130. #VbetoolPost yes
  131. #RestoreVCSAData yes
  132.  
  133. ### xhacks
  134. SwitchToTextMode yes
  135. # UseDummyXServer yes
  136. # DummyXServerConfig xorg-dummy.conf
  137.  
  138. ### xstatus
  139. ## This can be set to gnome, kde or x:
  140. ## For gnome you need zenity available.
  141. ## For kde you need dcop, kstart, kdialog available.
  142. ## For x you need to have xosd OR xmessage available.
  143. # XStatus x
  144. # XmessageDisable yes
  145. # XSuspendText Preparing to suspend...
  146. # XResumeText Resuming from suspend...
  147. ## When using XStatus x, and you have xosd installed:
  148. # XosdSettings --font '-misc-fixed-medium-r-semicondensed--*-120-*-*-c-*-*-*' --colour=Green --shadow 1 --pos bottom --align center --offset 50
  149.  
  150. ### xbacklight
  151. # BackLight yes
  152.  
  153. ### gaim
  154. ## You need to have dbus, gaim_remote available.
  155. # LogoutGaim yes
  156. # GaimRestoreStatus yes
  157. # GaimLogoutMessage Hibernating
  158. # GaimLoginMessage Back from hibernation
  159.  
  160. ### pidgin
  161. LogoutPidgin yes
  162. PidginRestoreStatus yes
  163. PidginLogoutMessage Hibernating - bye!
  164. # PidginLoginMessage I'm back!
  165.  
  166. ### SSH and PGP keys
  167. # AgentsClearGPG yes
  168. # AgentsClearSSH yes
  169.  
  170. ### Virtualbox
  171. SuspendVirtualbox yes

Ten plik jest stosunkowo prosty do odczytania. W górnej jego części znajduje się konfiguracja logowania, niżej możesz znaleźć listę sieciowych systemów plików, które powinny zostać odłączone przed wstrzymaniem. Następnie możesz zobaczyć konfigurację menu programu rozruchowego grub. Więcej informacji na temat menu gruba podam poniżej. Ważną rzeczą jest lista modułów jądra, które powinny zostać usunięte z pamięci. Ja usuwam moduł obsługujący mój czytnik kart SD. Poniżej możesz znaleźć listę usług systemowych, które powinny zostać uruchomione ponownie po wznowieniu sytemu. Jak widzisz ja restartuje głównie usługi sieciowe aby mieć pewność, że będą one działały poprawnie. Dodatkowo zabezpieczam środowisko X przed wstrzymaniem, w ten sposób po wznowieniu systemu będę zmuszony do podania hasła inaczej nie będę mógł wrócić do pracy. Kolejną ważną rzeczą jest wykorzystanie narzędzia zwanego radeontool. Jest to specjalny program zapewniający zarządzanie energią dla mojej karty graficznej. Przy poprawnej konfiguracji karty graficznej w systemie, to narzędzie powinno zostać zainstalowane jako zależność dla pm-utils. Oczywiście jeśli sobie życzysz zawsze możesz zainstalować to narzędzie ręcznie wykonując następującą komendę w terminalu:

emerge -av app-laptop/radeontool

Ostatnią rzeczą, która muszę zrobić jest stworzenie menu konfiguracyjnych programu rozruchowego grub. Pierwszy plik /boot/grub/grub.conf będzie odpowiedzialny za normalny start systemu. Poniżej możesz zobaczyć mój plik grub.conf.

Wyświetl pełny plik /boot/grub/grub.conf
  1. default 0
  2. timeout 10
  3.  
  4. splashimage=(hd0,0)/boot/grub/gentoo.xpm.gz
  5.  
  6. title Gentoo Linux TuxOnIce 2.6.32-r9 (Main)
  7. root(hd0,0)
  8. kernel /boot/vmlinuz-2.6.32-tuxonice-r9 root=/dev/sda2 resume=swap:/dev/sda8 video=uvesafb:1024x768-24@60,mtrr:2,ywrap splash=kdgraphics,silent,fadein,theme:natural-gentoo quiet CONSOLE=/dev/tty1 fbcon=scrollback:256K acpi=on lapic=yes
  9. initrd (hd0,0)/boot/fbsplash-natural_gentoo-1024x768
  10.  
  11. title Gentoo Linux TuxOnIce 2.6.32-r9 (Rescue)
  12. kernel /boot/vmlinuz-2.6.32-tuxonice-r9 root=/dev/sda2 init=/bin/bb
  13.  
  14. title Memtest86Plus
  15. root(hd0,0)
  16. kernel --type=netbsd /boot/memtest86plus/memtest

Widać tutaj jedną istotną dla procesu wstrzymania i wznawiania systemu informację, parametr kernela o nazwie resume wskazujący położenie partycji wymiany. Ten parametr jest wymagany tylko wtedy jeśli nie podałbym położenia partycji wymiany podczas konfiguracji kernela. Drugi plik konfiguracyjny programu rozruchowego grub nosi nazwę /boot/grub/menu-suspended.lst. Ten plik będzie odpowiedzialny za start systemu po hibernacji. Skrypt hibernacji zatroszczy się o zamianę plików konfiguracyjnych programu rozruchowego grub podczas procesu hibernacji. Poniżej możesz zobaczyć mój plik menu-suspended.lst.

Wyświetl pełny plik /boot/grub/menu-suspended.lst
  1. default 0
  2. timeout 10
  3.  
  4. splashimage=(hd0,0)/boot/grub/gentoo.xpm.gz
  5.  
  6. title Gentoo Linux TuxOnIce 2.6.32-r9 (RESUME SUSPENDED SYSTEM)
  7. root(hd0,0)
  8. kernel /boot/vmlinuz-2.6.32-tuxonice-r9 root=/dev/sda2 resume=swap:/dev/sda8 video=uvesafb:1024x768-24@60,mtrr:2,ywrap splash=kdgraphics,silent,fadein,theme:natural-gentoo quiet CONSOLE=/dev/tty1 fbcon=scrollback:256K acpi=on lapic=yes
  9. initrd (hd0,0)/boot/fbsplash-natural_gentoo-1024x768
  10.  
  11. title Gentoo Linux TuxOnIce 2.6.32-r9 (START UNSUSPENDED SYSTEM)
  12. root(hd0,0)
  13. kernel /boot/vmlinuz-2.6.32-tuxonice-r9 root=/dev/sda2 resume=swap:/dev/sda8 noresume video=uvesafb:1024x768-24@60,mtrr:2,ywrap splash=kdgraphics,silent,fadein,theme:natural-gentoo quiet CONSOLE=/dev/tty1 fbcon=scrollback:256K acpi=on lapic=yes
  14. initrd (hd0,0)/boot/fbsplash-natural_gentoo-1024x768
  15.  
  16. title Gentoo Linux TuxOnIce 2.6.32-r9 (Rescue)
  17. kernel /boot/vmlinuz-2.6.32-tuxonice-r9 root=/dev/sda2 init=/bin/bb
  18.  
  19. title Memtest86Plus
  20. root(hd0,0)
  21. kernel --type=netbsd /boot/memtest86plus/memtest

Jak widzisz ten plik zawiera dwie konfiguracje kernela. Pierwsza, która powinna uruchomić i załadować wstrzymany system z partycji wymiany i druga, która posiada specjalny parametr kernela noresume, który spowoduje uruchomienie systemu w normalny sposób. Trzeci plik konfiguracyjny gruba /boot/grub/grub.conf.bak jest po prostu kopią pierwszego pliku. To wszystko co zrobiłem aby funkcje wstrzymania i hibernacji działały tak jak sobie tego życzę. Następną rzeczą jest konfiguracja ACPI na moim notebooku.

Konfiguracja ACPI

Konfiguracja ACPI jest procesem dwustopniowym. Pierwszy stopień to konfiguracja kernela, drugi to instalacja i konfiguracja narzędzi, które wykorzystają udostępnione przez kernel możliwości. Poniżej znajdziesz konfigurację funkcji ACPI kernela na moim notebooku.

Konfiguracja Kernela Linuxa: Włączenie funkcji ACPI
Power management and  ACPI options  --->
  [*] Power Management support 
  [*] Run-time PM core functionality 
  [*] ACPI (Advanced Configuration and Power Interface) Support  --->
    [*]   Deprecated /proc/acpi files
    [*]   Deprecated power /proc/acpi directories
    < >   ACPI 4.0 power meter
    [*]   Future power /sys interface
    [*]   Deprecated /proc/acpi/event support
    <M>   AC Adapter
    <M>   Battery
    <M>   Button
    <M>   Fan
    -*-   Dock
    <*>   Processor
    < >    Processor Aggregator
    (0)   Disable ACPI for systems before Jan 1st this year 
    <M>   Smart Battery System
      CPU Frequency scaling  --->
    [*] CPU Frequency scaling
    [*]   Enable CPUfreq debugging
    <M>   CPU frequency translation statistics
    [*]     CPU frequency translation statistics details
           Default CPUFreq governor (userspace)  --->
    <*>   'performance' governor
    <*>   'powersave' governor
    <*>   'userspace' governor for userspace frequency scaling
    <*>   'ondemand' cpufreq policy governor
    <*>   'conservative' cpufreq governor
    <M>   ACPI Processor P-States driver
 -*- CPU idle PM support
Device Drivers  --->
 [*] X86 Platform Specific Device Drivers  --->
    <M>   Asus Laptop Extras
    < >   ASUS/Medion Laptop Extras (DEPRECATED)

Jak widzisz zaznaczyłem większość dostępnych w jądrze funkcji ACPI włączając w to wszystkie możliwe polityki skalowania częstotliwości procesora. Bardzo ważną rzeczą jest zaznaczenie modułu obsługującego funkcje ACPI typowe dla dostawcy notebooka. Dla notebooków Asusa, kluczowe jest aby nie używać przestarzałego modułu jądra nawet dla tak starych modeli jak mój. Nowa obsługa funkcji ACPI będzie działała bez problemu. Teraz można zainstalować programy wykorzystujące zaawansowane możliwości komputera mobilnego.

Jeśli posiadasz już zainstalowany system ze środowiskiem graficznym, najprawdopodobniej masz już wszelkie potrzebne programy. W Gentoo Linuxie ważne jest aby dodać dwie flagi USE dotyczące zaawansowanego zarządzania energią do pliku /etc/make.conf. Te flagi to: acpi i laptop. Po dodaniu tych flag należy się upewnić, że wszystkie wykorzystujące je pakiety zostaną przebudowane. Aby dokonać tego w systemie Gentoo Linux należy wykonać następującą komendę w teminalu:

emerge --deep --newuse --update world

Powinno to spowodować zainstalowanie najważniejszego dla zarządzania energią pakietu, którym jest pm-utils. Ten pakiet powinien zostać zainstalowany jako zależność do pakietu warstwy abstrakcji sprzętu hal lub jako zależność do narzędzia zarządzania energią środowiska graficznego. Ten pakiet może być także zainstalowany ręcznie poprzez wydanie następującej komendy w terminalu:

emerge -av sys-power/pm-utils

Istnieją także inne narzędzia zarządzania energią, które możesz chcieć zainstalować w swoim systemie. Pierwszym jest demon zaawansowanego zarządzania energrią acpid, drugim jest laptop-mode-tools trzecim jest cpufrequtils. Możesz zainstalować wszystkie te narzędzia wydając następujące komendy w terminalu:

emerge -av sys-power/acpid app-laptop/laptop-mode-tools sys-power/cpufrequtils

Po zainstalowaniu tych narzędzi należy także dodać ich usługi systemowe do domyślnego poziomu uruchamiania. Aby tego dokonać w systemie Gentoo Linux należy wydać następujące komendy w terminalu:

rc-update add acpid default
rc-update add laptop-mode-tools default
rc-update add cpufrequtils default

Dzisiaj większość zadań związanych z zarządzaniem energią jest wykonywana przez narzędzia zarządzania energią środowiska graficznego. KDE środowisko graficzne, którego używam posiada naprawdę dobre narzędzie nazwane PowerDevil. Dodałem wszystkie powyższe usługi do domyślnego poziomu uruchamiany, gdyż chcę mieć wsparcie dla zaawansowanego zarządzania energią nawet jeśli nie jestem jeszcze zalogowany do środowiska graficznego. Jedna z tych usług wymaga dodatkowej konfiguracji. Cpufrequtils wymaga podania polityki skalowania częstotliwości procesora, która powinna być ustawiona na starcie i po zatrzymaniu tej usługi systemowej. Ta konfiguracja powinna zostać wpisana do pliku /etc/conf.d/cpufrequtils. Poniżej możesz znaleźć mój plik /etc/conf.d/cpufrequtils.

Wyświetl pełny plik /etc/conf.d/cpufrequtils
  1. # /etc/conf.d/cpufrequtils: config file for /etc/init.d/cpufrequtils
  2.  
  3. # Options when starting cpufreq (given to the `cpufreq-set` program)
  4. START_OPTS="--governor ondemand"
  5.  
  6. # Options when stopping cpufreq (given to the `cpufreq-set` program)
  7. STOP_OPTS="--governor performance"

W ten sposób mam dynamiczne skalowanie częstotliwości procesora przed zalogowaniem się do środowiska graficznego. Teraz posiadam narzędzia, których potrzebuje ostatnia rzecz to konfiguracja dodatkowych przycisków notebooka.

Konfiguracja przycisków multimedialnych

Konfiguracja przycisków multimedialnych w Linuxie jest znacznie prostsza dziś niż była w przeszłości. Dzięki obsłudze wbudowanej bezpośrednio w hal, przyciski multimedialne większości notebooków są rozpoznawane jako normalne klawisze i mogą być skonfigurowane za pomocą dowolnego narzędzia konfiguracji klawiszy. Dawniej konfiguracja nie była aż taka trudna ale wymagała nieco więcej pracy gdyż należało utworzyć specjalne skrypty, które wykonywały zdefiniowane akcje kiedy klawisze były wciskane. Niestety nie wszystkie przyciski mojego notebooka mogłem skonfigurować nową metodą. Jeden z moich przycisków nie został rozpoznany a kolejny nie zachowywał się w sposób jakiego ja oczekiwałem. Właśnie dla tego moja konfiguracja używa obu podejść nowego dla tych przycisków, które zostały poprawnie rozpoznane i starego dla 2 przycisków, które nie zostały rozpoznane. Poniżej możesz znaleźć listę dodatkowych multimedialnych przycisków i akacje jakie chciałbym aby były wykonywane podczas ich wciskania.

Lista moich przycisków:
  • Przycisk Uśpij - Wstrzymanie systemu do pamięci Ram - ten przycisk działał poprawnie w KDE bez konieczności dodatkowej konfiguracji.
  • Przycisk Sieci Bezprzewodowej (2 przyciski) - Włączanie i wyłączanie bezprzewodowych interfejsów sieciowych.
  • Przycisk Zwiększający Jasność Ekranu - Ten przycisk jest obsługiwany sprzętowo. Funkcja zwiększająca jasność ekranu działa nawet bez załadowanego systemu operacyjnego.
  • Przycisk Zmniejszający Jasność Ekranu - Ten przycisk jest obsługiwany sprzętowo. Funkcja zmniejszająca jasność ekranu działa nawet bez załadowanego systemu operacyjnego.
  • Przycisk LCD - Ten przycisk jest obsługiwany sprzętowo. Funkcja przełączania pomiędzy włączonym i wyłączonym ekranem LCD działa nawet bez załadowanego systemu operacyjnego.
  • Przycisk LCD - CRT - Przełączanie pomiędzy dostępnymi konfiguracjami podwójnych ekranów.
  • Przycisk Wyciszania Dźwięku - Wyciszenie miksera dźwięku - ten przycisk działał poprawnie w KDE bez konieczności dodatkowej konfiguracji.
  • Przycisk Zwiększający Głośność - Zwiększenie głośności - ten przycisk działał poprawnie w KDE bez konieczności dodatkowej konfiguracji.
  • Przycisk Zmniejszający Głośność - Zmniejszenie głośności - ten przycisk działał poprawnie w KDE bez konieczności dodatkowej konfiguracji.
  • Przycisk Poczty - Uruchamianie klienta pocztowego Kmail.
  • Przycisk WWW - Uruchamianie przeglądarki internetowej Chromium.
  • Przycisk Touchpada - Włączanie i wyłączanie toichpada - ten przycisk nie został rozpoznany jako normalny przycisk.
  • Przycisk Wydajności - Przełączenie pomiędzy dostępnymi profilami wydajności - ten przycisk został rozpoznany jako przycisk wygaszacza ekranu.
  • Przycisk Odtwarzanie | Pauza - Przełączanie pomiędzy odtwarzaniem i wstrzymaniem odtwarzania w odtwarzaczu multimedialnym Amarok.
  • Przycisk Następny Utwór - Następny Utwór w odtwarzaczu Amarok.
  • Przycisk Poprzedni Utwór - Poprzedni Utwór w odtwarzaczu Amarok.
  • Przycisk Stop - Zatrzymanie odtwarzania w odtwarzaczu Amarok.
  • Przycisk Uruchom Media - Uruchamianie odtwarzacza Amarok.

Jak widać niektóre przyciski mojego notebooka działały bez konieczności dodatkowej konfiguracji. Domyślne ustawienia środowiska graficznego KDE zakładają, że takie przyciski będą dostępne w systemie. Inne poprawnie rozpoznane przyciski skonfigurowałem wykorzystując dostępne w KDE narzędzia konfiguracji klawiszy. Dla przycisków multimedialnych : Odtwarzanie | Pauza, Następny Utwór, Poprzedni Utwór i Stop użyłem narzędzia Globalne Skróty Klawiszowe dla odtwarzacza Amarok. Wszystko co musiałem zrobić to wybrać funkcje programu Amarok odpowiadającą przyciskowi i przycisnąć przycisk aby powiązać go z tą funkcją. Kosztowało to całe 30 sekund pracy. Dla przycisków Poczta, WWW i Uruchom Media użyłem narzędzia konfiguracji Akcji Klawiszowych. Stworzyłem trzy nowe skróty Globalne do Polecenia/URL: pierwszy do polecenia /usr/bin/chromium przypisany do przycisku WWW, drugi do polecenia /usr/bin/kmail przypisany do przycisku Poczta ostatni do polecenia /usr/bin/amarok przypisany do przycisku Media Start. W ten sposób mogę uruchamiać przeglądarkę internetową, klienta poczty i ulubiony odtwarzacz multimedialny przy użyciu przycisków mojego notebooka. To była prostsza część konfiguracji. Muszę przyznać, że miałem nieco więcej problemów z konfiguracją przycisków sieci bezprzewodowej i wydajności. Głównym problemem był fakt, że nie mogłem znaleźć komend systemowych lub komend dbus aby zrealizować funkcje, które chciałem powiązać z tymi przyciskami. Ale dla chcącego nie ma nic trudnego. W konfiguracji przycisku sieci bezprzewodowej pomógł mi świetny skrypt stworzony przez Poula Sladena dla pakietu acpi-support dystrybucji Ubuntu. Wykorzystałem jego funkcje sprawdzające stan urządzeń sieci bezprzewodowych i przełączające stan tych urządzeń z trybu włączonego w wyłączony i na odwrót. Skorzystałem z tych funkcji nieco inaczej niż były one wykorzystane w pakiecie acpi-support. Stworzyłem trzy skrypty. Pierwszy nazwałem wireless-toggle.sh. Poniżej możesz zobaczyć ten skrypt.

Wyświetl pełny plik wireless-toggle.sh
  1. #Function to toggle wireless interfaces originaly created by Paul Sladen for Ubuntu acpi-support package
  2. for DEVICE in /sys/class/net/* ; do
  3. if [ -d $DEVICE/wireless ] ; then
  4. # $DEVICE is a wireless device.
  5.  
  6. FOUND=
  7. # Yes, that's right... the new interface reverses the truth values.
  8. ON=1
  9. OFF=0
  10. for CONTROL in $DEVICE/device/rfkill/rfkill*/state; do
  11. if [ -w "$CONTROL" ]; then
  12. FOUND=1
  13.  
  14. if [ "$(cat "$CONTROL")" = "$ON" ] ; then
  15. # It's powered on. Switch it off.
  16. echo -n "$OFF" > "$CONTROL"
  17. else
  18. # It's powered off. Switch it on.
  19. echo -n "$ON" > "$CONTROL"
  20. fi
  21. fi
  22. done
  23. # it might be safe to assume that a device only supports one
  24. # interface at a time; but just in case, we short-circuit
  25. # here to avoid toggling the power twice
  26. if [ -n "$FOUND" ]; then
  27. continue
  28. fi
  29.  
  30. ON=0
  31. OFF=1 # 1 for rf_kill, 2 for power/state
  32. for CONTROL in $DEVICE/device/rf_kill $DEVICE/device/power/state ; do
  33. if [ -w $CONTROL ] ; then
  34. # We have a way of controlling the device, lets try
  35. if [ "`cat $CONTROL`" = 0 ] ; then
  36. # It's powered on. Switch it off.
  37. if echo -n $OFF > $CONTROL ; then
  38. break
  39. else
  40. OFF=2 # for power/state, second time around
  41. fi
  42. else
  43. # It's powered off. Switch it on.
  44. if echo -n $ON > $CONTROL ; then
  45. break
  46. fi
  47. fi
  48. fi
  49. done
  50. fi
  51. done

Ten skrypt wykorzystuje funkcje Poula Sladena przełączającą stan wszystkich urządzeń sieci bezprzewodowej. Ważną rzeczą jest fakt, że skrypt ten musi być uruchamiany z podwyższonymi uprawnieniami systemowymi. Zwykły użytkownik nie będzie w stanie z niego skorzystać. Wraz z przełączaniem stanu urządzeń sieci bezprzewodowej użytkownik powinien być także informowany o ich aktualnym stanie przez diodę umieszczoną na przednim panelu notebooka. Aby to zrealizować stworzyłem drugi skrypt, który nazwałem wireless-led.sh. Poniżej możesz zobaczyć ten skrypt.

Wyświetl pełny plik wireless-led.sh file
  1. #/bin/sh
  2.  
  3. echo $1 > /sys/devices/platform/asus_laptop/wlan

Jak widzisz ten skrypt jest bardzo prosty przekazuje on pierwszy parametr do urządzenia sterującego diodą systemową. Aby zaświecić diodę muszę uruchomić ten skrypt w następujący sposób: ./wireless-led.sh 1. Aby wyłączyć diodę muszę uruchomić ten skrypt w następujący sposób: ./wireless-led.sh 0. Ten skrypt także wymaga podwyższonych uprawnień systemowych. Zapisałem oba skrypty w katalogu /usr/local/bin. Aby sprawić, że oba powyższe skrypty będą mogły być wykorzystane przez normalnego użytkownika użyłem narzędzia sudo. W Gentoo Linuxie możesz zainstalować sudo wykonując następujące polecenia w terminalu:

emerge  -av app-admin/sudo

Mając zainstalowane sudo w systemie wszystko co muszę zrobić to uruchomić narzędzie visudo i dopisać poniższą konfigurację aby pozwolić dowolnemu użytkownikowi zalogowanemu na moim notebooku wykonać skrypty z podwyższonymi uprawnieniami bez potrzeby podawania hasła.

ALL notebook = NOPASSWD: /usr/local/bin/wireless-led.sh
ALL notebook = NOPASSWD: /usr/local/bin/wireless-toggle.sh

Ostatnią rzeczą jaką musiałem zrobić aby moje urządzenia bezprzewodowe były zarządzane za pomocą przycisków notebooka to stworzenie skryptu, który wykorzysta oba powyższe skrypty do przełączania stanu urządzeń i diody kontrolnej notebooka. Nazwałem ten skrypt wireless.sh i zapisałem go w katalogu /usr/local/bin. Poniżej możesz zobaczyć skrypt wireless.sh.

Wyświetl pełny plik wireless.sh
  1. #!/bin/sh
  2. #Function to check status originaly created by Paul Sladen for Ubuntu acpi-support package
  3. isAnyWirelessPoweredOn()
  4. {
  5. for DEVICE in /sys/class/net/* ; do
  6. if [ -d $DEVICE/wireless ]; then
  7. # Hurray for stable interfaces... now the rfkill is scarcely
  8. # associated with the network device at all (!)
  9. for RFKILL in $DEVICE/device/rfkill/rfkill*/state; do
  10. if [ -r "$RFKILL" ] && [ "$(cat "$RFKILL")" -eq 1 ]
  11. then
  12. return 0
  13. fi
  14. done
  15. # if any of the wireless devices are turned on then return success
  16. if [ -r $DEVICE/device/power/state ] && [ "`cat $DEVICE/device/power/state`" -eq 0 ]
  17. then
  18. return 0
  19. fi
  20. if [ -r $DEVICE/device/rf_kill ] && [ "`cat $DEVICE/device/rf_kill`" -eq 0 ]
  21. then
  22. return 0
  23. fi
  24. fi
  25. done
  26.  
  27. # otherwise return failure
  28. return 1
  29. }
  30.  
  31. if (isAnyWirelessPoweredOn); then
  32. kdialog --passivepopup "Wyłączam Interfejsy bezprzewodowe" --title "Wciśnięty przycisk Wifi"
  33. else
  34. kdialog --passivepopup "Włączam Interfejsy bezprzewodowe" --title "Wciśnięty przycisk Wifi"
  35. fi
  36.  
  37. sudo /usr/local/bin/wireless-toggle.sh
  38.  
  39. if (isAnyWirelessPoweredOn); then
  40. sudo /usr/local/bin/wireless-led.sh 1
  41. else
  42. sudo /usr/local/bin/wireless-led.sh 0
  43. fi

Ten skrypt wykorzystuje funkcję Poula Sladena do sprawdzenia stanu urządzeń bezprzewodowych, następnie informuje użytkownika za pomocą pasywnego okna powiadomienia KDE o czynności, która będzie podjęta, w kolejnym kroku wykorzystuje sudo do przełączenia stanu urządzeń bezprzewodowych i diody powiadamiającej. Ten plik został powiązany z przyciskiem sieci bezprzewodowej mojego notebooka poprzez utworzenia nowego Skrótu Globalnego do Polecenia/URL w narzędziu konfiguracji Akcji Klawiszowych. W ten sposób mogę włączać i wyłączać urządzenia bezprzewodowe używając jednego z dwóch dostępnych w moim notebooku klawiszy sieci bezprzewodowej.

Na szczęście przycisk wydajności wymagał tylko jednego skryptu. Jak napisałem powyżej chciałbym aby ten przycisk przełączał mnie pomiędzy zdefiniowanymi w systemie profilami wydajności. KDE posiada świetne narzędzie zarządzania profilami wydajności o nazwie PowerDevil. Stworzyłem skrypt, który używa komendy Dbus dostępnej w narzędziu PowerDevil do przełączania profili. Poniżej możesz zobaczyć mój skrypt performance.sh.

Wyświetl pełny plik performance.sh
  1. #!/bin/sh
  2.  
  3. PROFILES="/usr/local/bin/profiles"
  4.  
  5. test -f ${PROFILES} || exit 0
  6.  
  7. TEMPFILE=/tmp/${USER}-profile.tmp
  8.  
  9. if (test -f ${TEMPFILE}) then
  10. read line < ${TEMPFILE}
  11. PROFILE=${line}
  12. else
  13. PROFILE=Dynamic
  14. fi
  15.  
  16. i=0
  17. flaga=0
  18.  
  19. while read line
  20. do
  21. i=`expr $i + 1`
  22. if (test "${line}" = "${PROFILE}") then
  23. flaga=$i
  24. fi
  25. done < ${PROFILES}
  26.  
  27. if (test $flaga -eq $i) then
  28. flaga=1
  29. else
  30. flaga=`expr $flaga + 1`
  31. fi
  32.  
  33. j=0
  34.  
  35. while read line
  36. do
  37. j=`expr $j + 1`
  38. if (test $flaga -eq $j) then
  39. PROFILE=${line}
  40. fi
  41. done < ${PROFILES}
  42.  
  43. CMD="dbus-send --print-reply --session --dest=org.kde.powerdevil /modules/powerdevil org.kde.PowerDevil.setProfile string:"
  44.  
  45. ${CMD}"${PROFILE}"
  46.  
  47. echo ${PROFILE} > ${TEMPFILE}

Ten skrypt przechodzi prze listę profili zdefiniowanych w osobnym pliku, oznaczając aktualnie wybrany profil i przełączając na następny profil na liście przy wykorzystaniu komendy Dbus programu PowerDevil o nazwie setProfile. Aby skorzystać z tego skryptu musiałem zdefiniować kolejny plik zawierający nazwy wszystkich zdefiniowanych w systemie profili wydajności. Poniżej możesz zobaczyć plik z moją listą profili.

Wyświetl plik z listą profili
  1. Performance
  2. Performance No3D
  3. Dynamic
  4. Presentation
  5. Powersave
  6. Aggressive Powersave
  7. Xtreme Powersave

Powiązałem skrypt performance.sh z przyciskiem wydajności w ten sam sposób jak zrobiłem to dla przycisku sieci bezprzewodowej tworząc nowy Skrót Globalny do Polecenia/URL w narzędziu konfiguracji Akcji Klawiatury.

Zostały już tylko dwa nie skonfigurowane przyciski. Te przyciski skonfigurowałem używając starszego podejścia. Niestety mój przycisk TouchPada nie został rozpoznany w ten sam sposób jak inny przyciski. Zapewne konfiguracja mojego nieco przestarzałego notebooka nie jest w pełni wspierana przez nowe reguły mapowania hala. Właśnie dla tego potrzebowałem dodatkowego narzędzia stworzonego specjalnie dla notebooków Asusa. To narzędzie nosi nazwę acpi4asus. Aby zainstalować je w systemie Gentoo Linux musiałem wykonać następujące polecenia w terminalu:

echo "app-laptop/acpi4asus ~x86" > /etc/portage/package.keywords
emerge -av app-laptop/acpi4asus

To narzędzie dostarcza małego programu, który pomaga rozpoznać wciśnięte przyciski jako zdarzenia acpi. Dzięki temu mogę skonfigurować ostanie dwa przyciski. Przede wszystkim muszę mieć pewność, że ten mały program będzie uruchamiany automatycznie ilekroć zaloguję się do środowiska graficznego KDE. Aby tak się stało stworzyłem prosty skrypt, który uruchomi ten program i zapisałem go w swoim katalogu domowym w podkatalogu ~/.kde4/Autostart. Poniżej możesz zobaczyć mój plik asusacpid.sh.

  1. #!/bin/sh
  2.  
  3. /usr/bin/asus_acpid

W ten sposób przy każdym zalogowaniu do środowiska graficznego KDE ten mały program zostanie uruchomiony i będzie zapewniał obsługę stworzonej dla niego konfiguracji. Konfiguracja tego narzędzia powinna znaleźć się wewnątrz mojego katalogu domowego w podkatalogu o nazwie .asus_acpi. Sama konfiguracja jest względnie prosta należy stworzyć pliki, które powiążą kody zdarzeń acpi wywołanych poprzez wciśnięcie klawiszy z pożądanymi przez użytkownika akcjami. Poniżej możesz zobaczyć mój plik mapujący akcje dla przycisku TouchPada.

Wyświetl plik ~/.asus_acpi/events/asus-touchpad
  1. # /etc/acpi/events/asus-touchpad
  2. # This is called when the user presses the touchpad button and calls
  3. # /etc/acpi/asus-touchpad.sh for further processing.
  4.  
  5. event=hotkey (ATKD|HOTK) 0000006a
  6. action=~/.asus_acpi/actions/asus-touchpad.sh &

Jak widzisz mój przycisk jest powiązany ze zdarzeniem acpi o kodzie 0000006a. Kiedy wcisnę ten przycisk program pomocniczy asus_acpid uruchomi skrypt ~/.asus_acpi/actions/asus-touchpad.sh. Ten skrypt oczywiście powinien być odpowiedzialny za wyłączenie i włączenie mojego touchpada. Poniżej możesz zobaczyć mój skrypt ~/.asus_acpi/actions/asus-touchpad.sh.

Wyświetl plik ~/.asus_acpi/events/asus-touchpad
  1. #!/bin/bash
  2. state=$(synclient -l | grep TouchpadOff | awk -F"= " '{print $2}')
  3. if [ "$state" = "0" ]; then
  4. kdialog --passivepopup "Wyłączam TouchPad" --title "Wciśnięty przycisk TouchPad"
  5. synclient TouchpadOff=1
  6. else
  7. kdialog --passivepopup "Włączam TouchPad" --title "Wciśnięty przycisk TouchPad"
  8. synclient TouchpadOff=0
  9. fi

Jak widzisz ten skrypt nie jest skomplikowany. Odczytuje on aktualny stan touchpada i w zależności od tego stanu informuje użytkownika pasywny oknem informacyjnym KDE o czynności, która zostanie podjęta i włącza lub wyłącza touchpad przy użyciu polecenia synclient. Ten skrypt powinien działać. Jednakże przekonałem się, że mój sterownik touchpada synaptics musi być dodatkowo skonfigurowany w konkretny sposób w pliku konfiguracyjnym serwera X Xorg.conf. Bez tej dodatkowej konfiguracji polecenie synclient nie było wstanie uzyskać dostępu do touchpada. Poniżej możesz zobaczyć fragment mojego pliku xorg.conf dotyczący konfiguracji sterownika synaptics.

Wyświetl fragment pliku /etc/X11/Xorg.conf
  1. Section "InputDevice"
  2. Identifier "Synaptics0"
  3. Driver "synaptics"
  4. Option "Protocol" "auto"
  5. Option "SendCoreEvents" "true"
  6. Option "Protocol" "auto"
  7. Option "SHMConfig" "on"
  8. EndSection

Najważniejszą rzeczą w tej konfiguracji jest opcja Option "SHMConfig" "on". To ustawienie powoduje, że touchpad staje się dostępny dla polecenia synclient. To już wszystko co należy zrobić aby przycisk wyłączający touchpada działał.

Ostatni przyciskiem do skonfigurowania jest przycisk LCD - CRT. Chciałbym aby ten przycisk przełączał mnie pomiędzy konfiguracjami podwójnych ekranów. Przekonałem się, że wciskanie tego przycisku generuje 3 różne kody zdarzeń acpi. Kiedy wciskam przycisk po raz pierwszy generuje on kod 00000061, przy drugim wciśnięciu generuje on kod 00000062 a przy trzecim generuje on kod 00000063. Dzięki takiemu działaniu mogę w prosty sposób przypisać 3 różne akcje i przełączać się pomiędzy nimi używając jednego klawisza. Pierwszą rzeczą jaką muszę zrobić to stworzyć mapowania zdarzeń acpi. Pierwsze z nich nazwałem asus-screen1. Poniżej możesz zobaczyć ten plik.

Wyświetl plik ~/.asus_acpi/events/asus-screen1
  1. # ~/.asus_acpi/events/asus-screen1
  2. # This is called when the user is presing screen lcd/crt button,
  3.  
  4. event=hotkey (ATKD|HOTK) 00000061
  5. action=~/.asus_acpi/actions/screen1.sh &

Drugi nazwałem asus-screen2. Poniżej możesz zobaczyć ten plik.

Wyświetl plik ~/.asus_acpi/events/asus-screen2
  1. # ~/.asus_acpi/events/asus-screen2
  2. # This is called when the user is presing screen lcd/crt button,
  3.  
  4. event=hotkey (ATKD|HOTK) 00000062
  5. action=~/.asus_acpi/actions/screen2.sh &

Trzeci nazwałem asus-screen3. Poniżej możesz zobaczyć ten plik.

Wyświetl plik ~/.asus_acpi/events/asus-screen3
  1. # ~/.asus_acpi/events/screen3
  2. # This is called when the user is presing screen lcd/crt button,
  3.  
  4. event=hotkey (ATKD|HOTK) 00000063
  5. action=~/.asus_acpi/actions/screen3.sh &

Każdy z plików mapujących zdarzenia wskazuje skrypt umieszczony w katalogu akcji. Pierwszy z tych skryptów nosi nazwę screen1.sh. Poniżej możesz zobaczyć ten plik.

Wyświetl plik ~/.asus_acpi/actions/screen1.sh
  1. #!/bin/sh
  2.  
  3. kdialog --passivepopup "Wyłączam drugi ekran" --title "Wciśnięty przycisk Screen"
  4.  
  5. xrandr --output LVDS --auto --output VGA-0 --off

Ten skrypt wyłącza potencjalnie podłączony do mojego notebooka drugi ekran i ustawia domyślną rozdzielczość na ekranie głównym przy użyciu narzędzia linii komend xrandr. Drugi z tych skryptów nosi nazwę screen2.sh. Poniżej możesz zobaczyć ten plik.

Wyświetl plik ~/.asus_acpi/actions/screen2.sh
  1. #!/bin/sh
  2.  
  3. kdialog --passivepopup "Ustawiam oba ekrany w tryb klonowania" --title "Wciśnięty przycisk Screen"
  4.  
  5. xrandr --output LVDS --mode 1024x768 --output VGA-0 --mode 1024x768 --same-as LVDS

Ten skrypt ustawia na obu ekranach rozdzielczość 1024x768 i pozycjonuje jeden ekran na drugim włączając tym samym tryb klonowania wyjść. Trzeci z tych skryptów nosi nazwę screen3.sh. Poniżej możesz zobaczyć ten plik.

Wyświetl plik ~/.asus_acpi/actions/screen3.sh
  1. #!/bin/sh
  2.  
  3. kdialog --passivepopup "Uaktywniam oba ekrany w trybie domyślnej rozdzielczości " --title "Wciśnięty przycisk Screen"
  4.  
  5. xrandr --output LVDS --auto --output VGA-0 --auto --right-of LVDS

Ten skrypt ustawia domyślną rozdzielczość na obu ekranach i umieszcza drugi ekran po prawej stronie pierwszego ekranu. Teraz mogę się przełączać między zdefiniowanymi konfiguracjami przy użyciu jednego przycisku. Jest to niezwykle ważne dla mnie gdyż często wykorzystuję mój komputer w czasie pokazów dla publiczności.

To zamyka moją konfigurację. Mam wszystkie klawisze skonfigurowane dokładnie tak jak sobie tego życzyłem. Właśnie za to kocham Gentoo Linuxa. Jeśli chcę czegoś mogę tego dokonać, nie jestem przywiązany do żadnej domyślnej konfiguracji. Na sam koniec dodam jedną dość oczywistą rzecz. Wszystkie wspomniane tutaj skrypty muszą być zapisane z atrybutem wykonywalności zanim będzie można z nich skorzystać. Aby tego dokonać należy wykonać następującą komendę w terminalu:

chmod +x /path-to-script/script-name.sh

Informacje dodatkowe

Aby w pełni opisać moją konfigurację muszę dodać, że zrobiłem coś jeszcze. Mój notebook posiada diodę powiadamiającą o poczcie. Chciałby aby świeciła się ona kiedy mój domyślny klient pocztowy pobierze nową wiadomość z jednej z moich skrzynek pocztowych. Aby sprawić, że dioda będzie się świeciła stworzyłem skrypt mailledon.sh. Poniżej możesz zobaczyć ten plik.

Wyświetl plik mailledon.sh
  1. #!/bin/sh
  2.  
  3. echo 1 > /sys/class/leds/asus\:\:mail/brightness

Ten skrypt przekazuje wartość 1 do urządzenia diody, co powinno ją włączyć. Niestety ten skrypt musi być uruchomiony z podwyższonymi uprawnieniami systemowymi. W związku z tym dodatkowo musiałem uruchomić narzędzie visudo i dodać poniższą linię do konfiguracji sudo.

ALL notebook = NOPASSWD: /usr/local/bin/mailledon.sh

To pozwoli dowolnemu użytkownikowi zalogowanemu na moim notebooku wykorzystać ten skrypt bez potrzeby podawania hasła. Dopisałem ten skrypt w konfiguracji klienta pocztowego Kmail w sekcji Szczegółowe powiadamianie o nowej poczcie w następujący sposób:

sudo /usr/local/bin/mailledon.sh

Teraz kiedy otrzymuję nowego maila dioda się radośnie świeci.

Skopiowałem całą moją konfigurację do katalogu /etc/skel. Konkretnie skopiowałem całą zawartość katalogu ~/.asus_acpi wraz z plikami: ~/.kde4/Autostart/asusacpid.sh, ~/.kde4/share/config/khotkeysrc, ~/.kde4/share/config/kglobalshortcutsrc, ~/.kde4/share/config/powerdevilprofilesrc i ~/.kde4/share/config/powerdevilprofilesrc. Dzięki temu kiedy zakładałem nowe konto użytkownika dla mojej lepszej połowy jej profil od razu posiadał całą pożądaną konfigurację przycisków multimedialnych. Nie musiała się męczyć samemu.

Większość z wymienionych powyżej skryptów jest dostępna na moim serwerze svn. Poniżej możesz znaleźć bezpośrednie odnośniki do nich.

Dowód, że to działa

Źródła