moved hypr scripts

This commit is contained in:
2026-10-02 02:06:46 +02:00
parent 37fb63549e
commit f338147907
22 changed files with 610 additions and 5 deletions

66
modules/desktop/scripts/bg.fish Executable file
View File

@@ -0,0 +1,66 @@
#!/usr/bin/env fish
# This script randomly switches the background (through fehbg) every 5 to 30 minutes.
# It selects a random image from the ~/Pictures/Wallpapers folder (including subdirectories)
# Any hidden files in this folder are excluded.
# in-place awk script
set awkcommand '
BEGIN {
FS=", "
width=1920
height=1080
}
NR == 1 {
x = $1
y = $2
if (x < 0) {
x = width + x
}
if (y < 0) {
y = height + y
}
print x "," y
}
'
# kill old instances
for i in (ps -C (basename (status filename)) | awk 'FNR>1 {print $1}')
if test $i -ne $fish_pid
kill $i
end
end
# set bg
swaybg -i $(find ~/Pictures/wallpapers -type f -regextype posix-extended -iregex "/(.*/)*[^\.]*\.(png|jpe?g|webp|gif)" | sort -R | head -n1)
while true
set rand (math "(floor $(random 300 1800) / 60) * 60")
# countdown
while test $rand -gt 0
set minutes (math "floor $rand / 60 ")
printf '\r\033[K%.2d:00' $minutes
sleep 60
set rand (math $rand - 60 )
end
# update wallpaper
swaybg -i $(find ~/Pictures/wallpapers -type f -regextype posix-extended -iregex "/(.*/)*[^\.]*\.(png|jpe?g|webp|gif)" | sort -R | head -n1)
set newpid $last_pid
sleep 0.2
for pid in (pgrep -x swaybg)
if test $pid -ne $last_pid
kill $pid
end
end
end

View File

@@ -0,0 +1,15 @@
#!/usr/bin/env sh
HYPRGAMEMODE=$(hyprctl getoption animations:enabled | awk 'NR==1{print $2}')
GAMING_PROFILE="GAMEINK"
if [ "$HYPRGAMEMODE" = "true" ] ; then
hyprctl eval 'hl.config({ animations = { enabled = false }, decoration = { blur = { enabled = false}, rounding = 0, shadow = { enabled = false }, fullscreen_opacity = 1}, general = { border_size = 1, gaps_in = 0, gaps_out = 0}})'
tailor profile set "$GAMING_PROFILE"
dunstify -r 55421 -t 2000 -u low -i ~/.icons/candy-icons/apps/scalable/teamspeak.svg "Gamemode on"
exit
else
dunstify -r 55421 -t 2000 -u low -i ~/.icons/candy-icons/apps/scalable/teamspeak.svg "Gamemode off"
hyprctl reload
exit 0
fi

View File

@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Toggles the GAMING_PROFILE tuxedo power profile
GAMEMODE=$(tailor profile list | grep active | cut --fields 1 -d' ')
GAMING_PROFILE="GAMEINK"
DEFAULT_PROFILE="HOTHOTHOT"
function failure() {
dunstify -r 55422 -t 4000 -u normal -i ~/.icons/candy-icons/apps/scalable/teamspeak.svg "Failed to toggle power profile!"
exit 1
}
if [[ "$GAMEMODE" =~ "GAMEINK" ]] ; then
# Default profile
tailor profile set "$DEFAULT_PROFILE" || failure
dunstify -r 55422 -t 2000 -u low -i ~/.icons/candy-icons/apps/scalable/teamspeak.svg "Gaming power profile deactivated"
exit 0
else
# gaming profile
tailor profile set "$GAMING_PROFILE" || failure
dunstify -r 55422 -t 2000 -u low -i ~/.icons/candy-icons/apps/scalable/teamspeak.svg "Gaming power profile activated"
hyprctl reload
exit 0
fi

View File

@@ -0,0 +1,75 @@
#!/usr/bin/env bash
# This script visualizes all keybindings in the hyprland config.
# It also executes the associated command, if a keybinding is selected.
# It uses an Awk script, column -t, and rofi-dmenu to do so.
# Furthermore, rofi-dmenu expects the file ~/.config/rofi/keybinds.rasi to exist for theming.
# Awk script used for parsing `hyprctl binds`
# Basically:
# $1 contains submap; if empty replace with Default; also replaces shutdown mode.
# $2 contains modmap; parsed and replaced with human-readable modifiers
# $3 contains key
# $4 contains description
awkcommand='
BEGIN {
FS="\t"
}
{
# submap
if ($1 == "") {
submap = "Default"
} else {
submap = $1
if (submap == "l e s h r ^s") {
submap = "Shutdown"
}
}
# modmap parse
modmap = $2
mods = "1"
if (modmap >= 64) {
mods = gensub(/1/, " 1", 1, mods)
modmap = modmap - 64
}
if (modmap >= 8) {
mods = gensub(/1/, "Alt 1", 1, mods)
modmap = modmap - 8
}
if (modmap >= 4) {
mods = gensub(/1/, "Ctrl 1", 1, mods)
modmap = modmap - 4
}
if (modmap >= 1) {
mods = gensub(/1/, "Shift 1", 1, mods)
modmap = modmap - 1
}
mods = gensub(/1/, "", 1, mods)
# output
printf "%s,%s%s,%s\n", submap, mods, $3, $4
}
'
# get binds
binds=$(hyprctl binds -j | jq -r '.[] | select(.description != "") | [.submap, .modmask, .key, .description, .dispatcher, .arg] | @tsv')
idx=$(printf "%s" "$binds" | awk -F'\t' "$awkcommand" | column -ts',' | rofi -i -dmenu -p "Keybinds" -config ~/.config/rofi/keybinds.rasi -format d)
exit
# This is permanently borked i think.
# Since hyprland0.55 (the lua update), hyprctl binds no longer provides the actual command
# Instead, a pointer to a lua fragment is printed instead, which we can't do anything with.
# exit if user does not make a selection.
if [[ $idx -eq 0 ]]; then
printf "No command selected.\nExiting..\n"
exit
fi
# get line
cmdline=$(printf "%s" "$binds" | awk -F'\t' "NR == $idx {printf \"%s %s\", \$5, \$6}")
# run hyprctl dispatch $5 $6 (< 5,6 of line not shell script)
hyprctl eval $cmdline

View File

@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# This script allows the user to make a screenshot (through slurp)
# and will then open said screenshot from the clipboard into feh
# it will also make the feh window floating, and move it to the original position of the selection
slop=$(slurp -f "%x,%y %wx%h" || exit 1)
# If the capture was cancelled, out will be empty
if [[ -n "$slop" ]]; then
# get x,y of selection
coords=$(echo "$slop" | awk -F' ' '{print $1}')
x=$(echo "$coords" | awk -F',' '{print $1}')
y=$(echo "$coords" | awk -F',' '{print $2}')
grim -g "$slop" - | wl-copy
grim -g "$slop" - | feh - -T notitle --class 'floatme' &
pid="$!"
while [[ -z $(wmctrl -lp | awk -vpid=$pid '$3==pid {print $1; exit}') ]]; do
sleep 0.05
done
hyprctl dispatch "hl.dsp.window.move({ x = \"$x\", y = \"$y\", relative = false})"
fi

View File

@@ -0,0 +1,43 @@
#!/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"

View File

@@ -0,0 +1,44 @@
#!/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/windowShaders/"
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,l -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 dispatch 'hl.dsp.window.clear_tags()'
hyprctl reload
dunst "Reset shader"
exit
fi
name=$(printf "%s" "$shaders" | awk -F',' "NR == $idx {printf \"%s\n\", \$1}")
hyprctl dispatch "hl.dsp.window.tag({ tag = 'shader/$name'})"
dunst "Applied shader $file"

View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
# toggles focus between floating and tiled windows.
# get floating state of active window
floating=$(hyprctl activewindow -j | jq ".floating")
if [ "$floating" = "true" ]; then
# focus tiled
hyprctl dispatch "hl.dsp.window.cycle_next({ tiled = true })"
else
# focus floating
hyprctl dispatch "hl.dsp.window.cycle_next({ floating = true })"
fi

View File

@@ -0,0 +1,28 @@
#!/usr/bin/env bash
touchpad="uniw0001:00-093a:0255-touchpad"
statFile="/tmp/tpEnabled"
if [ ! -f "$statFile" ]; then
echo "false" > "$statFile"
fi
current=$(cat "$statFile")
if [[ "$current" = "true" ]]; then
newState="false"
msg="disabled"
else
newState="true"
msg="enabled"
fi
hyprctl eval "hl.device({ name = \"$touchpad\", enabled = $newState})"
echo "$newState" > "$statFile"
dunstify -u low \
-a Touchpad \
-i ~/.icons/candy-icons/apps/scalable/cs-desktop.svg \
-r 365 \
-t 1000 \
"Touchpad $msg"

View File

@@ -0,0 +1,16 @@
#!/usr/bin/env nix-shell
#! nix-shell -i bash --packages killall envsubst waybar
#kill old instance
kill $(ps aux | grep '[w]aybar -c /tmp/waybar-config' | awk -F' ' '{print $2}')
while pgrep -u $UID -x waybar > /dev/null; do
sleep 1;
killall -q waybar
kill $(ps aux | grep '[w]aybar -c /tmp/waybar-config' | awk -F' ' '{print $2}')
done
IFS=$'\t\n'
MONITOR=$(hyprctl monitors -j | jq -r '.[] | select(.x==0 and .y==0) | .name') envsubst < ~/.config/waybar/config > /tmp/waybar-config
unset IFS
waybar -c /tmp/waybar-config &