diff --git a/custom/keyboard-switch/default.nix b/custom/keyboard-switch/default.nix index 5b4c4cf..b88b52f 100644 --- a/custom/keyboard-switch/default.nix +++ b/custom/keyboard-switch/default.nix @@ -20,12 +20,12 @@ writeShellScriptBin "keyboard-switch" '' fi if [ "$var" = "disabled" ]; then - notify-send "Enabling keyboard..." \ "ON - Keyboard connected !"; + notify-send "Enabling keyboard..." \ "Keyboard connected !"; echo "enable keyboard..." xinput enable "${keyboard_name}" echo "enabled" > $fconfig elif [ "$var" = "enabled" ]; then - notify-send "Disabling Keyboard" \ "OFF - Keyboard disconnected"; + notify-send "Disabling Keyboard" \ "Keyboard disconnected"; echo "disable keyboard" xinput disable "${keyboard_name}" echo 'disabled' > $fconfig diff --git a/hm_modules/polybar.nix b/hm_modules/polybar.nix index e1d5643..39021a4 100644 --- a/hm_modules/polybar.nix +++ b/hm_modules/polybar.nix @@ -18,6 +18,14 @@ let PATH=$PATH:"${lib.makeBinPath [ pkgs.dbus ]}" ${dunstctl} set-paused toggle ''; + keyboardStatus = pkgs.writeShellScript "keyboardStatus" '' + PATH=$PATH:"${lib.makeBinPath [ pkgs.coreutils ]}" + if [[ `cat ~/.local/share/keyboard-switch.state` == "disabled" ]]; then echo 󰌐; else echo 󰌌; fi + ''; + keyboardToggle = pkgs.writeShellScript "keyboardToggle" '' + PATH=$PATH:"${lib.makeBinPath [ pkgs.keyboard-switch ]}" + keyboard-switch + ''; notificationHistory = pkgs.writeShellScript "notificationToggle" '' PATH=$PATH:"${lib.makeBinPath [ pkgs.dbus ]}" ${dunstctl} set-paused false @@ -148,7 +156,7 @@ in modules-left = "bspwm"; # modules-center = modules-right = - "player pulseaudio temperature cpu memory battery notifications powermenu date"; + "player pulseaudio temperature cpu memory battery keyboard-switch notifications powermenu date"; tray = { position = "right"; padding = 1; @@ -159,7 +167,7 @@ in modules-left = "bspwm"; # modules-center = modules-right = - "player pulseaudio temperature cpu memory battery notifications powermenu date"; + "player pulseaudio temperature cpu memory battery keyboard-switch notifications powermenu date"; }; "module/battery" = { @@ -359,7 +367,14 @@ in interval = 0.5; # tail = 1; }; - + "module/keyboard-switch" = { + type = "custom/script"; + format = recursiveUpdate colors.normal { padding = 0; }; + exec = "${keyboardStatus}"; + click.left = "${keyboardToggle}"; + interval = 1; + # tail = 1; + }; "module/player" = { type = "custom/script"; format = colors.normal;