LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   How to make special keys run commands without X? (https://www.linuxquestions.org/questions/slackware-14/how-to-make-special-keys-run-commands-without-x-812436/)

catkin 06-06-2010 05:46 AM

How to make special keys run commands without X?
 
Hello :)

I'm installing Slackware 13.1 on a Samsung N150 netbook and am stuck trying to make the special keys do their normal functions when using a virtual terminal, that is not under X. Under X + Xfce it can be done via Menu->Settings->Keyboard->"Application Shortcuts".

In essence the question is how to make a special key (example Fn+Up to increase screen brightness) run a command in the background.

EDIT: Changed title and text to make clear that the command should not run in a virtual terminal but while the display is being used for a virtual terminal, that is after Ctrl+Alt+F2 for example.

Best

Charles

T3slider 06-06-2010 11:14 PM

This page should be helpful. Also see /etc/inputrc and `man 3 readline` for more information. If you use screen you can always configure keybindings there as well.

catkin 06-07-2010 02:17 AM

Thanks T3slider :)

Thinking this through some more it's a hardware-level requirement. Ideally it would work at a virtual terminal even before login. Maybe it is not possible because all (?) keystrokes are intercepted by the login process that replaces the getty-type process but Linux is very flexible and powerful so I still have some hope. Perhaps keystrokes are passed to the login process via the kernel or perhaps there is a hardware event in hal land ...

dive 06-07-2010 02:48 AM

Fn keys are usually controlled through acpi events if the hardware doesn't do it alone.

Check out /etc/acpi/acpi_handler.sh

catkin 06-07-2010 03:38 AM

Quote:

Originally Posted by dive (Post 3995070)
Fn keys are usually controlled through acpi events if the hardware doesn't do it alone.

Check out /etc/acpi/acpi_handler.sh

Thanks dive :)

It looks as if Fn+<whatever> does not create ACPI events.

In the default installation, the /etc/acpi/events directory has a single file, defaults, which looks as if it simply passes all events to acpi_handler.sh:
Code:

root@CW9:~# cat /etc/acpi/events/default | grep -E -v '^#|^$'
event=.*
action=/etc/acpi/acpi_handler.sh %e

The as-installed acpi_handler.sh reports everything except the power button as "not defined":
Code:

root@CW9:~# cat /etc/acpi/acpi_handler.sh | grep -E -v '^#|^$'
IFS=${IFS}/
set $@
case "$1" in
  button)
    case "$2" in
      power) /sbin/init 0
        ;;
      *) logger "ACPI action $2 is not defined"
        ;;
    esac
    ;;
  *)
    logger "ACPI group $1 / action $2 is not defined"
    ;;
esac

Searching the /var/log/* files for such reports shows very few and none associated with Fn+ keys:
Code:

root@CW9:/var/log# grep 'ACPI group' * | sed 's/.*logger: //' | sort | uniq
ACPI group ac_adapter / action ADP1 is not defined
ACPI group battery / action BAT1 is not defined
ACPI group processor / action CPU0 is not defined
ACPI group processor / action CPU1 is not defined



All times are GMT -5. The time now is 03:04 PM.