[eww] Add brightness, network & notifications widgets
This commit is contained in:
parent
e4301645d1
commit
962fdf8c30
5 changed files with 56 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
|||
; Brightness
|
||||
(deflisten brightness :initial "128" "while :; do cat /sys/class/backlight/amdgpu_bl1/brightness; sleep 0.1; done")
|
||||
(defpoll brightness :initial "128" :interval "1m" "cat /sys/class/backlight/amdgpu_bl1/brightness")
|
||||
(defvar brightness-icons '["", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]')
|
||||
(defvar brightness-slide false)
|
||||
|
||||
|
@ -12,8 +12,11 @@
|
|||
(defpoll day :interval "1m" :initial "1" "date +'%d'")
|
||||
(defpoll year :interval "1m" :initial "0" "date +'%Y'")
|
||||
|
||||
; Network
|
||||
(defpoll network :initial '{"if": "lo"}' :interval "2s" "~/.config/eww/scripts/get-network.sh")
|
||||
|
||||
; Notifications status
|
||||
(deflisten nf-enabled :initial "true" "while :; do makoctl mode | grep -q dnd && echo false || echo true; sleep 0.1; done")
|
||||
(defpoll nf-enabled :initial "true" :interval "1m" "makoctl mode | grep -q dnd && echo false || echo true")
|
||||
|
||||
; Packages updates
|
||||
(deflisten packages-updates :initial '{"count": "-", "class": " "}' "~/.config/eww/scripts/pkg-updates.sh")
|
||||
|
@ -38,6 +41,7 @@
|
|||
)
|
||||
(nf-state)
|
||||
(packages-updates)
|
||||
(network)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -69,6 +73,13 @@
|
|||
)
|
||||
)
|
||||
|
||||
(defwidget network []
|
||||
(tooltip
|
||||
(label :text "IPv4: ${network.ip4}\\nIPv6: ${network.ip6}${network.type == "wifi" ? "\\nRate: ${network.rate}\\nSignal strength: ${network.signal}" : ""}")
|
||||
(label :text "${network.icon} ${network.name} ${network.if == "null" ? "" : " ${EWW_NET[network.if].NET_DOWN} ${EWW_NET[network.if].NET_UP}"}")
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(defwidget bar-middle []
|
||||
(label :limit-width 2
|
||||
|
@ -109,7 +120,7 @@
|
|||
(scale :value {brightness}
|
||||
:min 0
|
||||
:max 255
|
||||
:onchange "echo {} > /sys/class/backlight/amdgpu_bl1/brightness"
|
||||
:onchange "~/.config/eww/scripts/set-brightness.sh {}"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
26
.config/eww/scripts/get-network.sh
Executable file
26
.config/eww/scripts/get-network.sh
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
if=$(ip -j r list default | jq -r '.[0].dev')
|
||||
|
||||
if [[ "$if" != "null" ]]; then
|
||||
type="$(nmcli -t -g general.type device show $if)"
|
||||
ip4="$(nmcli -t -g ip4.address device show $if)"
|
||||
ip6="$(nmcli -t -g ip6.address device show $if | sed 's/\\//g')"
|
||||
|
||||
if [[ "$type" == "wifi" ]]; then
|
||||
icon=""
|
||||
name="$(nmcli -t -g general.connection device show $if)"
|
||||
rate="$(nmcli -t -g 'AP' device show wlo1 | awk -F ':' '{if ($2 == "*") { print $12 } }')"
|
||||
signal="$(nmcli -t -g 'AP' device show wlo1 | awk -F ':' '{if ($2 == "*") { print $13 } }')%"
|
||||
else
|
||||
icon=""
|
||||
name="Ethernet"
|
||||
fi
|
||||
else
|
||||
icon=""
|
||||
name="Not connected"
|
||||
fi
|
||||
|
||||
cat << EOF
|
||||
{"if": "$if", "icon": "$icon", "type": "$type", "name": "$name", "ip4": "$ip4", "ip6": "$ip6", "rate": "$rate", "signal": "$signal"}
|
||||
EOF
|
11
.config/eww/scripts/set-brightness.sh
Executable file
11
.config/eww/scripts/set-brightness.sh
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [[ "$1" =~ ^[0-9]+$ ]]; then
|
||||
echo "$1" > /sys/class/backlight/amdgpu_bl1/brightness
|
||||
elif [[ "$1" == "raise" ]]; then
|
||||
swayosd-client --brightness raise
|
||||
elif [[ "$1" == "lower" ]]; then
|
||||
swayosd-client --brightness lower
|
||||
fi
|
||||
|
||||
eww update brightness=$(cat /sys/class/backlight/amdgpu_bl1/brightness)
|
|
@ -3,10 +3,13 @@
|
|||
makoctl mode -t dnd
|
||||
|
||||
if ! makoctl mode | grep -q dnd; then
|
||||
eww update nf-enabled=true
|
||||
if [[ "$LANG" =~ ^fr ]]; then
|
||||
text="Notifications activées."
|
||||
else
|
||||
text="Notifications enabled."
|
||||
fi
|
||||
notify-send "$text"
|
||||
else
|
||||
eww update nf-enabled=false
|
||||
fi
|
||||
|
|
|
@ -71,8 +71,8 @@ binde = , XF86AudioRaiseVolume, exec, swayosd-client --output-volume=raise
|
|||
binde = , XF86AudioLowerVolume, exec, swayosd-client --output-volume=lower
|
||||
binde = , XF86AudioMute, exec, swayosd-client --output-volume=mute-toggle
|
||||
binde = , XF86AudioMicMute, exec, swayosd-client --input-volume=mute-toggle
|
||||
bindel = , XF86MonBrightnessUp, exec, swayosd-client --brightness raise
|
||||
bindel = , XF86MonBrightnessDown, exec, swayosd-client --brightness lower
|
||||
bindel = , XF86MonBrightnessUp, exec, $HOME/.config/eww/scripts/set-brightness.sh raise
|
||||
bindel = , XF86MonBrightnessDown, exec, $HOME/.config/eww/scripts/set-brightness.sh lower
|
||||
|
||||
# Media keys
|
||||
bindl = , XF86AudioPlay, exec, playerctl play-pause
|
||||
|
|
Loading…
Reference in a new issue