evrouter
can help to do that. It will even allow to release G9 before selecting the task from the list.
http://www.bedroomlan.org/projects/evrouter
I've built it from source and installed with checkinstall
, but there is something that looks like a repository there.
Hooks
It can be configured in the ~/.evrouterrc
:
"Logitech Gaming Mouse G300" "/dev/input/event.*" any key/272 "SHELL//home/velkan/click.sh"
"Logitech Gaming Mouse G300" "/dev/input/event.*" any key/275 "SHELL//home/velkan/atab.sh"
Running sudo evrouter -d /dev/input/event*
and clicking around will help to compose these lines.
"Logitech Gaming Mouse G300"
is the name of my mouse.
"/dev/input/event.*"
means that input will be intercepted regardless of the name of device file to which the mouse is bound.
any
- means that the event will be accepted with any Alt/Ctrl/Shift modifier.
key/272
- left mouse button.
key/275
- back mouse button (on G4 for me).
"SHELL//home/velkan/click.sh"
- run /home/velkan/click.sh
when that event occurs.
Alt-Tab scripts
So, the /home/velkan/atab.sh
script (that is bound to G4 in this case):
#!/bin/bash
mktemp /tmp/evr-alt-tab-XXXX
/usr/bin/xte 'usleep 100000' 'keydown Alt_L' 'usleep 50000' 'key Tab'
It creates a temporary file that will inform the click.sh
(bound to the left button) that it needs to release Alt.
click.sh
script:
#!/bin/bash
if [ -e /tmp/evr-alt-tab-???? ]; then
/usr/bin/xte 'usleep 100000' 'keyup Alt_L'
rm /tmp/evr-alt-tab-????
fi
Activating evrouter on startup
Haven't tried that on KDE.
Launch script /usr/local/sbin/evrouter_launch.sh
:
#!/bin/sh
/usr/local/bin/evrouter /dev/input/event* 0<&- > /dev/null
(or it may be /usr/bin/evrouter
instead of /usr/local/bin/evrouter
)
Config /etc/lightdm/lightdm.conf
to start evrouter with the desktop manager:
[SeatDefaults]
autologin-user=
session-setup-script=/usr/local/sbin/evrouter_launch.sh
I created GitHub repository for k380 configuration program.
https://github.com/jergusg/k380-function-keys-conf
I did the same steps as Mario to get sequence for k380.
The code is same as Mario's, but with the sequence for k380 keyboard and k380 device ID.
It outputs write: 0 were written instead of 7
on my computer, but it works anyway.
The sequences are:
const char k380_seq_fkeys_on[] = {0x10, 0xff, 0x0b, 0x1e, 0x00, 0x00, 0x00};
const char k380_seq_fkeys_off[] = {0x10, 0xff, 0x0b, 0x1e, 0x01, 0x00, 0x00};
Best Answer
From the CLI, UPower can do this:
From the GUI,
mate-power-statistics
(from the MATE Power Manager project) orgnome-power-statistics
(from the GNOME Power Manager project) can do this.