Add swaync control center, wifi/bluetooth/vpn rofi menus, waybar notification button
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Executable
+44
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env bash
|
||||
# Bluetooth menu (rofi): power, connect/disconnect known devices, scan and pair new ones.
|
||||
THEME=~/.config/rofi/catppuccin.rasi
|
||||
menu() { rofi -dmenu -i -p "$1" -theme "$THEME" "${@:2}"; }
|
||||
|
||||
if ! bluetoothctl show | grep -q "Powered: yes"; then
|
||||
choice=$(printf '%s\n' "Включить Bluetooth" | menu "Bluetooth") || exit 0
|
||||
[[ $choice == "Включить Bluetooth" ]] && bluetoothctl power on >/dev/null && notify-send "Bluetooth" "Включён"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
build() {
|
||||
local list="" mac name mark
|
||||
while read -r _ mac name; do
|
||||
[[ -z $mac ]] && continue
|
||||
mark="○"; bluetoothctl info "$mac" | grep -q "Connected: yes" && mark="●"
|
||||
list+="$mark $name [$mac]"$'\n'
|
||||
done < <(bluetoothctl devices)
|
||||
printf '%s' "$list"
|
||||
}
|
||||
|
||||
choice=$(printf '%s%s\n%s\n' "$(build)" "Найти новые устройства" "Выключить Bluetooth" | sed '/^$/d' | menu "Bluetooth") || exit 0
|
||||
[[ -z $choice ]] && exit 0
|
||||
|
||||
case $choice in
|
||||
"Выключить Bluetooth") bluetoothctl power off >/dev/null; notify-send "Bluetooth" "Выключен"; exit 0 ;;
|
||||
"Найти новые устройства")
|
||||
notify-send "Bluetooth" "Поиск устройств (8 с)…"
|
||||
bluetoothctl --timeout 8 scan on >/dev/null 2>&1
|
||||
choice=$(build | menu "Bluetooth: найденные") || exit 0
|
||||
[[ -z $choice ]] && exit 0
|
||||
mac=${choice##*[}; mac=${mac%]}
|
||||
bluetoothctl pair "$mac" >/dev/null 2>&1; bluetoothctl trust "$mac" >/dev/null 2>&1
|
||||
bluetoothctl connect "$mac" >/dev/null 2>&1 && notify-send "Bluetooth" "Подключено" || notify-send -u critical "Bluetooth" "Не удалось подключиться"
|
||||
exit 0 ;;
|
||||
esac
|
||||
|
||||
mac=${choice##*[}; mac=${mac%]}
|
||||
name=${choice:2}; name=${name% [*}
|
||||
if [[ ${choice:0:1} == "●" ]]; then
|
||||
bluetoothctl disconnect "$mac" >/dev/null && notify-send "Bluetooth" "Отключено: $name"
|
||||
else
|
||||
bluetoothctl connect "$mac" >/dev/null 2>&1 && notify-send "Bluetooth" "Подключено: $name" || notify-send -u critical "Bluetooth" "Не удалось подключиться: $name"
|
||||
fi
|
||||
@@ -26,7 +26,7 @@ client.placeholder $base $base $text $base $base
|
||||
client.background $base
|
||||
|
||||
# Autostart
|
||||
exec_always sh -c 'pkill -x dunst; exec dunst'
|
||||
exec_always sh -c 'pkill -x dunst; pkill -x swaync; exec swaync'
|
||||
exec_always sh -c 'pkill -x nm-applet; exec nm-applet --indicator'
|
||||
bindsym --to-code $mod+Shift+x exec ~/.config/sway/lock.sh
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ titlebar_separator disable
|
||||
layer_effects "waybar" blur enable; blur_ignore_transparent enable; corner_radius 14; shadows enable
|
||||
layer_effects "rofi" blur enable; blur_ignore_transparent enable; corner_radius 20; shadows enable
|
||||
layer_effects "notifications" blur enable; blur_ignore_transparent enable; corner_radius 14; shadows enable
|
||||
layer_effects "swaync-control-center" blur enable; blur_ignore_transparent enable; corner_radius 20; shadows enable
|
||||
layer_effects "swaync-notification-window" blur enable; blur_ignore_transparent enable; corner_radius 14; shadows enable
|
||||
layer_effects "swaynag" blur enable; blur_ignore_transparent enable; corner_radius 12
|
||||
|
||||
# Translucent terminals, glass shows through
|
||||
|
||||
@@ -32,3 +32,6 @@ bindsym --to-code $mod+Shift+s exec ~/.config/sway/screenshot-menu.sh
|
||||
bindsym --to-code $mod+F1 exec ~/.config/sway/cheatsheet.sh
|
||||
# Performance mode: toggle blur + shadows
|
||||
bindsym --to-code $mod+Shift+b blur toggle; shadows toggle
|
||||
# Control center (notifications + quick settings)
|
||||
bindsym --to-code $mod+n exec swaync-client -t -sw
|
||||
bindsym --to-code $mod+Shift+n exec swaync-client -d -sw
|
||||
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
# VPN menu (rofi): lists NetworkManager vpn/wireguard connections, click to connect/disconnect.
|
||||
# Secrets are asked by nm-applet (secret agent).
|
||||
THEME=~/.config/rofi/catppuccin.rasi
|
||||
menu() { rofi -dmenu -i -p "$1" -theme "$THEME" "${@:2}"; }
|
||||
|
||||
active=$(nmcli -t -e no -f NAME,TYPE connection show --active)
|
||||
list=""
|
||||
while IFS= read -r line; do
|
||||
type=${line##*:}; name=${line%:*}
|
||||
[[ $type == vpn || $type == wireguard ]] || continue
|
||||
mark="○"; grep -Fxq "$line" <<<"$active" && mark="●"
|
||||
list+="$mark $name ($type)"$'\n'
|
||||
done < <(nmcli -t -e no -f NAME,TYPE connection show)
|
||||
|
||||
[[ -z $list ]] && { notify-send "VPN" "Нет настроенных VPN"; exit 0; }
|
||||
choice=$(printf '%s%s\n' "$list" "Расширенные настройки…" | menu "VPN") || exit 0
|
||||
[[ -z $choice ]] && exit 0
|
||||
[[ $choice == "Расширенные настройки…" ]] && exec nm-connection-editor
|
||||
|
||||
name=${choice:2}; name=${name% (*}
|
||||
if [[ ${choice:0:1} == "●" ]]; then
|
||||
nmcli connection down id "$name" >/dev/null && notify-send "VPN" "Отключено: $name"
|
||||
else
|
||||
nmcli connection up id "$name" >/dev/null 2>&1 && notify-send "VPN" "Подключено: $name" || notify-send -u critical "VPN" "Не удалось подключиться: $name"
|
||||
fi
|
||||
Executable
+44
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env bash
|
||||
# Wi-Fi menu (rofi): toggle radio, connect/disconnect, prompt for password on new networks.
|
||||
THEME=~/.config/rofi/catppuccin.rasi
|
||||
menu() { rofi -dmenu -i -p "$1" -theme "$THEME" "${@:2}"; }
|
||||
|
||||
radio=$(nmcli radio wifi)
|
||||
if [[ $radio != enabled ]]; then
|
||||
choice=$(printf '%s\n' "Включить Wi-Fi" | menu "Wi-Fi")
|
||||
[[ $choice == "Включить Wi-Fi" ]] && nmcli radio wifi on && notify-send "Wi-Fi" "Включён"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
declare -A seen
|
||||
list=""
|
||||
while IFS=: read -r use sig sec ssid; do
|
||||
[[ -z $ssid || -n ${seen[$ssid]} ]] && continue
|
||||
seen[$ssid]=1
|
||||
mark="○"; [[ $use == '*' ]] && mark="●"
|
||||
lock=""; [[ -n $sec && $sec != "--" ]] && lock=" (защищена)"
|
||||
list+="$mark $ssid ${sig}%$lock"$'\n'
|
||||
done < <(nmcli -t -e no -f IN-USE,SIGNAL,SECURITY,SSID dev wifi list --rescan auto | sort -t: -k2 -nr)
|
||||
|
||||
choice=$(printf '%s%s\n%s\n' "$list" "Выключить Wi-Fi" "Расширенные настройки…" | sed '/^$/d' | menu "Wi-Fi") || exit 0
|
||||
[[ -z $choice ]] && exit 0
|
||||
|
||||
case $choice in
|
||||
"Выключить Wi-Fi") nmcli radio wifi off; notify-send "Wi-Fi" "Выключен"; exit 0 ;;
|
||||
"Расширенные настройки…") exec nm-connection-editor ;;
|
||||
esac
|
||||
|
||||
ssid=${choice:2}; ssid=${ssid%% *}
|
||||
if [[ ${choice:0:1} == "●" ]]; then
|
||||
nmcli connection down id "$ssid" >/dev/null && notify-send "Wi-Fi" "Отключено от $ssid"
|
||||
elif nmcli -t -f NAME connection show | grep -Fxq "$ssid"; then
|
||||
nmcli connection up id "$ssid" >/dev/null 2>&1 && notify-send "Wi-Fi" "Подключено к $ssid" || notify-send -u critical "Wi-Fi" "Не удалось подключиться к $ssid"
|
||||
else
|
||||
if [[ $choice == *"(защищена)"* ]]; then
|
||||
pw=$(menu "Пароль для $ssid" -password -lines 0) || exit 0
|
||||
out=$(nmcli dev wifi connect "$ssid" password "$pw" 2>&1)
|
||||
else
|
||||
out=$(nmcli dev wifi connect "$ssid" 2>&1)
|
||||
fi
|
||||
[[ $? -eq 0 ]] && notify-send "Wi-Fi" "Подключено к $ssid" || notify-send -u critical "Wi-Fi" "Ошибка: $out"
|
||||
fi
|
||||
Reference in New Issue
Block a user