This commit is contained in:
LavaDesu 2024-01-16 01:08:18 +07:00
parent 4667653ed1
commit d149a7704b
8 changed files with 41 additions and 117 deletions

View file

@ -1,6 +1,6 @@
# Depends on bspwm
{ pkgs, ... }: {
home.packages = with pkgs; [ xtitle ];
home.packages = with pkgs; [ socat ];
programs.eww = {
enable = true;
configDir = ../../res/eww;

View file

@ -1,5 +1,5 @@
self: super: {
eww = super.eww.overrideAttrs (old: rec {
eww = (super.eww.override { withWayland = true; }).overrideAttrs (old: rec {
patches = old.patches ++ [
# Use normal scroll events instead of smooth scroll ( due to https://bugzilla.gnome.org/show_bug.cgi?id=675959 )
./patches/eww.patch

View file

@ -1,14 +1,3 @@
(defwindow linebar :monitor 0
:geometry (geometry :x "30px"
:y "0%"
:width "100%"
:height "2px"
:anchor "top center")
:stacking "fg"
:windowtype "dock"
:wm-ignore false
(wlinebar))
(defwindow mainbar :monitor 0
:geometry (geometry :x "0%"
:y "0%"
@ -16,8 +5,8 @@
:height "30px"
:anchor "top center")
:stacking "fg"
:windowtype "dock"
:wm-ignore false
:exclusive false
:focusable false
(bar))
(defvar time-extended false) ; for :run-while property of below variable
@ -34,8 +23,6 @@
:run-while time-extended
`date "+:%S"`)
(deflisten lworkspaces "./scripts/workspaces.sh")
(deflisten llineworkspaces "./scripts/line-workspaces.sh")
(deflisten ltitle "./scripts/title.sh")
(defwidget bar []
@ -46,15 +33,19 @@
(title)
(time))))
(defwidget wlinebar []
(eventbox :onscroll "./scripts/scroll.sh {}"
(line_workspaces)))
(deflisten workspaces :initial "[]" "bash ~/.config/eww/scripts/workspaces.sh")
(deflisten current_workspace :initial "1" "bash ~/.config/eww/scripts/active-workspace.sh")
(defwidget workspaces []
(literal :content lworkspaces))
(defwidget line_workspaces []
(literal :content llineworkspaces))
(box :class "widget workspaces"
:halign "start"
:valign "center"
:vexpand true
:hexpand true
(for workspace in workspaces
(eventbox :cursor "hand"
(button :class "${workspace.id == current_workspace ? "focused" : (workspace.windows > 0 ? "occupied" : "empty")}"
:onclick "hyprctl dispatch workspace ${workspace.id}"
"${workspace.id == current_workspace ? "" : (workspace.windows > 0 ? "" : "")}")))))
(defwidget title []
(literal :content ltitle))
@ -72,6 +63,5 @@
(time_extension :text {time-extended ? petimea : ""})
(label :text ptime
:class "base")
(time_extension :text {time-extended ? petimeb : ""})
)))
(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

@ -1,43 +0,0 @@
#!/usr/bin/env sh
# Checks if a list ($1) contains an element ($2)
contains() {
for e in $1; do
[ "$e" -eq "$2" ] && echo 1 && return
done
echo 0
}
print_workspaces() {
buf=""
desktops=$(bspc query -D --names)
focused_desktop=$(bspc query -D -d focused --names)
occupied_desktops=$(bspc query -D -d .occupied --names)
urgent_desktops=$(bspc query -D -d .urgent --names)
for d in $desktops; do
if [ "$(contains "$focused_desktop" "$d")" -eq 1 ]; then
ws=$d
class="focused"
elif [ "$(contains "$occupied_desktops" "$d")" -eq 1 ]; then
ws=$d
class="occupied"
elif [ "$(contains "$urgent_desktops" "$d")" -eq 1 ]; then
ws=$d
class="urgent"
else
ws=$d
class="empty"
fi
buf="$buf (eventbox :cursor \"hand\" (button :class \"$class\" :onclick \"bspc desktop -f $ws\" \"\"))"
done
echo "(box :class \"widget line-workspaces\" :halign \"start\" :valign \"center\" :vexpand true :hexpand true $buf)"
}
# Listen to bspwm changes
print_workspaces
bspc subscribe desktop node_transfer | while read -r _ ; do
print_workspaces
done

View file

@ -1,10 +1,17 @@
#!/usr/bin/env sh
xtitle -s | while read -r line ; do
trunc=$(echo $line | cut -c-85)
if [ -z "$line" ]; then
out () {
if [ -z "$1" ]; then
echo ""
else
echo "(box :class \"widget title\" :halign \"center\" :valign \"center\" :vexpand true :hexpand true (label :text \"${trunc}\"))"
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

@ -1,47 +1,11 @@
#!/usr/bin/env sh
# Checks if a list ($1) contains an element ($2)
contains() {
for e in $1; do
[ "$e" -eq "$2" ] && echo 1 && return
done
echo 0
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)})'
}
print_workspaces() {
buf=""
desktops=$(bspc query -D --names)
focused_desktop=$(bspc query -D -d focused --names)
occupied_desktops=$(bspc query -D -d .occupied --names)
urgent_desktops=$(bspc query -D -d .urgent --names)
for d in $desktops; do
if [ "$(contains "$focused_desktop" "$d")" -eq 1 ]; then
ws=$d
icon=""
class="focused"
elif [ "$(contains "$occupied_desktops" "$d")" -eq 1 ]; then
ws=$d
icon=""
class="occupied"
elif [ "$(contains "$urgent_desktops" "$d")" -eq 1 ]; then
ws=$d
icon=""
class="urgent"
else
ws=$d
icon=""
class="empty"
fi
buf="$buf (eventbox :cursor \"hand\" (button :class \"$class\" :onclick \"bspc desktop -f $ws\" \"$icon\"))"
done
echo "(box :class \"widget workspaces\" :halign \"start\" :valign \"center\" :vexpand true :hexpand true $buf)"
}
# Listen to bspwm changes
print_workspaces
bspc subscribe desktop node_transfer | while read -r _ ; do
print_workspaces
spaces
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | while read -r line; do
spaces
done

View file

@ -37,7 +37,7 @@
# spicetify
dunst
# eww
eww
# picom
#
# xorg