user/eww: init
This commit is contained in:
parent
ed93b93c43
commit
5a4b56580b
12 changed files with 202 additions and 3 deletions
49
res/eww/eww.scss
Normal file
49
res/eww/eww.scss
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
58
res/eww/eww.yuck
Normal file
58
res/eww/eww.yuck
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
(defwindow mainbar :monitor 0
|
||||
:geometry (geometry :x "0%"
|
||||
:y "0%"
|
||||
:width "100%"
|
||||
:height "30px"
|
||||
:anchor "top center")
|
||||
:stacking "fg"
|
||||
:windowtype "dock"
|
||||
:wm-ignore 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 lworkspaces "./scripts/workspaces.sh")
|
||||
(deflisten ltitle "./scripts/title.sh")
|
||||
|
||||
(defwidget bar []
|
||||
(eventbox :onscroll "./scripts/scroll.sh {}"
|
||||
(centerbox :orientation "h"
|
||||
:class "bar"
|
||||
(workspaces)
|
||||
(title)
|
||||
(time))))
|
||||
|
||||
(defwidget workspaces []
|
||||
(literal :content lworkspaces))
|
||||
|
||||
(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 : ""})
|
||||
)))
|
||||
|
||||
3
res/eww/scripts/scroll.sh
Executable file
3
res/eww/scripts/scroll.sh
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env sh
|
||||
translated=$([ "$1" == "up" ] && echo "prev" || echo "next")
|
||||
bspc desktop -f $translated
|
||||
10
res/eww/scripts/title.sh
Executable file
10
res/eww/scripts/title.sh
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
xtitle -s | while read -r line ; do
|
||||
trunc=$(echo $line | cut -c-85)
|
||||
if [ -z "$line" ]; then
|
||||
echo ""
|
||||
else
|
||||
echo "(box :class \"widget title\" :halign \"center\" :valign \"center\" :vexpand true :hexpand true (label :text \"${trunc}\"))"
|
||||
fi
|
||||
done
|
||||
47
res/eww/scripts/workspaces.sh
Executable file
47
res/eww/scripts/workspaces.sh
Executable file
|
|
@ -0,0 +1,47 @@
|
|||
#!/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
|
||||
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
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue