treewide: preliminary Wayland!

This commit is contained in:
LavaDesu 2024-01-17 15:33:46 +07:00
parent 67798937bb
commit 2602b8bc1c
Signed by: cilly
GPG key ID: 6500251E087653C9
11 changed files with 197 additions and 11 deletions

72
res/eww-wayland/eww.scss Normal file
View file

@ -0,0 +1,72 @@
$background: #1a1b26;
$accent: #9d7cd8;
$foreground: #c0caf5;
* {
all: unset;
}
window {
background: transparent;
}
.bar {
margin: 5px 20px 0px 20px;
}
.widget {
background: $background;
color: $foreground;
font-family: "Noto Sans";
font-weight: 600;
font-size: 15px;
padding: 5px 15px;
border-radius: 50px;
}
.time {
.base {
font-weight: 700;
}
.extension {
font-weight: 500;
color: rgba($foreground, .7);
}
}
.workspaces {
padding: 5px 10px;
font-size: 22px;
button {
padding: 0px 2px;
}
.empty, .occupied {
color: $accent;
}
}
.widget.line-workspaces {
color: transparent;
padding: 0;
border-radius: 0;
font-size: 0;
button {
padding: 0 13px;
}
.empty {
background-color: $background;
}
.occupied {
background-color: $accent;
}
.focused {
background-color: $foreground;
}
}

67
res/eww-wayland/eww.yuck Normal file
View file

@ -0,0 +1,67 @@
(defwindow mainbar :monitor 0
:geometry (geometry :x "0%"
:y "0%"
:width "100%"
:height "30px"
:anchor "top center")
:stacking "fg"
:exclusive false
:focusable false
(bar))
(defvar time-extended false) ; for :run-while property of below variable
; when this turns true, the polling starts and
; var gets updated with given interval
(defpoll ptime :interval "1s"
:run-while !time-extended
`date +%H:%M`)
(defpoll petimea :interval "1s"
:run-while time-extended
`date "+%A, %d %B %Y "`)
(defpoll petimeb :interval "1s"
:run-while time-extended
`date "+:%S"`)
(deflisten ltitle "./scripts/title.sh")
(deflisten lworkspaces :initial "[]" "./scripts/workspaces.sh")
(deflisten lcurrent_workspace :initial "1" "./scripts/active-workspace.sh")
(defwidget bar []
(eventbox :onscroll "./scripts/scroll.sh {}"
(centerbox :orientation "h"
:class "bar"
(workspaces)
(title)
(time))))
(defwidget workspaces []
(box :class "widget workspaces"
:halign "start"
:valign "center"
:vexpand true
:hexpand true
(for workspace in lworkspaces
(eventbox :cursor "hand"
(button :class "${workspace.id == lcurrent_workspace ? "focused" : (workspace.windows > 0 ? "occupied" : "empty")}"
:onclick "hyprctl dispatch workspace ${workspace.id}"
"${workspace.id == lcurrent_workspace ? "" : (workspace.windows > 0 ? "" : "")}")))))
(defwidget title []
(literal :content ltitle))
(defwidget time_extension [text]
(label :text text
:class "extension"))
(defwidget time []
(button :onclick `eww update time-extended=${time-extended ? "false" : "true"}`
(box :orientation "horizontal"
:space-evenly false
:halign "end"
:class "widget time"
(time_extension :text {time-extended ? petimea : ""})
(label :text ptime
:class "base")
(time_extension :text {time-extended ? petimeb : ""}))))

View file

@ -0,0 +1,6 @@
#!/usr/bin/env sh
hyprctl monitors -j | jq '.[] | select(.focused) | .activeWorkspace.id'
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - |
stdbuf -o0 awk -F '>>|,' -e '/^workspace>>/ {print $2}' -e '/^focusedmon>>/ {print $3}'

View file

@ -0,0 +1,17 @@
#!/usr/bin/env sh
out () {
if [ -z "$1" ]; then
echo ""
else
echo "(box :class \"widget title\" :halign \"center\" :valign \"center\" :vexpand true :hexpand true (label :text \"$1\"))"
fi
}
init=$(hyprctl activewindow -j | jq --raw-output .title)
out "$init"
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | stdbuf -o0 awk -F '>>|,' '/^activewindow>>/{print $3}' | while read -r line ; do
trunc=$(echo $line | cut -c-85)
out "$trunc"
done

View file

@ -0,0 +1,11 @@
#!/usr/bin/env sh
spaces (){
WORKSPACE_WINDOWS=$(hyprctl workspaces -j | jq 'map({key: .id | tostring, value: .windows}) | from_entries')
seq 1 10 | jq --argjson windows "${WORKSPACE_WINDOWS}" --slurp -Mc 'map(tostring) | map({id: ., windows: ($windows[.]//0)})'
}
spaces
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | while read -r line; do
spaces
done