From 2443f479e3f9efa3d3d0a464ebcf25723e0210a4 Mon Sep 17 00:00:00 2001 From: Sravan Balaji Date: Sun, 26 Mar 2023 20:26:50 -0400 Subject: [PATCH] Naughty Control Script + Rofi Menu - Replace deadd with naughty script --- .config/awesome | 2 +- .config/betterlockscreenrc | 4 +- .scripts/control-center.sh | 6 +-- .scripts/game_exit.sh | 2 +- .scripts/game_launch.sh | 2 +- .scripts/naughty.sh | 68 +++++++++++++++++++++++++++++ .scripts/startup.sh | 2 - README.org | 89 ++++++++++++++++++++++++++++++++++---- 8 files changed, 156 insertions(+), 19 deletions(-) create mode 100755 .scripts/naughty.sh diff --git a/.config/awesome b/.config/awesome index 3630ca4..a136c17 160000 --- a/.config/awesome +++ b/.config/awesome @@ -1 +1 @@ -Subproject commit 3630ca4c1a2c5b3b701bf89d58d3a8a8d3aa6e22 +Subproject commit a136c17a51a97271d60adc884cf60a65ee2dc56f diff --git a/.config/betterlockscreenrc b/.config/betterlockscreenrc index 5a9d993..f418ebe 100644 --- a/.config/betterlockscreenrc +++ b/.config/betterlockscreenrc @@ -32,10 +32,10 @@ modifcolor=ff5555ff bgcolor=282a36ff prelock() { - # /home/sravan/.scripts/deadd.sh --pause + /home/sravan/.scripts/naughty.sh --pause } # custom postlock postlock() { - # /home/sravan/.scripts/deadd.sh --unpause + /home/sravan/.scripts/naughty.sh --unpause } diff --git a/.scripts/control-center.sh b/.scripts/control-center.sh index 059546d..bd887f9 100755 --- a/.scripts/control-center.sh +++ b/.scripts/control-center.sh @@ -13,7 +13,7 @@ rofi_menu() { declare -a options=( " Compositor - picom" " Display - brightness" - " Notifications - deadd" + " Notifications - naughty" " Media - playerctl" "墳Volume - pactl" " Backup - backup" @@ -50,8 +50,8 @@ main() { --brightness) /home/sravan/.scripts/brightness.sh --rofi ;; - --deadd) - /home/sravan/.scripts/deadd.sh --rofi + --naughty) + /home/sravan/.scripts/naughty.sh --rofi ;; --playerctl) /home/sravan/.scripts/playerctl.sh --rofi diff --git a/.scripts/game_exit.sh b/.scripts/game_exit.sh index 7d3f338..910af81 100755 --- a/.scripts/game_exit.sh +++ b/.scripts/game_exit.sh @@ -1,4 +1,4 @@ #!/bin/bash -# /home/sravan/.scripts/deadd.sh --unpause +/home/sravan/.scripts/naughty.sh --unpause /home/sravan/.scripts/cpu-gpu.sh --gpu-profile-adaptive /usr/bin/xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -s false diff --git a/.scripts/game_launch.sh b/.scripts/game_launch.sh index 882ad1a..6c7ac1b 100755 --- a/.scripts/game_launch.sh +++ b/.scripts/game_launch.sh @@ -1,5 +1,5 @@ #!/bin/bash /home/sravan/.scripts/picom.sh --off /home/sravan/.scripts/cpu-gpu.sh --gpu-profile-performance -# /home/sravan/.scripts/deadd.sh --pause +/home/sravan/.scripts/naughty.sh --pause /usr/bin/xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -s true diff --git a/.scripts/naughty.sh b/.scripts/naughty.sh new file mode 100755 index 0000000..2bd4f34 --- /dev/null +++ b/.scripts/naughty.sh @@ -0,0 +1,68 @@ +#!/bin/bash +help_menu() { + echo "Script to interact with AwesomeWM's naughty. Use only one argument at a time." + echo " - Toggle Pause/Unpause: naughty.sh OR naughty.sh --toggle OR naughty.sh -t" + echo " - Pause Popup Notifications: naughty.sh --pause" + echo " - Unpause Popup Notifications: naughty.sh --unpause" + echo " - Rofi Menu: naughty.sh --rofi" + echo " - Help: naughty.sh --help OR naughty.sh -h" +} + +rofi_menu() { + declare -a options=( + "⏼ Toggle - toggle" + " Pause Popup Notifications - pause" + " Unpause Popup Notifications - unpause" + " Back - back" + " Quit - quit" + ) + + choice=$(printf '%s\n' "${options[@]}" | rofi -dmenu -i) + option=$(printf '%s\n' "${choice}" | awk '{print $NF}') + + if [[ "$option" == "quit" ]]; then + pkill rofi + elif [[ "$option" != "back" ]]; then + main "--$option" && main "--rofi" + fi +} + +main() { + if [ $# -eq 0 ]; then + # No arguments + help_menu + else + case $1 in + --help | -h) + help_menu + ;; + --toggle) + /usr/bin/awesome-client ' + local naughty = require("naughty") + naughty.toggle() + ' + ;; + --pause) + notify-send "Pausing Notifications" + + /usr/bin/awesome-client ' + local naughty = require("naughty") + naughty.suspend() + ' + ;; + --unpause) + /usr/bin/awesome-client ' + local naughty = require("naughty") + naughty.resume() + ' + + notify-send "Unpausing Notifications" + ;; + --rofi) + rofi_menu + ;; + esac + fi +} + +main $@ diff --git a/.scripts/startup.sh b/.scripts/startup.sh index 208a555..91d0e07 100755 --- a/.scripts/startup.sh +++ b/.scripts/startup.sh @@ -1,7 +1,6 @@ #!/bin/bash declare -a startup_array=(\ # Background Processes - # "bash /home/sravan/.scripts/deadd.sh --on" \ # Deadd Notification Center "bash /home/sravan/.scripts/picom.sh --on" \ # Picom Compositor "/usr/bin/greenclip daemon" \ # Greenclip Clipboard Manager "/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1" \ # GNOME Polkit Authentication Agent @@ -12,7 +11,6 @@ declare -a startup_array=(\ declare -a kill_startup_array=(\ # Background Processes - # "pkill deadd-notificat" \ # Deadd Notification Center "pkill picom" \ # Picom Compositor "pkill greenclip" \ # Greenclip Clipboard Manager "pkill polkit" \ # GNOME Polkit Authentication Agent diff --git a/README.org b/README.org index 5e1ed30..88b92b4 100644 --- a/README.org +++ b/README.org @@ -27,6 +27,7 @@ - [[#configuration][Configuration]] - [[#styling][Styling]] - [[#control-script-1][Control Script]] + - [[#awesomewm-naughty][AwesomeWM Naughty]] - [[#application-launcher][Application Launcher]] - [[#rofi][Rofi]] - [[#configuration-1][Configuration]] @@ -1484,6 +1485,78 @@ main() { main $@ #+END_SRC +** AwesomeWM Naughty + +#+BEGIN_SRC shell :shebang #!/bin/bash :tangle .scripts/naughty.sh +help_menu() { + echo "Script to interact with AwesomeWM's naughty. Use only one argument at a time." + echo " - Toggle Pause/Unpause: naughty.sh OR naughty.sh --toggle OR naughty.sh -t" + echo " - Pause Popup Notifications: naughty.sh --pause" + echo " - Unpause Popup Notifications: naughty.sh --unpause" + echo " - Rofi Menu: naughty.sh --rofi" + echo " - Help: naughty.sh --help OR naughty.sh -h" +} + +rofi_menu() { + declare -a options=( + "⏼ Toggle - toggle" + " Pause Popup Notifications - pause" + " Unpause Popup Notifications - unpause" + " Back - back" + " Quit - quit" + ) + + choice=$(printf '%s\n' "${options[@]}" | rofi -dmenu -i) + option=$(printf '%s\n' "${choice}" | awk '{print $NF}') + + if [[ "$option" == "quit" ]]; then + pkill rofi + elif [[ "$option" != "back" ]]; then + main "--$option" && main "--rofi" + fi +} + +main() { + if [ $# -eq 0 ]; then + # No arguments + help_menu + else + case $1 in + --help | -h) + help_menu + ;; + --toggle) + /usr/bin/awesome-client ' + local naughty = require("naughty") + naughty.toggle() + ' + ;; + --pause) + notify-send "Pausing Notifications" + + /usr/bin/awesome-client ' + local naughty = require("naughty") + naughty.suspend() + ' + ;; + --unpause) + /usr/bin/awesome-client ' + local naughty = require("naughty") + naughty.resume() + ' + + notify-send "Unpausing Notifications" + ;; + --rofi) + rofi_menu + ;; + esac + fi +} + +main $@ +#+END_SRC + * Application Launcher ** Rofi @@ -3150,7 +3223,7 @@ bgcolor=282a36ff #+BEGIN_SRC conf :tangle .config/betterlockscreenrc prelock() { - # /home/sravan/.scripts/deadd.sh --pause + /home/sravan/.scripts/naughty.sh --pause } #+END_SRC @@ -3159,7 +3232,7 @@ prelock() { #+BEGIN_SRC conf :tangle .config/betterlockscreenrc # custom postlock postlock() { - # /home/sravan/.scripts/deadd.sh --unpause + /home/sravan/.scripts/naughty.sh --unpause } #+END_SRC @@ -7289,7 +7362,7 @@ These are scripts that should be run from Lutris when launching or exiting a gam #+BEGIN_SRC shell :shebang #!/bin/bash :tangle .scripts/game_launch.sh /home/sravan/.scripts/picom.sh --off /home/sravan/.scripts/cpu-gpu.sh --gpu-profile-performance -# /home/sravan/.scripts/deadd.sh --pause +/home/sravan/.scripts/naughty.sh --pause /usr/bin/xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -s true #+END_SRC @@ -7298,7 +7371,7 @@ These are scripts that should be run from Lutris when launching or exiting a gam *Preferences > System options > Post-exit script* #+BEGIN_SRC shell :shebang #!/bin/bash :tangle .scripts/game_exit.sh -# /home/sravan/.scripts/deadd.sh --unpause +/home/sravan/.scripts/naughty.sh --unpause /home/sravan/.scripts/cpu-gpu.sh --gpu-profile-adaptive /usr/bin/xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -s false #+END_SRC @@ -8104,7 +8177,6 @@ Xcursor.size: CURSOR_SIZE #+BEGIN_SRC shell :shebang #!/bin/bash :tangle .scripts/startup.sh declare -a startup_array=(\ # Background Processes - # "bash /home/sravan/.scripts/deadd.sh --on" \ # Deadd Notification Center "bash /home/sravan/.scripts/picom.sh --on" \ # Picom Compositor "/usr/bin/greenclip daemon" \ # Greenclip Clipboard Manager "/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1" \ # GNOME Polkit Authentication Agent @@ -8115,7 +8187,6 @@ declare -a startup_array=(\ declare -a kill_startup_array=(\ # Background Processes - # "pkill deadd-notificat" \ # Deadd Notification Center "pkill picom" \ # Picom Compositor "pkill greenclip" \ # Greenclip Clipboard Manager "pkill polkit" \ # GNOME Polkit Authentication Agent @@ -8785,7 +8856,7 @@ rofi_menu() { declare -a options=( " Compositor - picom" " Display - brightness" - " Notifications - deadd" + " Notifications - naughty" " Media - playerctl" "墳Volume - pactl" " Backup - backup" @@ -8822,8 +8893,8 @@ main() { --brightness) /home/sravan/.scripts/brightness.sh --rofi ;; - --deadd) - /home/sravan/.scripts/deadd.sh --rofi + --naughty) + /home/sravan/.scripts/naughty.sh --rofi ;; --playerctl) /home/sravan/.scripts/playerctl.sh --rofi