44 lines
1.2 KiB
Bash
Executable File
44 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# This script allows toggling the active screen_shader used in hyprland.
|
|
# It automatically discovers shader files in the $SHADERDIR folder.
|
|
# And uses rofi for a graphical gui-- this uses the shaders.rasi configuration file.
|
|
# (Also dunst for notifications.)
|
|
|
|
SHADERDIR="$HOME/.config/hypr/shaders/"
|
|
|
|
|
|
function dunst() {
|
|
dunstify \
|
|
-r 2137 \
|
|
-t 2000 \
|
|
-u low \
|
|
-i ~/.icons/candy-icons/apps/scalable/applets-screenshooter.svg \
|
|
"${1/.*/}"
|
|
}
|
|
|
|
|
|
shaders="reset,
|
|
$(find "$SHADERDIR" -type f -regextype posix-extended -iregex '.*(frag|vert|glsl)$' | awk -F'[./]' '{printf "%s,%s.%s\n", $(NF-1), $(NF-1), $NF}')"
|
|
|
|
idx=$(printf "%s" "$shaders" | awk -F',' '{print $1}' | rofi -i -dmenu -P Shaders -config ~/.config/rofi/shaders.rasi -format d)
|
|
|
|
|
|
# apply selected shader (if any)
|
|
if [[ $idx -eq 0 ]]; then
|
|
printf "No shader selected.\nExiting..\n"
|
|
exit
|
|
fi
|
|
|
|
if [[ $idx -eq 1 ]]; then
|
|
# selected reset, which is a special case
|
|
hyprctl reload
|
|
dunst "Reset shader"
|
|
exit
|
|
fi
|
|
|
|
file=$(printf "%s" "$shaders" | awk -F',' "NR == $idx {printf \"%s\n\", \$2}")
|
|
hyprctl dispatch "hl.config({ decoration = { screen_shader = '$SHADERDIR/$file'}})"
|
|
dunst "Applied shader $file"
|
|
|