From 5501aaaec93144782c99e6b64b413297f65c8193 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Sun, 11 Sep 2022 19:04:25 +0200 Subject: [PATCH] reworked desktopctl --- modules/desktop.nix | 5 ++- other/assets/desktopctl/lock-screen.svg | 57 ++++++++++++++++++++++++ other/assets/desktopctl/logout.svg | 59 +++++++++++++++++++++++++ other/assets/desktopctl/reboot.svg | 21 +++++++++ other/assets/desktopctl/shutdown.svg | 29 ++++++++++++ scripts/desktop/desktopctl.nix | 30 +++++++++++++ 6 files changed, 199 insertions(+), 2 deletions(-) create mode 100644 other/assets/desktopctl/lock-screen.svg create mode 100644 other/assets/desktopctl/logout.svg create mode 100644 other/assets/desktopctl/reboot.svg create mode 100644 other/assets/desktopctl/shutdown.svg create mode 100644 scripts/desktop/desktopctl.nix diff --git a/modules/desktop.nix b/modules/desktop.nix index 9873ba0..2f19908 100644 --- a/modules/desktop.nix +++ b/modules/desktop.nix @@ -3,7 +3,8 @@ let cfg = config.jade.desktop; window-screenshot = pkgs.writeShellScriptBin "window-screenshot.sh" (builtins.readFile ../scripts/desktop/window-screenshot.sh); - desktop-ctl = pkgs.writeShellScriptBin "desktop-ctl.sh" (builtins.readFile ../scripts/desktop/desktop-ctl.sh); + # desktop-ctl = pkgs.writeShellScriptBin "desktop-ctl.sh" (builtins.readFile ../scripts/desktop/desktop-ctl.sh); + desktop-ctl = import ../scripts/desktop/desktopctl.nix { pkgs = pkgs; }; em-record = pkgs.writeShellScriptBin "em-record.sh" (builtins.readFile ../scripts/desktop/macros/record.sh); em-play = pkgs.writeShellScriptBin "em-play.sh" (builtins.readFile ../scripts/desktop/macros/play.sh); em-play-loop = pkgs.writeShellScriptBin "em-play-loop.sh" (builtins.readFile ../scripts/desktop/macros/play-loop.sh); @@ -111,7 +112,7 @@ in with lib; { "${mod}+d" = "exec --no-startup-id rofi -show drun -theme ${../other/rofi-themes/applauncher.rasi}"; "${mod}+space" = "exec --no-startup-id -show window"; "${mod}+i" = "exec --no-startup-id rofimoji -f alchemical_symbols anatolian_hieroglyphs emojis braille_patterns box_drawing chess_symbols emoticons geometric_shapes gothic greek_extended math mathematical_alphanumeric_symbols mathematical_operators miscellaneous_symbols miscellaneous_mathematical_symbols-a miscellaneous_mathematical_symbols-b miscellaneous_symbols_and_arrows miscellaneous_symbols_and_pictographs miscellaneous_technical modi modifier_tone_letters musical_symbols nerd_font number_forms shorthand_format_controls specials variation_selectors vertical_forms -a copy"; - "${mod}+Shift+e" = "exec --no-startup-id desktop-ctl.sh"; + "${mod}+Shift+e" = "exec --no-startup-id rofi -show \"desktopctl\" -modes \"desktopctl:${desktop-ctl.outPath}/bin/desktopctl\" -theme ${../other/rofi-themes/applauncher.rasi}"; "${mod}+m" = "exec --no-startup-id menu-qalc"; # audio diff --git a/other/assets/desktopctl/lock-screen.svg b/other/assets/desktopctl/lock-screen.svg new file mode 100644 index 0000000..6a54078 --- /dev/null +++ b/other/assets/desktopctl/lock-screen.svg @@ -0,0 +1,57 @@ + + + + + + + + + + + + + diff --git a/other/assets/desktopctl/logout.svg b/other/assets/desktopctl/logout.svg new file mode 100644 index 0000000..2bc5f2e --- /dev/null +++ b/other/assets/desktopctl/logout.svg @@ -0,0 +1,59 @@ + + + + + + + + + + + + + diff --git a/other/assets/desktopctl/reboot.svg b/other/assets/desktopctl/reboot.svg new file mode 100644 index 0000000..e2ccb5c --- /dev/null +++ b/other/assets/desktopctl/reboot.svg @@ -0,0 +1,21 @@ + + + + + + + + + diff --git a/other/assets/desktopctl/shutdown.svg b/other/assets/desktopctl/shutdown.svg new file mode 100644 index 0000000..46a8632 --- /dev/null +++ b/other/assets/desktopctl/shutdown.svg @@ -0,0 +1,29 @@ + + + + + + + + + + diff --git a/scripts/desktop/desktopctl.nix b/scripts/desktop/desktopctl.nix new file mode 100644 index 0000000..e4fef11 --- /dev/null +++ b/scripts/desktop/desktopctl.nix @@ -0,0 +1,30 @@ +{ pkgs, ... }: +pkgs.writeShellScriptBin "desktopctl" '' +case $@ in + "Lock Screen") + nohup sh -c "i3lock-fancy" > /dev/null & + exit 0 + ;; + "Log Out") + pkill i3 + exit 0 + ;; + "Shut Down") + shutdown now + exit 0 + ;; + "Reboot") + systemctl reboot + exit 0 + ;; +esac + +echo -en "\0theme\x1flistview,inputbar,message{columns:4;lines:1;}\n" +echo -en "\0theme\x1fwindow{width:800px;location:north;y-offset:30px;}\n" +echo -en "\0theme\x1fmainbox{children:[listview,inputbar];}\n" +echo -en "\0theme\x1finputbar{margin:0;}\n" +echo -en "Lock Screen\0icon\x1f${../../other/assets/desktopctl/lock-screen.svg}\n" +echo -en "Log Out\0icon\x1f${../../other/assets/desktopctl/logout.svg}\n" +echo -en "Shut Down\0icon\x1f${../../other/assets/desktopctl/shutdown.svg}\n" +echo -en "Reboot\0icon\x1f${../../other/assets/desktopctl/reboot.svg}\n" +''