blob: a085ef1d4cba1f8a80034ba2aef1ea6ae9be3a7d (
plain)
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
{ pkgs, ... }:
let
volume-control = pkgs.writeShellScriptBin "volume-control" ''
TAG="audio-volume"
function get_vol {
${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print int($2 * 100)}'
}
case $1 in
up) ${pkgs.wireplumber}/bin/wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+ ;;
down) ${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- ;;
mute) ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle ;;
esac
vol=$(get_vol)
is_muted=$(${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_AUDIO_SINK@ | grep "MUTED")
if [ -n "$is_muted" ]; then
${pkgs.dunst}/bin/dunstify -a "Volume" -u low \
-h string:x-canonical-private-synchronous:$TAG \
"Volume: Muted"
else
${pkgs.dunst}/bin/dunstify -a "Volume" -u low \
-h string:x-canonical-private-synchronous:$TAG \
-h int:value:"$vol" \
"Volume: $vol%"
fi
'';
brightness-control = pkgs.writeShellScriptBin "brightness-control" ''
TAG="screen-brightness"
case $1 in
up) ${pkgs.brightnessctl}/bin/brightnessctl set +5% ;;
down) ${pkgs.brightnessctl}/bin/brightnessctl set 5%- ;;
esac
# Get current percentage
current=$(${pkgs.brightnessctl}/bin/brightnessctl info | grep -oP '\(\K[0-9]+(?=%\))')
${pkgs.dunst}/bin/dunstify -a "Brightness" -u low \
-h string:x-canonical-private-synchronous:$TAG \
-h int:value:"$current" \
"Brightness: $current%"
'';
mic-control = pkgs.writeShellScriptBin "mic-control" ''
TAG="audio-mic"
case $1 in
toggle) ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle ;;
esac
is_muted=$(${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_AUDIO_SOURCE@ | grep "MUTED")
if [ -n "$is_muted" ]; then
${pkgs.dunst}/bin/dunstify -a "Microphone" -u low \
-h string:x-canonical-private-synchronous:$TAG \
"Microphone: Muted"
else
${pkgs.dunst}/bin/dunstify -a "Microphone" -u low \
-h string:x-canonical-private-synchronous:$TAG \
"Microphone: On"
fi
'';
beesettings = pkgs.writeShellScriptBin "beesettings" ''
CONFIG_FILE="$HOME/.config/beeSettings"
WALL_DIR="$HOME/Pictures/Wallpapers"
init_settings() {
if [ ! -f "$CONFIG_FILE" ]; then
mkdir -p "$(dirname "$CONFIG_FILE")"
echo -e "theme=dark\nnightlight=off\nwallpaper=$WALL_DIR/default.jpg\ncolor_type=scheme-tonal-spot" > "$CONFIG_FILE"
fi
}
get_val() { grep "^$1=" "$CONFIG_FILE" | cut -d'=' -f2; }
set_val() { sed -i "s|^$1=.*|$1=$2|" "$CONFIG_FILE"; }
set_layout() { mmsg -l "$1"; }
apply_all() {
local theme=$(get_val "theme")
local wall=$(get_val "wallpaper")
local color_type=$(get_val "color_type")
local mode_flag="dark"
[ "$theme" == "light" ] && mode_flag="light"
matugen image "$wall" -m "$mode_flag" -t "$color_type" --source-color-index 0 2>/dev/null
wallust -q -s run -p "''${mode_flag}16" "$wall" 2>/dev/null
systemctl --user restart xdg-desktop-portal-gtk
if [ "$mode_flag" = "dark" ]; then
dconf write /org/gnome/desktop/interface/color-scheme "'prefer-light'"
else
dconf write /org/gnome/desktop/interface/color-scheme "'prefer-dark'"
fi
dconf write /org/gnome/desktop/interface/color-scheme "'prefer-$mode_flag'"
if [ -z "$WAYLAND_DISPLAY" ] && [ -n "$DISPLAY" ]; then
xrdb -merge "$HOME/.Xresources"
fi
[ -f "$HOME/.config/sequences" ] && sh "$HOME/.config/sequences"
}
cmd_wall() {
list_walls() {
for wall in "$WALL_DIR"/*.{jpg,jpeg,png,webp}; do
[ -f "$wall" ] && echo -en "$(basename "$wall")\0icon\x1f$wall\n"
done
}
SELECTED=$(list_walls | rofi -dmenu -i -p "Wallpaper" \
-show-icons \
-theme-str 'element { orientation: vertical; padding: 15px; }' \
-theme-str 'element-icon { size: 10em; horizontal-align: 0.5; }' \
-theme-str 'listview { columns: 3; lines: 2; }' \
-theme-str 'window { width: 50%; }')
if [ -n "$SELECTED" ]; then
FULL_PATH="$WALL_DIR/$SELECTED"
set_val "wallpaper" "$FULL_PATH"
if [ -n "$WAYLAND_DISPLAY" ]; then
if command -v swww >/dev/null 2>&1; then
swww img "$FULL_PATH" --transition-type grow --transition-fps 120 --transition-step 60 --transition-duration 1.5
else
pkill swaybg; swaybg -i "$FULL_PATH" -m fill &
fi
else
feh --bg-fill "$FULL_PATH"
fi
apply_all
fi
}
clr_type() {
local types=(
"scheme-tonal-spot"
"scheme-content"
"scheme-expressive"
"scheme-fidelity"
"scheme-fruit-salad"
"scheme-monochrome"
"scheme-neutral"
"scheme-rainbow"
"scheme-vibrant"
)
local selection
selection=$(printf "%s\n" "''${types[@]}" | rofi -dmenu -i -p "Coloscheme Types")
if [[ -n "$selection" ]]; then
set_val "color_type" "$selection"
apply_all
fi
}
cmd_layout() {
declare -A layouts=(
["tile"]="T"
["monocle"]="M"
["scroller"]="S"
["tgmix"]="TG"
["grid"]="G"
["deck"]="K"
["center tile"]="CT"
["right tile"]="RT"
["vertical scroller"]="VS"
["vertical tile"]="VT"
["vertical grid"]="VG"
["vertical deck"]="VK"
)
local selection
selection=$(printf "%s\n" "''${!layouts[@]}" | sort | rofi -dmenu -i -p "Layout")
if [[ -n "''${layouts[$selection]}" ]]; then
set_layout "''${layouts[$selection]}"
fi
}
cmd_settings() {
local theme=$(get_val "theme")
local nl=$(get_val "nightlight")
local ct=$(get_val "color_type")
local options=(
"Mode: $theme"
"Night Light: $nl"
"Wallpaper"
"Colorscheme Type: $ct"
"Layouts"
)
local choice
choice=$(printf "%s\n" "''${options[@]}" | rofi -dmenu -p "Settings" -i)
case "$choice" in
"Mode: "*)
[[ "$theme" == "dark" ]] && set_val "theme" "light" || set_val "theme" "dark"
apply_all
;;
"Night Light: "*)
if [[ "$nl" == "on" ]]; then
set_val "nightlight" "off"; pkill wlsunset
else
set_val "nightlight" "on"; wlsunset -T 4500 &
fi
;;
"Wallpaper") cmd_wall ;;
"Colorscheme Type:"*) clr_type ;;
"Layouts") cmd_layout ;;
esac
}
init_settings
case "$1" in
wall) cmd_wall ;;
settings) cmd_settings ;;
layout) cmd_layout ;;
apply) apply_all ;;
*) echo "Usage: bee {wall|settings|apply}" ;;
esac
'';
in
{
home.packages = [
volume-control
brightness-control
mic-control
beesettings
];
}
|