WIP: rice
This commit is contained in:
parent
f842c92339
commit
1096479c4a
14 changed files with 81 additions and 32 deletions
40
pkgs/keyboard-switch/default.nix
Normal file
40
pkgs/keyboard-switch/default.nix
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
{ writeShellScriptBin
|
||||
, lib
|
||||
, xorg
|
||||
, libnotify
|
||||
, coreutils
|
||||
, keyboard_name ? "AT Translated Set 2 keyboard"
|
||||
,
|
||||
}:
|
||||
writeShellScriptBin "keyboard-switch" ''
|
||||
set -e
|
||||
|
||||
PATH=$PATH:"${
|
||||
lib.makeBinPath [
|
||||
coreutils
|
||||
xorg.xinput
|
||||
libnotify
|
||||
]
|
||||
}"
|
||||
fconfig="''${XDG_DATA_HOME:-$HOME/.local/share}/keyboard-switch.state"
|
||||
if [ ! -f $fconfig ]; then
|
||||
echo "Creating config file"
|
||||
mkdir -p `dirname $config_folder`
|
||||
echo "enabled" > $fconfig
|
||||
fi
|
||||
|
||||
read -r var< $fconfig
|
||||
echo "keyboard ${keyboard_name} is $var"
|
||||
|
||||
if [ "$var" = "disabled" ]; then
|
||||
notify-send "Enabling keyboard..." \ "Keyboard connected !";
|
||||
echo "enable keyboard..."
|
||||
xinput enable "${keyboard_name}"
|
||||
echo "enabled" > $fconfig
|
||||
elif [ "$var" = "enabled" ]; then
|
||||
notify-send "Disabling Keyboard" \ "Keyboard disconnected";
|
||||
echo "disable keyboard"
|
||||
xinput disable "${keyboard_name}"
|
||||
echo 'disabled' > $fconfig
|
||||
fi
|
||||
''
|
||||
Loading…
Add table
Add a link
Reference in a new issue