Skip to content

Commit 064812b

Browse files
committed
feat: refine Hyprland autostart and helper scripts
- feat: add per-workspace show-desktop minimize/restore script. - feat: add Waybar toggle script with hidden config support and optional LM Studio refresh. - feat: improve hyprpaper wallpaper IPC with a fallback target and more robust success detection. - change: simplify example Hyprland configs by removing app-specific binds/rules and grouping optional extras. - feat: enable optional Hyprland autostart extras during setup when dependencies are available.
1 parent 9c2d9d9 commit 064812b

File tree

9 files changed

+201
-76
lines changed

9 files changed

+201
-76
lines changed

dotfiles/.config/hypr/scripts/Startup_check.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ processes=(
6060
"Telegram"
6161
"wasistlos"
6262
"hyprsunset"
63-
"gpu-screen-recorder"
6463
"conky"
6564
"fcitx5"
6665
"bluetoothd"

dotfiles/.config/hypr/scripts/change_wallpaper.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ fi
127127
pkill -f "hyprctl.*hyprpaper" 2>/dev/null
128128
sleep 0.1
129129

130+
# Set fallback wallpaper target first (empty monitor selector).
131+
# This follows current hyprpaper IPC docs and avoids "no target" on
132+
# dynamic outputs until monitor-specific assignments are applied.
133+
hyprctl hyprpaper wallpaper ", $WALLPAPER, cover" >/dev/null 2>&1 || true
134+
130135
# Set wallpaper on each monitor with retry logic
131136
# New hyprpaper 0.8.0 IPC format: 'monitor, path, fit_mode'
132137
# fit_mode is optional and defaults to 'cover' if omitted
@@ -137,7 +142,10 @@ for monitor in "${MONITORS[@]}"; do
137142

138143
while [ $retry_count -lt $max_retries ] && [ "$success" = false ]; do
139144
# New format requires spaces: monitor, path, fit_mode
140-
if hyprctl hyprpaper wallpaper "$monitor, $WALLPAPER, cover" &>/dev/null; then
145+
wallpaper_out="$(hyprctl hyprpaper wallpaper "$monitor, $WALLPAPER, cover" 2>&1 || true)"
146+
if [ -z "$wallpaper_out" ]; then
147+
success=true
148+
elif echo "$wallpaper_out" | grep -qiE "ok|applied|success"; then
141149
success=true
142150
else
143151
retry_count=$((retry_count + 1))
@@ -149,6 +157,7 @@ for monitor in "${MONITORS[@]}"; do
149157

150158
if [ "$success" = false ]; then
151159
echo "Error: Failed to set wallpaper on $monitor after $max_retries attempts" >&2
160+
[ -n "${wallpaper_out:-}" ] && echo "hyprpaper output: $wallpaper_out" >&2
152161
fi
153162
done
154163

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
3+
TMP_FILE="$XDG_RUNTIME_DIR/hyprland-show-desktop"
4+
5+
CURRENT_WORKSPACE=$(hyprctl monitors -j | jq -r '.[] | .activeWorkspace | .name' | head -n1)
6+
7+
if [ -s "$TMP_FILE-$CURRENT_WORKSPACE" ]; then
8+
# Restore windows
9+
CMDS=""
10+
readarray -t ADDRESS_ARRAY < <(grep -v '^$' "$TMP_FILE-$CURRENT_WORKSPACE")
11+
12+
for address in "${ADDRESS_ARRAY[@]}"
13+
do
14+
address=$(echo "$address" | tr -d '[:space:]')
15+
if [[ -n "$address" ]]; then
16+
CMDS+="dispatch movetoworkspacesilent name:$CURRENT_WORKSPACE,address:$address;"
17+
fi
18+
done
19+
20+
if [[ -n "$CMDS" ]]; then
21+
hyprctl --batch "$CMDS"
22+
fi
23+
24+
rm "$TMP_FILE-$CURRENT_WORKSPACE"
25+
else
26+
# Hide windows
27+
CMDS=""
28+
TMP_ADDRESS=""
29+
30+
# Get windows from current workspace, excluding special workspaces
31+
HIDDEN_WINDOWS=$(hyprctl clients -j | jq -r --arg CW "$CURRENT_WORKSPACE" '.[] | select(.workspace.name == $CW and (.workspace.name | startswith("special:") | not)) | .address')
32+
33+
if [[ -z "$HIDDEN_WINDOWS" ]]; then
34+
exit 0
35+
fi
36+
37+
while IFS= read -r address; do
38+
address=$(echo "$address" | tr -d '[:space:]')
39+
if [[ -n "$address" ]]; then
40+
TMP_ADDRESS+="$address"$'\n'
41+
CMDS+="dispatch movetoworkspacesilent special:desktop,address:$address;"
42+
fi
43+
done <<< "$HIDDEN_WINDOWS"
44+
45+
if [[ -n "$CMDS" ]]; then
46+
hyprctl --batch "$CMDS"
47+
echo -n "$TMP_ADDRESS" | sed -e '/^$/d' > "$TMP_FILE-$CURRENT_WORKSPACE"
48+
fi
49+
fi

dotfiles/.config/hypr/sources_example/app_variables.conf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,12 @@ $editor = hyprctl dispatch exec "code --ozone-platform=wayland --enable-features
1919
# $editor = nvim
2020
# $editor = cursor --ozone-platform=wayland --enable-features=UseOzonePlatform
2121

22-
# Voice/Communication app (example)
23-
# $voice = discord --enable-features=UseOzonePlatform --ozone-platform=wayland
24-
2522
$screenshot = hyprshot --mode
2623

2724
$cursor = rose-pine-hyprcursor
2825

2926
$colorPicker = hyprpicker --autocopy --format hex
3027

31-
$git = github-desktop
32-
3328
$calc = qalculate-gtk
3429

3530
# Default wallpaper (will be overridden by change_wallpaper.sh)

dotfiles/.config/hypr/sources_example/autostart.conf

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,47 @@ exec-once = systemctl --user start hyprpolkitagent &
33
exec-once = hyprctl keyword input:kb_numlock true && date "+%Y-%m-%d %H:%M:%S" > /tmp/numlock-set
44
exec-once = /usr/lib/polkit-kde-authentication-agent-1 &
55

6-
# Start Notifications Daemon
7-
exec-once = swaync
8-
9-
# Used for tray, network in the status bar (waybar)
10-
exec-once = nm-applet --indicator &
11-
126
# Static Wallpaper
137
exec-once = hyprpaper &
148
exec-once = $hyprscripts/change_wallpaper.sh &
159

16-
# Start Pyprland for Scratchpad-Terminal
17-
exec-once = pypr
18-
1910
# Persistent Clipboard
2011
exec-once = wl-clip-persist --clipboard regular &
2112
exec-once = wl-clipboard-history -t &
2213

2314
# Start Idle Manager
2415
exec-once = hypridle &
2516

26-
exec-once = systemctl --user start app-org.kde.xwaylandvideobridge@autostart.service &
27-
28-
# Fix Dolphin File Manager
29-
exec-once = $hyprscripts/fix-dolphin.sh &
30-
31-
# If you use a mouse with additional buttons: Chack name with: `libinput list-devices | grep Device`
32-
exec-once = input-remapper-control --command autoload --device $mouse &
33-
3417
# Cursor theme
3518
exec-once = hyprctl setcursor $cursor 24
3619

20+
# Start Waybar
21+
exec-once = sleep 1; waybar -c "$HOME/.config/waybar/config.jsonc" &
22+
23+
exec-once = sleep 1; $hyprscripts/Startup_check.sh &
24+
3725
# Start Apps Workspace 1:
3826
exec-once = [workspace 1 silent] $editor
3927

4028
# Start Apps Workspace 2:
4129
exec-once = [workspace 2 silent] $browser &
4230

43-
# Start Apps Workspace 3:
31+
# Optional extras (commented in the example to avoid assuming package availability)
32+
# exec-once = swaync
33+
# exec-once = nm-applet --indicator &
34+
# exec-once = pypr
35+
# exec-once = systemctl --user start app-org.kde.xwaylandvideobridge@autostart.service &
36+
# exec-once = $hyprscripts/fix-dolphin.sh &
37+
# exec-once = input-remapper-control --command autoload --device $mouse &
38+
# exec-once = hyprsunset
39+
# exec-once = blueman-applet &
40+
# exec-once = blueman-tray &
41+
#
42+
# Example: autostart apps per workspace
43+
# (Workspace 1/2 defaults are enabled above; add more here as needed.)
44+
45+
# Start Apps Workspace 3 (terminal examples)
46+
# These are only safe to enable if the terminal/layout referenced actually exists.
4447
# exec-once = [workspace 3 silent] kitty --session ~/.config/kitty/my_layout.conf
45-
# Example: Start terminal with zellij layout
4648
# exec-once = [workspace 3 silent] kitty -e zellij -l ~/.config/zellij/layouts/sysmon.kdl
47-
48-
# Start Apps Workspace 4:
49-
# Example: Start voice/communication apps
50-
# exec-once = [workspace 4 silent] $voice &
51-
# exec-once = [workspace 4 silent] telegram-desktop &
52-
53-
exec-once = hyprsunset
54-
55-
# Used for tray, Bluetooth in the status bar (waybar)
56-
exec-once = blueman-applet &
57-
exec-once = blueman-tray &
58-
59-
# Start Waybar
60-
exec-once = sleep 1; waybar -c "$HOME/.config/waybar/config.jsonc" &
61-
62-
63-
exec-once = sleep 1; $hyprscripts/Startup_check.sh &
49+
# exec-once = [workspace 3 silent] alacritty -e zellij -l ~/.config/zellij/layouts/sysmon.kdl

dotfiles/.config/hypr/sources_example/keybindings.conf

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,12 @@ $LESS = code:94 # Less Key
1313
$DOUBLES = code:49 # "§" Key
1414
$HOME = code:110 # Home Key
1515

16-
# Open Programms
16+
# Open programs (portable defaults)
1717
bindd = $mainMod, SPACE, Open Menu, exec, pkill wofi || $menu
1818
bindd = $mainMod1, Y, Open Preferred Terminal, exec, $terminal --command $multiplex
1919
bindd = $mainMod, E, Open Preferred File Manager, exec, $fileManager
2020
bindd = $mainMod, F, Open Preferred Browser, exec, $browser
2121
bindd = $mainMod, C, Open Preferred Editor, exec, $editor
22-
bindd = $mainMod, T, Open Telegram, exec, Telegram
23-
bindd = $mainMod, A, Open WhatsApp, exec, wasistlos
24-
bindd = $mainMod, D, Open Preferred Voice App, exec, $voice
25-
bindd = $mainMod, G, Open Github Desktop, exec, $git
2622
bindd = $mainMod, J, Open Preferred Color Picker, exec, $colorPicker
2723
bindd = $mainMod, K, Open Preferred Calendar, exec, $calendar
2824
bindd = $mainMod, $ENTER, Open Calculator, exec, $calc
@@ -61,12 +57,9 @@ bindd = , $HOME, Take Screenshot of Region, exec, $screenshot region --raw | sat
6157
bindd = $mainMod, H, Toggle Waybar, exec, $hyprscripts/toggle_waybar.sh
6258
bindd = $mainMod, V, Toggle Floating, exec, $hyprscripts/toggle_floating.sh
6359
bindd = $mainMod, W, Change Wallpaper, exec, $hyprscripts/change_wallpaper.sh
64-
# bindd = $mainMod $mainMod1, Y, Start WoW Dependencies, exec, $hyprscripts/start_wow_dependencies.sh
65-
bindd = $mainMod $mainMod2, S, Save Replay, exec, $hyprscripts/save_replay.sh
6660
bindd = $mainMod $mainMod1, S, Start Hyprsunset, exec, $hyprscripts/hyprsunset.sh
6761
bindd = $mainMod $mainMod1, M, Start Music Player, exec, hyprctl dispatch exec "[workspace 7 silent] $terminal -e $hyprscripts/play_music.sh"
6862
bindd = $mainMod, $DOUBLES, Open Notes, exec, $terminal -t Notes --command bash -lc "$hyprscripts/notes.sh"
69-
bindd = $mainMod $mainMod1, C, Launch Steam, exec, $hyprscripts/launch_steam_fix.sh
7063
bindd = $mainMod $mainMod2, B, Toggle Bluetooth ON or OFF, exec, $hyprscripts/toggle_bluetooth.sh
7164
bindd = $mainMod $mainMod1, SPACE, Wofi Menu for Github Repositories, exec, $hyprscripts/repos_wofi.sh
7265

dotfiles/.config/hypr/sources_example/windows_and_workspaces.conf

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,11 @@
44
windowrule = float on, match:class alacritty.term-top
55
windowrule = float on, match:class org.pulseaudio.pavucontrol
66

7-
# Workspace 1
8-
# windowrule = workspace 1 silent, match:class Code, match:title Visual Studio Code
9-
10-
# Workspace 2
11-
windowrule = workspace 2 silent, match:class zen
12-
# Alternative browsers:
13-
# windowrule = workspace 2 silent, match:class vivaldi-stable
7+
# Workspace rules
8+
# Intentionally left empty in the example.
9+
# During setup, `setup.sh` may inject a browser workspace rule here based on your browser choice.
1410

15-
# Workspace 4
16-
windowrule = workspace 4 silent, match:class discord
17-
windowrule = workspace 4 silent, match:class org.telegram.desktop
18-
windowrule = workspace 4 silent, match:class wasistlos
19-
20-
# Workspace 5
21-
windowrule = workspace 5, match:class LM Studio
11+
# Workspace 1
2212

2313
# Ignore maximize requests from apps. You'll probably like this.
2414
# Note: suppressevent may not be available in v0.53.0 - check documentation
@@ -75,9 +65,6 @@ windowrule = size 1330 800, match:class filezilla
7565

7666
layerrule = dim_around on, match:namespace wofi
7767

78-
windowrule = float on, match:class steam
79-
windowrule = workspace 6, match:class steam
80-
8168
windowrule = float on, match:class qalculate-gtk
8269

8370
windowrule = float on, match:class alacritty, match:title Notes
@@ -104,11 +91,3 @@ windowrule = stay_focused off, match:class ^(conky)$
10491
windowrule = pin on, match:class ^(conky)$
10592
windowrule = move 20 40, match:class ^(conky)$
10693

107-
windowrule = float on, match:class externe_analytik
108-
windowrule = float on, match:class GitHub Desktop
109-
110-
windowrule = float on, match:class Schulungen-Rust
111-
windowrule = float on, match:class Lagerverwaltung
112-
113-
windowrule = workspace 5, match:class steam_app_275850
114-
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
STATE_FILE="/tmp/waybar_toggle_state"
4+
5+
# Define the visible and hidden config paths.
6+
VISIBLE_CONFIG="$HOME/.config/waybar/config.jsonc"
7+
HIDDEN_CONFIG="$HOME/.config/waybar/hidden_config.jsonc"
8+
9+
if [ -f "$STATE_FILE" ]; then
10+
# Currently hidden, switch to visible
11+
rm "$STATE_FILE"
12+
pkill -f "waybar -c $HIDDEN_CONFIG"
13+
# Refresh LM Studio menu before showing waybar (run synchronously to ensure config is updated)
14+
if [ -f "$HOME/.config/waybar/scripts/lmstudio_refresh_menu.sh" ]; then
15+
"$HOME/.config/waybar/scripts/lmstudio_refresh_menu.sh" > /dev/null 2>&1
16+
fi
17+
waybar -c "$VISIBLE_CONFIG" &
18+
else
19+
# Currently visible, switch to hidden
20+
touch "$STATE_FILE"
21+
pkill -f "waybar -c $VISIBLE_CONFIG"
22+
waybar -c "$HIDDEN_CONFIG" &
23+
fi

0 commit comments

Comments
 (0)