milgner / k290-fnkeyctl

Configures the behaviour of the F-keys on the Logitech K290
MIT License
222 stars 29 forks source link

Auto set keys on plug / unplug #3

Closed Neamar closed 10 years ago

Neamar commented 10 years ago

Hi,

Really great script. I searched for something like that a few months ago without any success, so really happy to find it now.

One small caveat though, the setting is reset each time i plug / unplug / sleep / hibernate / reboot. Do you think there is any way it can be set automatically each time?

Else i guess i can find a place to run the script after boot / unsleep, but not after plugging the keyboard in ;)

Once again, really nice work.

milgner commented 10 years ago

Hi,

thanks a lot! I'm glad it is of use to others as well :) I'm pretty sure it should be quite straightforward to achieve what you describe using a udev rule. Until now I didn't need such a script but I'll gladly give it a go.

milgner commented 10 years ago

So I added a udev rules file and it works great. Feel free to check it out and thanks for the idea!

To install, just put 99-k290-config.rules in /etc/udev/rules.d and restart udev to have it pick it up.

Neamar commented 10 years ago

Great! I'll test that on monday.

Neamar commented 10 years ago

Sadly, it does not seem to works.

Here is a ll from /etc/udev/rules.d:

total 24
drwxr-xr-x 2 root root 4096 Apr 26 18:27 ./
drwxr-xr-x 4 root root 4096 Apr  1 11:31 ../
-rw-r--r-- 1 root root  862 Apr 30  2013 70-persistent-cd.rules
-rw-r--r-- 1 root root  458 Apr 17  2013 70-persistent-net.rules
-rw-r--r-- 1 root root   86 Apr 26 18:27 99-k290-config.rules
-rw-r--r-- 1 root root 1157 Oct 11  2012 README

However, when the computer resume from sleep, keys are not restored. Am I missing something?

milgner commented 10 years ago

Good question :smile: I hadn't tested resuming from sleep and as I'm a udev-noob myself it is quite likely that I overlooked something and it's possible to have it re-run the command in that scenario.

Neamar commented 10 years ago

So plugging / unplugging works quite well,

Regarding suspend, i tried to sleep with udevadm monitor, no 'input' devices are logged, so i guess more work would be needed.

Sadly, according to http://lists.freedesktop.org/archives/systemd-devel/2013-December/015327.html:

udev rules are only executed when hw appears/disappears or "changes", but not on resume/suspend... sorry...

Maybe for now i'll stick to plugging / unplugging the device after resume ^^

milgner commented 10 years ago

Looks like the easiest way would be either via script in /etc/pm/sleep.d or via a systemd service on After=sleep.target (or suspend.target, I'm not sure).

Neamar commented 10 years ago

Okay, thank you. I'll give it a shot.

On Tue, Apr 29, 2014 at 7:35 PM, Marcus Ilgner notifications@github.comwrote:

Looks like the easiest way would be either via script in /etc/pm/sleep.dor via a systemd service on After=sleep.target (or suspend.target, I'm not sure).

— Reply to this email directly or view it on GitHubhttps://github.com/milgner/k290-fnkeyctl/issues/3#issuecomment-41707039 .

mariuszs commented 10 years ago

For resume from sleep #7 I use this script:

/usr/lib/systemd/system-sleep/k290-fnkeyctl.sh 90ea4d15f2a0cfa653b537e506e1ea54a5a66036

#!/bin/bash
case $1/$2 in
  post/*)
    /usr/local/sbin/k290_fnkeyctl
    ;;
esac

In Fedora 18+ /etc/pm/sleep.d is not invoked anymore.

For system without systemd, sleep.d script should work /etc/pm/sleep.d/20-k290.sh dc070bc74cb972d507ea461fd095dbc6ceb939df

#!/bin/bash

case "$1" in
    thaw|resume)
        /usr/local/sbin/k290_fnkeyctl > /dev/null
        ;;
    *) exit $NA
        ;;
esac
exit $?
Neamar commented 10 years ago

This worked! Thanks.