feat: autofreeze script for swww when window is selected + a toggle;

refactor: cpufreq does not save notifications anymore;
feat: 3GHz option for cpufreq;
feat: Script for controlling power profile + bind;
refactor: removed hyprpaper, replaced with swww;
refactor: no longer affecting border radius in gamemode;
fix: grayscale filter;
feat: toggle automatic wallpaper switching;
This commit is contained in:
2025-10-05 15:29:30 +03:00
parent edb6817582
commit 4e688c7c83
12 changed files with 182 additions and 66 deletions

50
hypr/scripts/autofreeze_swww.sh Executable file
View File

@@ -0,0 +1,50 @@
#!/usr/bin/env bash
# Variable to store the last focused window address
last_focused_window=""
current_window=""
# PID of the swww-daemon process
swww_pid=""
# Get the PID of the swww-daemon process
get_swww_pid() {
swww_pid=$(pgrep -f swww-daemon)
}
function handle {
if [[ ${1:0:14} == "activewindowv2" ]]; then
new_window="${1:16}"
# Update window tracking
last_focused_window="${current_window}"
current_window="${new_window}"
get_swww_pid
if [[ ! -n "$swww_pid" ]]; then
return 1
fi
# XXX: please review
if [[ $(cat "$HOME/.config/hypr/conditions/autofreeze_swww") -eq 0 ]]; then
kill -CONT "$swww_pid" 2>/dev/null
return 0
fi
# Process for unfreezing if there is no active window
if [[ $(hyprctl activeworkspace -j | jq '.id') = 9 ]] || [[ ! -n "$current_window" ]]; then
echo "Unfreezing swww-daemon (PID: $swww_pid)"
kill -CONT "$swww_pid" 2>/dev/null
else
echo "Freezing swww-daemon (PID: $swww_pid)"
kill -STOP "$swww_pid" 2>/dev/null
return 0
fi
fi
}
# Listen for events
socat - "UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" | while read -r line; do handle "$line"; done

View File

@@ -4,7 +4,7 @@ CURRENT=$(sudo cpupower frequency-info | grep 'current policy: frequency should
set_cmd() {
sudo cpupower frequency-set --max $1MHz
notify-send -t 800 "$1MHz CPU Power"
notify-send --hint int:transient:1 -t 800 "$1MHz CPU Power"
}
if [ -z "$1" ]; then
@@ -24,6 +24,11 @@ if [ -z "$1" ]; then
fi
if [ $CURRENT = "2.00GHz" ]; then
set_cmd 3000
exit 0
fi
if [ $CURRENT = "3.00GHz" ]; then
set_cmd 4200
exit 0
fi
@@ -39,7 +44,8 @@ else
"600.00MHz") echo 2 ;;
"1000.00MHz") echo 3 ;;
"2.00GHz") echo 4 ;;
"4.20GHz") echo 5 ;;
"3.00GHz") echo 5 ;;
"4.20GHz") echo 6 ;;
*) echo "Unknown frequency" ;;
esac
exit 0
@@ -49,10 +55,11 @@ else
2) set_cmd 600 ;;
3) set_cmd 1000 ;;
4) set_cmd 2000 ;;
5) set_cmd 4200 ;;
5) set_cmd 3000 ;;
6) set_cmd 4200 ;;
esac
exit 0
fi
notify-send CPU-Power Error: value is $CURRENT
notify-send --hint int:transient:1 CPU-Power Error: value is $CURRENT
exit 1

43
hypr/scripts/freeze_swww.sh Executable file
View File

@@ -0,0 +1,43 @@
#!/bin/bash
set_frozen() {
PID=$(pgrep -f swww-daemon)
if [ $? -ne 0 ]; then
return 1
fi
if [ $1 -eq 1 ]; then
kill -STOP $PID
elif [ $1 -eq 0 ]; then
kill -CONT $PID
else
echo "Error: $1 is not a valid freeze state"
return 1
fi
return $?
}
get_frozen() {
if pid=$(pgrep -f swww-daemon); then
if ps -o state= $pid | grep -q 'T'; then
echo "true"
else
echo "false"
fi
else
echo "false"
return 1
fi
}
if [ "$1" == "g" ]; then
get_frozen
exit $?
else
if [ "$(get_frozen)" == "true" ]; then
set_frozen 0 # Unfreeze
else
set_frozen 1 # Freeze
fi
fi

View File

@@ -5,8 +5,6 @@ if [ "$HYPRGAMEMODE" = 1 ] ; then
keyword animations:enabled 0;\
keyword decoration:shadow:enabled 0;\
keyword decoration:blur:enabled 0;\
keyword general:border_size 1;\
keyword decoration:rounding 0;\
keyword plugin:hyprfocus:fade_opacity 1"
exit
fi

34
hypr/scripts/power_profile.sh Executable file
View File

@@ -0,0 +1,34 @@
#!/bin/bash
notify-send --hint int:transient:1 -t 500 "powerprofilesctl" "Please, wait..."
CURRENT=$(powerprofilesctl get)
if [[ $? -ne 0 ]]; then
notify-send --hint int:transient:1 -t 1800 "powerprofilesctl" "Error: could not retrieve status"
exit 1
fi
case "$CURRENT" in
"power-saver")
powerprofilesctl set balanced
;;
"balanced")
powerprofilesctl set performance
;;
"performance")
powerprofilesctl set power-saver
;;
*)
echo "Error: '$CURRENT' is not a valid power mode"
exit 1
;;
esac
if [[ $? -ne 0 ]]; then
notify-send --hint int:transient:1 -t 800 "powerprofilesctl" "Error: failed to set power mode"
exit 1
else
notify-send --hint int:transient:1 -t 800 "powerprofilesctl" "Successfully changed to $(powerprofilesctl get)"
fi
exit 0

View File

@@ -4,28 +4,6 @@ WALLPAPER_DIR="$HOME/Pictures/Wallpapers/current/"
INTRO_DIR="$HOME/Pictures/Wallpapers/intro/"
DELAY=5m
intro() {
if [ -z "$(ls -A "$WALLPAPER_DIR")" ]; then
echo "Current wallpaper folder is empty, nothing to do"
sleep 1
exit 0
fi
WALLPAPER=$(find "$INTRO_DIR" -type l | shuf -n 1)
while true; do
if hyprctl hyprpaper reload ,"$WALLPAPER"; then
sleep 1.5
break
fi
sleep 0.1
done
}
random_wallpaper() {
# Check if folder is not empty
if [ -z "$(ls -A "$WALLPAPER_DIR")" ]; then
@@ -39,33 +17,24 @@ random_wallpaper() {
WALLPAPER=$(find "$WALLPAPER_DIR" -type l ! -name "$(basename "$CURRENT_WALL")" | shuf -n 1)
# Apply the selected wallpaper
hyprctl hyprpaper reload $1,"$WALLPAPER"
swww img -o $1 "$WALLPAPER"
if [ $? -ne 0 ]; then
echo "The previous command failed."
# Handle the error here
hyprpaper &
sleep 1
hyprctl hyprpaper reload ,"$WALLPAPER"
return 1
fi
echo "Set random wallpaper to $WALLPAPER"
sleep 5
echo "Set random wallpaper for $1 to $WALLPAPER"
}
loop() {
sleep 1
while true; do
hyprctl hyprpaper listactive
if [ $? == 0 ]; then
break
if [ ! $(cat $HOME/.config/hypr/conditions/lock_wallpaper) -eq 1 ]; then
random_wallpaper "eDP-1" &
sleep 1
random_wallpaper "HDMI-A-1" &
fi
sleep 1
done
while true; do
hyprctl hyprpaper unload all
# TODO: get monitors dynamically
random_wallpaper "eDP-1"
random_wallpaper "HDMI-A-1"
sleep "$DELAY"
done
}