From 4e688c7c83647e3d0f385be05e624a016680ff2c Mon Sep 17 00:00:00 2001 From: Nikolai Papin Date: Sun, 5 Oct 2025 15:29:30 +0300 Subject: [PATCH] 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; --- hypr/conditions/autofreeze_swww | 1 + hypr/conditions/lock_wallpaper | 1 + hypr/grayscale.conf | 6 ++-- hypr/hyprland.conf | 39 ++++++++++++++++++------- hypr/hyprpaper.conf | 4 --- hypr/monitors.conf | 6 ++-- hypr/scripts/autofreeze_swww.sh | 50 ++++++++++++++++++++++++++++++++ hypr/scripts/cpufreq.sh | 15 +++++++--- hypr/scripts/freeze_swww.sh | 43 +++++++++++++++++++++++++++ hypr/scripts/gamemode.sh | 2 -- hypr/scripts/power_profile.sh | 34 ++++++++++++++++++++++ hypr/scripts/random_wallpaper.sh | 47 +++++------------------------- 12 files changed, 182 insertions(+), 66 deletions(-) create mode 100644 hypr/conditions/autofreeze_swww create mode 100644 hypr/conditions/lock_wallpaper delete mode 100644 hypr/hyprpaper.conf create mode 100755 hypr/scripts/autofreeze_swww.sh create mode 100755 hypr/scripts/freeze_swww.sh create mode 100755 hypr/scripts/power_profile.sh diff --git a/hypr/conditions/autofreeze_swww b/hypr/conditions/autofreeze_swww new file mode 100644 index 0000000..573541a --- /dev/null +++ b/hypr/conditions/autofreeze_swww @@ -0,0 +1 @@ +0 diff --git a/hypr/conditions/lock_wallpaper b/hypr/conditions/lock_wallpaper new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/hypr/conditions/lock_wallpaper @@ -0,0 +1 @@ +1 diff --git a/hypr/grayscale.conf b/hypr/grayscale.conf index 0abd837..358737b 100644 --- a/hypr/grayscale.conf +++ b/hypr/grayscale.conf @@ -1,3 +1,3 @@ -decoration { -screen_shader = ~/.config/hypr/grayscale.glsl -} +# decoration { +# screen_shader = ~/.config/hypr/grayscale.glsl +# } diff --git a/hypr/hyprland.conf b/hypr/hyprland.conf index 93ecefd..6a641ee 100644 --- a/hypr/hyprland.conf +++ b/hypr/hyprland.conf @@ -28,7 +28,9 @@ $privateBrowser = env GTK_THEME=Adwaita:light zen-browser --private-window # Or execute your favorite apps at launch like this: # Le essential hyprland crap -exec-once = hyprpaper +# exec-once = hyprpaper +exec-once = swww-daemon +exec-once = ~/.config/hypr/scripts/autofreeze_swww.sh exec-once = waybar & hypridle & hyprsunset & exec-once = mullvad-vpn exec-once = swaync @@ -128,8 +130,8 @@ decoration { # https://wiki.hyprland.org/Configuring/Variables/#blur blur { enabled = true - size = 5 - passes = 2 + size = 1 + passes = 4 ignore_opacity = true new_optimizations = true @@ -259,7 +261,9 @@ input { # kb_variant = ,qwerty # kb_model = # kb_rules = - + repeat_rate = 25 + repeat_delay = 200 + follow_mouse = 0 # 2 float_switch_override_focus = 0 @@ -279,6 +283,7 @@ input { # https://wiki.hyprland.org/Configuring/Variables/#gestures gestures { gesture = 3, horizontal, scale: 2, workspace + workspace_swipe_forever = true } # Example per-device config @@ -300,6 +305,9 @@ $mainMod = SUPER # Sets "Windows" key as main modifier bind = $mainMod ALT, Q, exit, bind = $mainMod SHIFT, delete, exec, shutdown now +# Menu dropdown +bind = $mainMod, P, sendshortcut, , Menu, activewindow + # Open programs bind = $mainMod, Return, exec, $terminal bind = $mainMod, E, exec, $fileManager @@ -307,7 +315,7 @@ bind = $mainMod, Q, exec, $browser bind = $mainMod SHIFT, Q, exec, $privateBrowser bind = $mainMod, Backslash, exec, $fastTerminal bind = $mainMod, Space, exec, $menu -bind = $mainMod, N, exec, swaync-client -t -sw || notify-send "Error SwayNC is down" +bind = $mainMod, N, exec, swaync-client -t -sw || notify-send --hint int:transient:1 "Error SwayNC is down" # Open floating terminal bind = $mainMod SHIFT, Return, exec, [float; size 800 600; move center] $fastTerminal --class kitty-float @@ -341,7 +349,6 @@ bind = $mainMod SHIFT, S, setfloating, bind = $mainMod SHIFT, S, resizeactive, exact 800 600 bind = $mainMod SHIFT, S, centerwindow, -bind = $mainMod, P, pseudo, # dwindle bind = $mainMod, D, togglesplit, # dwindle # Screenshots @@ -468,8 +475,9 @@ bind = $mainMod CTRL ALT, Right, movewindoworgroup, r # Laptop multimedia keys for volume and LCD brightness bindel = ,XF86AudioRaiseVolume, exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+ bindel = ,XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- -bindel = ,XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle -bindel = ,XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle +# bindl = ,XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle +bindl = ,XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle +bindl = ,XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle bindel = ,XF86MonBrightnessUp, exec, brightnessctl -e4 -n2 set 5%+ bindel = ,XF86MonBrightnessDown, exec, brightnessctl -e4 -n2 set 5%- @@ -494,6 +502,9 @@ bind = $mainMod, B, exec, ~/.config/hypr/scripts/reserved_space.sh # Cycle cpu frequency mode bind = $mainMod CTRL, C, exec, ~/.config/hypr/scripts/cpufreq.sh +# Cycle power mode +bind = $mainMod CTRL, V, exec, ~/.config/hypr/scripts/power_profile.sh + # Pin window bind = $mainMod CTRL, Y, pin, active @@ -526,6 +537,10 @@ windowrule = bordercolor rgba(ffff00ff) rgba(ffff0055),tag:voicechatuz # Zen - focus searchbar bindrn = CTRL, Space, sendshortcut, , F6, class:^(zen)$ +# OBS +bindrn = $mainMod CTRL, bracketleft, pass, class:^(com.obsproject.Studio)$ +bindrn = $mainMod CTRL, bracketright, pass, class:^(com.obsproject.Studio)$ + bind = , XF86PowerOff, exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 35% & ristretto -f ~/Templates/Images/theorist.jpg & play ~/Templates/Sounds/scream.mp3 # Disable binds temporarily @@ -553,15 +568,17 @@ windowrule = float,class:^(zenity)$ windowrule = workspace 7 silent,class:^(superProductivity)$ # Telegram -windowrule = workspace 8 silent,class:^(TelegramDesktop)$ -windowrule = group override set always,class:^(TelegramDesktop)$ windowrule = workspace 8 silent,class:^(org.telegram.desktop)$ -windowrule = group override set always,class:^(org.telegram.desktop)$ +windowrule = group set,class:^(org.telegram.desktop)$ # Vesktop windowrule = workspace 8 silent,class:^(vesktop)$ windowrule = group override set always,class:^(vesktop)$ +# Element +windowrule = workspace 8 silent,class:^(Element)$ +windowrule = group override set always,class:^(Element)$ + # Nextcloud windowrule = float,animation slide top,resize 800 600,move center,class:^(com.nextcloud.desktopclient.nextcloud)$ diff --git a/hypr/hyprpaper.conf b/hypr/hyprpaper.conf deleted file mode 100644 index 2410040..0000000 --- a/hypr/hyprpaper.conf +++ /dev/null @@ -1,4 +0,0 @@ - -wallpaper = eDP-1,/home/greg/Pictures/Wallpapers/oneshot_boat_centered.png -wallpaper = HDMI-A-1,/home/greg/Pictures/Wallpapers/oneshot_boat_centered.png -ipc = on diff --git a/hypr/monitors.conf b/hypr/monitors.conf index 9628e75..da082a9 100644 --- a/hypr/monitors.conf +++ b/hypr/monitors.conf @@ -1,4 +1,4 @@ -# Generated by nwg-displays on 2025-09-20 at 10:12:32. Do not edit manually. +monitor=eDP-1, 1920x1080, 0x0, 1 +monitor=HDMI-A-1, 1920x1080, -1920x-100, 1 -monitor=eDP-1,1920x1080@60.01,2560x0,1.0 -monitor=HDMI-A-1,3840x2160@30.0,0x0,1.5 +# monitor=HDMI-A-1, 1920x1080, -1920x-100, 1, mirror, eDP-1 diff --git a/hypr/scripts/autofreeze_swww.sh b/hypr/scripts/autofreeze_swww.sh new file mode 100755 index 0000000..1649378 --- /dev/null +++ b/hypr/scripts/autofreeze_swww.sh @@ -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 + diff --git a/hypr/scripts/cpufreq.sh b/hypr/scripts/cpufreq.sh index 9ec98bb..48803f4 100755 --- a/hypr/scripts/cpufreq.sh +++ b/hypr/scripts/cpufreq.sh @@ -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 diff --git a/hypr/scripts/freeze_swww.sh b/hypr/scripts/freeze_swww.sh new file mode 100755 index 0000000..19fa900 --- /dev/null +++ b/hypr/scripts/freeze_swww.sh @@ -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 diff --git a/hypr/scripts/gamemode.sh b/hypr/scripts/gamemode.sh index 994ddcc..2ea0e4d 100755 --- a/hypr/scripts/gamemode.sh +++ b/hypr/scripts/gamemode.sh @@ -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 diff --git a/hypr/scripts/power_profile.sh b/hypr/scripts/power_profile.sh new file mode 100755 index 0000000..ea36358 --- /dev/null +++ b/hypr/scripts/power_profile.sh @@ -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 diff --git a/hypr/scripts/random_wallpaper.sh b/hypr/scripts/random_wallpaper.sh index bf69793..4b71636 100755 --- a/hypr/scripts/random_wallpaper.sh +++ b/hypr/scripts/random_wallpaper.sh @@ -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 }