Make gammastep control script and restart gammastep on shikane profile change

This commit is contained in:
Sravan Balaji
2024-12-14 16:11:45 -05:00
parent 98d2d9bfb9
commit db694e5c86
5 changed files with 226 additions and 78 deletions

View File

@@ -3737,6 +3737,83 @@ adjustment-method=wayland
;screen=0
#+END_SRC
***** Control Script
#+BEGIN_SRC shell :shebang #!/usr/bin/env bash :tangle gammastep/.scripts/gammastep.sh
help_menu() {
echo "Script to interact with gammastep. Use only one argument at a time."
}
is_running() {
if pgrep -x gammastep >/dev/null; then
echo 1
else
echo 0
fi
}
rofi_menu() {
declare -a options=(
"⏼ Toggle - toggle"
"󱩌 Turn On - on"
"󱩍 Turn Off - off"
"󰌍 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)
if [ $(is_running) -eq '1' ]; then
main --off
else
main --on
fi
;;
--on)
if [ $(is_running) -eq '1' ]; then
pkill gammastep
fi
# Start Gammastep
/usr/bin/gammastep-indicator &
notify-send "Turning Gammastep ON" &
;;
--off)
notify-send "Turning Gammastep OFF" &
if [ $(is_running) -eq '1' ]; then
pkill gammastep
fi
;;
--rofi)
rofi_menu
;;
esac
fi
}
main $@
#+END_SRC
*** Lock Screen
**** Betterlockscreen
@@ -3808,7 +3885,10 @@ postlock() {
#+BEGIN_SRC toml :tangle shikane/.config/shikane/config.toml
[[profile]]
name = "docked"
exec = ["notify-send shikane \"Profile $SHIKANE_PROFILE_NAME has been applied\" &"]
exec = [
"notify-send shikane \"Profile $SHIKANE_PROFILE_NAME has been applied\" &",
"$HOME/.scripts/gammastep.sh --on"
]
[[profile.output]]
enable = false
@@ -3847,7 +3927,10 @@ adaptive_sync = false
#+BEGIN_SRC toml :tangle shikane/.config/shikane/config.toml
[[profile]]
name = "mobile"
exec = ["notify-send shikane \"Profile $SHIKANE_PROFILE_NAME has been applied\" &"]
exec = [
"notify-send shikane \"Profile $SHIKANE_PROFILE_NAME has been applied\" &",
"$HOME/.scripts/gammastep.sh --on"
]
[[profile.output]]
enable = true
@@ -8885,7 +8968,6 @@ declare -a startup_array=(\
"/usr/libexec/polkit-gnome-authentication-agent-1" \ # GNOME Polkit Authentication Agent
"/usr/bin/xss-lock -l -- betterlockscreen --lock" \ # Session Lock Utility
"/usr/lib/kdeconnectd --replace" \ # KDE Connect Daemon
"/usr/bin/gammastep -x" \ # Gammastep Night Light
"/usr/bin/unclutter" \ # Hide Mouse Cursor
"/usr/bin/easyeffects --gapplication-service" \ # Easy Effects PipeWire Plugins
)
@@ -8895,43 +8977,40 @@ declare -a kill_startup_array=(\
"pkill polkit" \ # GNOME Polkit Authentication Agent
"pkill xss-lock" \ # Session Lock Utility
"pkill kdeconnectd" \ # KDE Connect Daemon
"pkill gammastep" \ # Gammastep Night Light
"pkill unclutter" \ # Hide Mouse Cursor
"pkill easyeffects" \ # Easy Effects PipeWire Plugins
)
declare -a delay_array=(\
"/usr/bin/gammastep-indicator" \ # Gammastep Night Light
"/usr/bin/blueman-applet" \ # Blueman Bluetooth Manager
"/usr/bin/nm-applet" \ # Network Manager Applet
"/usr/bin/kdeconnect-indicator" \ # KDE Connect Indicator
"/usr/bin/flameshot" \ # Flameshot Screenshot Tool
"/usr/bin/xfce4-power-manager" \ # XFCE4 Power Manager
"/usr/bin/udiskie -a -n -s" \ # Udiskie
"/usr/bin/openrgb" \ # OpenRGB
"/usr/bin/syncthing-gtk" \ # Syncthing GTK
"/usr/bin/nextcloud" \ # NextCloud Client
"/usr/bin/nyrna" \ # Nyrna
"bash $HOME/.scripts/dunst.sh --on" \ # Dunst Notification Daemon
"bash $HOME/.scripts/picom.sh --on" \ # Picom Compositor
"/usr/bin/autorandr --change --force" \ # Auto restore screen layout
"/usr/bin/numlockx on" \ # Enable numlock
"/usr/bin/blueman-applet" \ # Blueman Bluetooth Manager
"/usr/bin/nm-applet" \ # Network Manager Applet
"/usr/bin/kdeconnect-indicator" \ # KDE Connect Indicator
"/usr/bin/flameshot" \ # Flameshot Screenshot Tool
"/usr/bin/xfce4-power-manager" \ # XFCE4 Power Manager
"/usr/bin/udiskie -a -n -s" \ # Udiskie
"/usr/bin/openrgb" \ # OpenRGB
"/usr/bin/syncthing-gtk" \ # Syncthing GTK
"/usr/bin/nextcloud" \ # NextCloud Client
"/usr/bin/nyrna" \ # Nyrna
"bash $HOME/.scripts/dunst.sh --on" \ # Dunst Notification Daemon
"bash $HOME/.scripts/picom.sh --on" \ # Picom Compositor
"/usr/bin/autorandr --change --force" \ # Auto restore screen layout
"/usr/bin/numlockx on" \ # Enable numlock
)
declare -a kill_delay_array=(\
"pkill gammastep-indic" \ # Gammastep Night Light
"pkill blueman-applet" \ # Blueman Bluetooth Manager
"pkill nm-applet" \ # Network Manager Applet
"pkill kdeconnect-indicator" \ # KDE Connect Indicator
"pkill flameshot" \ # Flameshot Screenshot Tool
"pkill xfce4-power-manager" \ # XFCE4 Power Manager
"pkill udiskie" \ # Udiskie
"pkill openrgb" \ # OpenRGB
"pkill syncthing-gtk" \ # Syncthing GTK
"pkill nextcloud" \ # NextCloud Client
"pkill nyrna" \ # Nyrna
"bash $HOME/.scripts/dunst.sh --off" \ # Dunst Notification Daemon
"bash $HOME/.scripts/picom.sh --off" \ # Picom Compositor
"pkill blueman-applet" \ # Blueman Bluetooth Manager
"pkill nm-applet" \ # Network Manager Applet
"pkill kdeconnect-indicator" \ # KDE Connect Indicator
"pkill flameshot" \ # Flameshot Screenshot Tool
"pkill xfce4-power-manager" \ # XFCE4 Power Manager
"pkill udiskie" \ # Udiskie
"pkill openrgb" \ # OpenRGB
"pkill syncthing-gtk" \ # Syncthing GTK
"pkill nextcloud" \ # NextCloud Client
"pkill nyrna" \ # Nyrna
"bash $HOME/.scripts/dunst.sh --off" \ # Dunst Notification Daemon
"bash $HOME/.scripts/picom.sh --off" \ # Picom Compositor
)
help_menu() {
@@ -9074,11 +9153,10 @@ declare -a startup_array=(\
"/usr/bin/hyprwall --restore" \ # Wallpaper
"/usr/bin/gammastep -x" \ # Reset gammastep night light
# Tray Applications
"/usr/bin/gammastep-indicator" \ # Gamamstep Night Light Indicator
"/usr/bin/blueman-applet" \ # Bluetooth Manager Applet
"/usr/bin/nm-applet" \ # Network Manager Applet
"/usr/bin/kdeconnect-indicator" \ # KDE Connect Indicator
"/usr/bin/udiskie -a -n -s" \ # Udiskie
"/usr/bin/blueman-applet" \ # Bluetooth Manager Applet
"/usr/bin/nm-applet" \ # Network Manager Applet
"/usr/bin/kdeconnect-indicator" \ # KDE Connect Indicator
"/usr/bin/udiskie -a -n -s" \ # Udiskie
# GUI Applications
"/usr/bin/nextcloud" \ # NextCloud Client
"/usr/bin/syncthing-gtk" \ # Syncthing GUI
@@ -9098,9 +9176,7 @@ declare -a kill_startup_array=(\
"pkill swhkd" \
# Display / Compositor Setup
"pkill shikane" \
"pkill gammastep" \
# Tray Applications
"pkill gammastep-indic" \
"pkill blueman-applet" \
"pkill nm-applet" \
"pkill kdeconnect-indi" \

View File

@@ -16,11 +16,10 @@ declare -a startup_array=(\
"/usr/bin/hyprwall --restore" \ # Wallpaper
"/usr/bin/gammastep -x" \ # Reset gammastep night light
# Tray Applications
"/usr/bin/gammastep-indicator" \ # Gamamstep Night Light Indicator
"/usr/bin/blueman-applet" \ # Bluetooth Manager Applet
"/usr/bin/nm-applet" \ # Network Manager Applet
"/usr/bin/kdeconnect-indicator" \ # KDE Connect Indicator
"/usr/bin/udiskie -a -n -s" \ # Udiskie
"/usr/bin/blueman-applet" \ # Bluetooth Manager Applet
"/usr/bin/nm-applet" \ # Network Manager Applet
"/usr/bin/kdeconnect-indicator" \ # KDE Connect Indicator
"/usr/bin/udiskie -a -n -s" \ # Udiskie
# GUI Applications
"/usr/bin/nextcloud" \ # NextCloud Client
"/usr/bin/syncthing-gtk" \ # Syncthing GUI
@@ -40,9 +39,7 @@ declare -a kill_startup_array=(\
"pkill swhkd" \
# Display / Compositor Setup
"pkill shikane" \
"pkill gammastep" \
# Tray Applications
"pkill gammastep-indic" \
"pkill blueman-applet" \
"pkill nm-applet" \
"pkill kdeconnect-indi" \

View File

@@ -4,7 +4,6 @@ declare -a startup_array=(\
"/usr/libexec/polkit-gnome-authentication-agent-1" \ # GNOME Polkit Authentication Agent
"/usr/bin/xss-lock -l -- betterlockscreen --lock" \ # Session Lock Utility
"/usr/lib/kdeconnectd --replace" \ # KDE Connect Daemon
"/usr/bin/gammastep -x" \ # Gammastep Night Light
"/usr/bin/unclutter" \ # Hide Mouse Cursor
"/usr/bin/easyeffects --gapplication-service" \ # Easy Effects PipeWire Plugins
)
@@ -14,43 +13,40 @@ declare -a kill_startup_array=(\
"pkill polkit" \ # GNOME Polkit Authentication Agent
"pkill xss-lock" \ # Session Lock Utility
"pkill kdeconnectd" \ # KDE Connect Daemon
"pkill gammastep" \ # Gammastep Night Light
"pkill unclutter" \ # Hide Mouse Cursor
"pkill easyeffects" \ # Easy Effects PipeWire Plugins
)
declare -a delay_array=(\
"/usr/bin/gammastep-indicator" \ # Gammastep Night Light
"/usr/bin/blueman-applet" \ # Blueman Bluetooth Manager
"/usr/bin/nm-applet" \ # Network Manager Applet
"/usr/bin/kdeconnect-indicator" \ # KDE Connect Indicator
"/usr/bin/flameshot" \ # Flameshot Screenshot Tool
"/usr/bin/xfce4-power-manager" \ # XFCE4 Power Manager
"/usr/bin/udiskie -a -n -s" \ # Udiskie
"/usr/bin/openrgb" \ # OpenRGB
"/usr/bin/syncthing-gtk" \ # Syncthing GTK
"/usr/bin/nextcloud" \ # NextCloud Client
"/usr/bin/nyrna" \ # Nyrna
"bash $HOME/.scripts/dunst.sh --on" \ # Dunst Notification Daemon
"bash $HOME/.scripts/picom.sh --on" \ # Picom Compositor
"/usr/bin/autorandr --change --force" \ # Auto restore screen layout
"/usr/bin/numlockx on" \ # Enable numlock
"/usr/bin/blueman-applet" \ # Blueman Bluetooth Manager
"/usr/bin/nm-applet" \ # Network Manager Applet
"/usr/bin/kdeconnect-indicator" \ # KDE Connect Indicator
"/usr/bin/flameshot" \ # Flameshot Screenshot Tool
"/usr/bin/xfce4-power-manager" \ # XFCE4 Power Manager
"/usr/bin/udiskie -a -n -s" \ # Udiskie
"/usr/bin/openrgb" \ # OpenRGB
"/usr/bin/syncthing-gtk" \ # Syncthing GTK
"/usr/bin/nextcloud" \ # NextCloud Client
"/usr/bin/nyrna" \ # Nyrna
"bash $HOME/.scripts/dunst.sh --on" \ # Dunst Notification Daemon
"bash $HOME/.scripts/picom.sh --on" \ # Picom Compositor
"/usr/bin/autorandr --change --force" \ # Auto restore screen layout
"/usr/bin/numlockx on" \ # Enable numlock
)
declare -a kill_delay_array=(\
"pkill gammastep-indic" \ # Gammastep Night Light
"pkill blueman-applet" \ # Blueman Bluetooth Manager
"pkill nm-applet" \ # Network Manager Applet
"pkill kdeconnect-indicator" \ # KDE Connect Indicator
"pkill flameshot" \ # Flameshot Screenshot Tool
"pkill xfce4-power-manager" \ # XFCE4 Power Manager
"pkill udiskie" \ # Udiskie
"pkill openrgb" \ # OpenRGB
"pkill syncthing-gtk" \ # Syncthing GTK
"pkill nextcloud" \ # NextCloud Client
"pkill nyrna" \ # Nyrna
"bash $HOME/.scripts/dunst.sh --off" \ # Dunst Notification Daemon
"bash $HOME/.scripts/picom.sh --off" \ # Picom Compositor
"pkill blueman-applet" \ # Blueman Bluetooth Manager
"pkill nm-applet" \ # Network Manager Applet
"pkill kdeconnect-indicator" \ # KDE Connect Indicator
"pkill flameshot" \ # Flameshot Screenshot Tool
"pkill xfce4-power-manager" \ # XFCE4 Power Manager
"pkill udiskie" \ # Udiskie
"pkill openrgb" \ # OpenRGB
"pkill syncthing-gtk" \ # Syncthing GTK
"pkill nextcloud" \ # NextCloud Client
"pkill nyrna" \ # Nyrna
"bash $HOME/.scripts/dunst.sh --off" \ # Dunst Notification Daemon
"bash $HOME/.scripts/picom.sh --off" \ # Picom Compositor
)
help_menu() {

73
gammastep/.scripts/gammastep.sh Executable file
View File

@@ -0,0 +1,73 @@
#!/usr/bin/env bash
help_menu() {
echo "Script to interact with gammastep. Use only one argument at a time."
}
is_running() {
if pgrep -x gammastep >/dev/null; then
echo 1
else
echo 0
fi
}
rofi_menu() {
declare -a options=(
"⏼ Toggle - toggle"
"󱩌 Turn On - on"
"󱩍 Turn Off - off"
"󰌍 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)
if [ $(is_running) -eq '1' ]; then
main --off
else
main --on
fi
;;
--on)
if [ $(is_running) -eq '1' ]; then
pkill gammastep
fi
# Start Gammastep
/usr/bin/gammastep-indicator &
notify-send "Turning Gammastep ON" &
;;
--off)
notify-send "Turning Gammastep OFF" &
if [ $(is_running) -eq '1' ]; then
pkill gammastep
fi
;;
--rofi)
rofi_menu
;;
esac
fi
}
main $@

View File

@@ -1,6 +1,9 @@
[[profile]]
name = "docked"
exec = ["notify-send shikane \"Profile $SHIKANE_PROFILE_NAME has been applied\" &"]
exec = [
"notify-send shikane \"Profile $SHIKANE_PROFILE_NAME has been applied\" &",
"$HOME/.scripts/gammastep.sh --on"
]
[[profile.output]]
enable = false
@@ -35,7 +38,10 @@ adaptive_sync = false
[[profile]]
name = "mobile"
exec = ["notify-send shikane \"Profile $SHIKANE_PROFILE_NAME has been applied\" &"]
exec = [
"notify-send shikane \"Profile $SHIKANE_PROFILE_NAME has been applied\" &",
"$HOME/.scripts/gammastep.sh --on"
]
[[profile.output]]
enable = true