forked from mkbula/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththeme-set
More file actions
executable file
·107 lines (81 loc) · 2.33 KB
/
Copy paththeme-set
File metadata and controls
executable file
·107 lines (81 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
source "$HOME/.local/share/dotfiles/bin/lib/helpers.sh"
THEMES_DIR="$HOME/.local/share/dotfiles/themes"
CURRENT_THEME_LINK="$HOME/.local/share/dotfiles/current/theme"
CURRENT_BACKGROUND_LINK="$HOME/.local/share/dotfiles/current/background"
set_wallpaper() {
local wallpaper="$1"
ln -nsf "$wallpaper" "$CURRENT_BACKGROUND_LINK"
hyprctl hyprpaper preload "$wallpaper"
hyprctl monitors -j | jq -r '.[].name' | while read -r monitor; do
hyprctl hyprpaper wallpaper "$monitor,$wallpaper"
done
log_success "Wallpaper set: $(basename "$wallpaper")"
}
reload_apps() {
log_step "Reloading applications"
restart-app waybar
restart-app swayosd
hyprctl reload
pkill -SIGUSR2 btop
makoctl reload
killall -SIGUSR2 ghostty
killall xdg-desktop-portal-gtk
local gnome_icons_theme="$HOME/.local/share/dotfiles/current/theme/icons.theme"
if [[ -f "$gnome_icons_theme" ]]; then
gsettings set org.gnome.desktop.interface icon-theme "$(<"$gnome_icons_theme")"
fi
log_success "Applications reloaded"
}
apply_dynamic_theme() {
local theme_name="$1"
local wallpaper="$2"
log_step "Applying ${theme_name^} theme"
ln -nsf "$THEMES_DIR/$theme_name" "$CURRENT_THEME_LINK"
if [[ -n "$wallpaper" ]]; then
set_wallpaper "$wallpaper"
fi
reload_apps
log_success "${theme_name^} theme applied"
}
switch_theme() {
local theme_name="$1"
theme_name=$(echo "$theme_name" | sed -E 's/<[^>]+>//g' | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
local theme_path="$THEMES_DIR/$theme_name"
if [[ ! -d "$theme_path" ]]; then
log_error "Theme '$theme_name' not found"
return 1
fi
log_step "Switching to theme: $theme_name"
ln -nsf "$theme_path" "$CURRENT_THEME_LINK"
local wallpaper=$(find -L "$theme_path/backgrounds" -type f | sort | head -n 1)
if [[ -n "$wallpaper" ]]; then
set_wallpaper "$wallpaper"
fi
reload_apps
log_success "Theme switched"
}
change_wallpaper() {
local wallpaper="$1"
if [[ ! -f "$wallpaper" ]]; then
log_error "Wallpaper not found"
return 1
fi
log_step "Changing wallpaper"
set_wallpaper "$wallpaper"
log_info "Use Tinte to regenerate colors for this wallpaper"
}
main() {
case "$1" in
tinte | matugen)
apply_dynamic_theme "$1" "$2"
;;
--wallpaper)
change_wallpaper "$2"
;;
*)
switch_theme "$1"
;;
esac
}
main "$@"