config/eww ahrc-laptop : nouvelle version
This commit is contained in:
parent
bdbf866d0d
commit
2cfd4c662e
6 changed files with 249 additions and 34 deletions
11
config/eww-ahrc--laptop/action/hyprland/nearby-workspace
Executable file
11
config/eww-ahrc--laptop/action/hyprland/nearby-workspace
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env sh
|
||||
case "$1" in
|
||||
up)
|
||||
hyprctl dispatch workspace +1
|
||||
;;
|
||||
down)
|
||||
hyprctl dispatch workspace -1
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
|
@ -1,9 +1,30 @@
|
|||
window {
|
||||
window, menubar {
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
window {
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
window > box {
|
||||
margin: 0px 15px;
|
||||
window > box > box > * {
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.workspace-button, .submap {
|
||||
border-top: 2px solid white;
|
||||
}
|
||||
|
||||
.workspace-button:hover {
|
||||
border-color: #80ff80;
|
||||
color: #e0ffe0;
|
||||
}
|
||||
|
||||
.workspace-button > box {
|
||||
padding-top: 3px;
|
||||
}
|
||||
|
||||
.workspace-current {
|
||||
border-color: #00ff00;
|
||||
color: #00f000;
|
||||
}
|
||||
|
|
|
@ -1,40 +1,122 @@
|
|||
(defwidget time []
|
||||
(eventbox :class "time"
|
||||
"${formattime(EWW_TIME, "%Y-%m-%d | %H:%M:%S")}"
|
||||
(deflisten batterystatus
|
||||
:initial "unknown"
|
||||
"listen/battery BAT1"
|
||||
)
|
||||
|
||||
(deflisten workspaces
|
||||
:initial '{"current":1,"used":[1]}'
|
||||
"listen/hypr workspace"
|
||||
)
|
||||
|
||||
(deflisten windowtitle
|
||||
:initial ''
|
||||
"listen/hypr activewindow"
|
||||
)
|
||||
|
||||
(deflisten submap
|
||||
:initial ''
|
||||
"listen/hypr submap"
|
||||
)
|
||||
|
||||
(deflisten network
|
||||
:initial '{"state":"disconnected","infos":{}}'
|
||||
"listen/network"
|
||||
)
|
||||
|
||||
(defvar battery-icon '{
|
||||
"unknown": "",
|
||||
"critical": "",
|
||||
"low": "",
|
||||
"medium": "",
|
||||
"high": "",
|
||||
"full": ""
|
||||
}')
|
||||
|
||||
(defvar network-icon '{
|
||||
"disconnected": "",
|
||||
"ethernet": "",
|
||||
"wifi-terrible": "",
|
||||
"wifi-bad": "",
|
||||
"wifi-mediocre": "",
|
||||
"wifi-good": "",
|
||||
"wifi-excellent": "",
|
||||
"tethering": ""
|
||||
}')
|
||||
|
||||
(defwidget workspaces []
|
||||
(eventbox :onscroll "action/hyprland/nearby-workspace {}"
|
||||
(box :class "workspaces"
|
||||
(for workspace in {workspaces.used}
|
||||
(eventbox
|
||||
:class "workspace-button ${workspace == workspaces.current ? "workspace-current" : ""}"
|
||||
:onclick "hyprctl dispatch workspace ${workspace}"
|
||||
(box :width 25 "${workspace}")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defwidget submap []
|
||||
(eventbox :onclick "hyprctl dispatch submap reset"
|
||||
(box :class "submap" "${submap}")
|
||||
)
|
||||
)
|
||||
|
||||
(defwidget window-title []
|
||||
(box "${windowtitle ?: ''}")
|
||||
)
|
||||
|
||||
(defwidget tray [] (box
|
||||
(systray :icon-size 15 :spacing 10)
|
||||
))
|
||||
|
||||
(defwidget time []
|
||||
"${formattime(EWW_TIME, "%Y-%m-%d")} ${formattime(EWW_TIME, "%H:%M:%S")}"
|
||||
)
|
||||
|
||||
; (defwidget sound [] "")
|
||||
(defwidget network []
|
||||
"${network.state == "wireless" ? "${network-icon["wifi-${network.infos.signal}"]} ${network.infos.ssid}" : "${network-icon[network.state]}"}"
|
||||
)
|
||||
|
||||
(defwidget battery []
|
||||
(box
|
||||
(label
|
||||
:text "${EWW_BATTERY.BAT0.status == "Discharging" ? "" : ""}"
|
||||
)
|
||||
(label :text "${EWW_BATTERY.BAT0.capacity} %")
|
||||
)
|
||||
"${battery-icon[batterystatus]}${EWW_BATTERY.BAT1.status == "Charging" ? " " : ""} ${EWW_BATTERY.BAT1.capacity} %"
|
||||
)
|
||||
|
||||
(defwindow bar
|
||||
:monitor 0
|
||||
:geometry (geometry
|
||||
:x "0%"
|
||||
:y "0%"
|
||||
:width "100%"
|
||||
:height "2.5%"
|
||||
:anchor "bottom center"
|
||||
:monitor 0
|
||||
:geometry (geometry
|
||||
:anchor "bottom center"
|
||||
:width "100%"
|
||||
:height 25
|
||||
)
|
||||
:exclusive true
|
||||
|
||||
(centerbox
|
||||
(box
|
||||
:halign "start"
|
||||
:space-evenly false
|
||||
:class "left"
|
||||
|
||||
(workspaces)
|
||||
(submap)
|
||||
(window-title)
|
||||
)
|
||||
:stacking "fg"
|
||||
:reserve (struts :distance "0px" :side "top")
|
||||
:windowtype "dock"
|
||||
:wm-ignore false
|
||||
:exclusive true
|
||||
:focusable false
|
||||
(centerbox
|
||||
(box :class "left")
|
||||
(box :class "center"
|
||||
(time)
|
||||
)
|
||||
(box :class "right" :halign "end"
|
||||
(battery)
|
||||
)
|
||||
(box
|
||||
:space-evenly false
|
||||
:class "middle"
|
||||
|
||||
(tray) (time)
|
||||
)
|
||||
(box
|
||||
:halign "end"
|
||||
:space-evenly false
|
||||
:class "right"
|
||||
|
||||
; (sound)
|
||||
(network)
|
||||
(battery)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
19
config/eww-ahrc--laptop/listen/battery
Executable file
19
config/eww-ahrc--laptop/listen/battery
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env sh
|
||||
battery=$1
|
||||
|
||||
print_battery_status() {
|
||||
battery_capacity=$(cat "/sys/class/power_supply/${battery}/capacity") \
|
||||
|| exit
|
||||
|
||||
if [ "$battery_capacity" -lt 25 ]; then echo critical
|
||||
elif [ "$battery_capacity" -lt 50 ]; then echo low
|
||||
elif [ "$battery_capacity" -lt 75 ]; then echo medium
|
||||
elif [ "$battery_capacity" -lt 100 ]; then echo high
|
||||
else echo full
|
||||
fi
|
||||
}
|
||||
|
||||
while :; do
|
||||
print_battery_status
|
||||
sleep 20
|
||||
done
|
21
config/eww-ahrc--laptop/listen/hypr
Executable file
21
config/eww-ahrc--laptop/listen/hypr
Executable file
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env sh
|
||||
workspace() {
|
||||
printf '{"current":%s,"used":%s}\n' \
|
||||
"$(hyprctl -j activeworkspace | jq -c '.id')" \
|
||||
"$(hyprctl -j workspaces | jq -c '.[].id' | sort -n | jq -sc)"
|
||||
}
|
||||
|
||||
activewindow() {
|
||||
hyprctl -j activewindow | jq -c -r .title
|
||||
}
|
||||
|
||||
submap() {
|
||||
echo "$event" | sed 's/^submap>>//'
|
||||
}
|
||||
|
||||
command -v "$1" > /dev/null || exit
|
||||
|
||||
"$1"
|
||||
socat -U STDOUT UNIX-CONNECT:"${XDG_RUNTIME_DIR}/hypr/${HYPRLAND_INSTANCE_SIGNATURE}/.socket2.sock" | stdbuf -o L grep -e "^${1}>>" | while read -r event; do
|
||||
"$1"
|
||||
done
|
61
config/eww-ahrc--laptop/listen/network
Executable file
61
config/eww-ahrc--laptop/listen/network
Executable file
|
@ -0,0 +1,61 @@
|
|||
#!/usr/bin/env sh
|
||||
print_state() {
|
||||
case "$1" in
|
||||
eth*)
|
||||
echo ethernet
|
||||
;;
|
||||
wlan*)
|
||||
echo wireless
|
||||
;;
|
||||
usb*)
|
||||
echo tethering
|
||||
;;
|
||||
*)
|
||||
echo disconnected
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
wifi_strength() {
|
||||
if [ "$1" -le -80 ]; then echo terrible
|
||||
elif [ "$1" -le -70 ]; then echo bad
|
||||
elif [ "$1" -le -60 ]; then echo mediocre
|
||||
elif [ "$1" -le -40 ]; then echo good
|
||||
else echo excellent
|
||||
fi
|
||||
}
|
||||
|
||||
print_infos() {
|
||||
printf \{
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
route_line=$(ip route show dev "$1" | awk '($1 == "default") { print }')
|
||||
|
||||
printf '"ip":"%s","gateway":"%s"' \
|
||||
"$(echo "$route_line" | awk '{ print $7 }')" \
|
||||
"$(echo "$route_line" | awk '{ print $3 }')"
|
||||
|
||||
if [ "$state" = wireless ]; then
|
||||
signal=$(iw dev "$1" link | awk '($1 == "signal:") { print $2}')
|
||||
printf ',"signal":"%s","ssid":"%s"' \
|
||||
"$(wifi_strength "$signal")" \
|
||||
"$(iw dev wlan0 info | grep '^\s*ssid ' | xargs | cut -d \ -f 2-)"
|
||||
fi
|
||||
fi
|
||||
|
||||
printf '}\n'
|
||||
}
|
||||
|
||||
print_network_status() {
|
||||
device=$(ip route | awk '($1 == "default") { print $5 }')
|
||||
state=$(print_state "$device")
|
||||
|
||||
printf '{"state":"%s","infos":%s}\n' \
|
||||
"$state" \
|
||||
"$(print_infos "$device")"
|
||||
}
|
||||
|
||||
while :; do
|
||||
print_network_status
|
||||
sleep 5
|
||||
done
|
Loading…
Reference in a new issue