Bye Bye Polybar. Hello eww.

This commit is contained in:
Cedric Bonhomme 2024-02-06 01:57:30 +01:00
parent 32213b0619
commit bf72127620
7 changed files with 166 additions and 70 deletions

View file

@ -85,11 +85,12 @@ qdbus org.kde.kded5 /kded org.kde.kded5.loadModule appmenu
# Notifications
dunst &
# Bar
"${HOME}/.config/polybar/launch.sh" &
# "${HOME}/.config/polybar/launch.sh" &
# Manage desktops
"${HOME}/.local/share/go/bin/btops" &
# Widgets
eww daemon
eww open bar
eww open clock
#TODO#vdirsyncer sync &

View file

@ -45,7 +45,7 @@ constant = " "
" " = ["scrcpy"]
" " = ["p3x-onenote"]
" " = ["lxqt-config-appearance", "Kvantum Manager"]
" " = ["lxqt-config", "systemsettings"]
" " = ["lxqt-config", "systemsettings", "qt5ct", "qt6ct"]
" " = ["yuzu"]
" " = ["Olive"]
" " = ["k3b"]

View file

@ -11,7 +11,7 @@ window {
}
.clock {
margin: 20px;
font-size: 60px;
font-size: 20px;
}
.cover {
margin: 20px;
@ -61,18 +61,23 @@ window {
.full-music-bar {
border-radius: 0px;
}
.prefix {
color: $color5;
margin-right: 5px;
}
.separator {
color: $foreground;
margin: 0 10px;
}
.hour-side {
color: $foreground;
font-size: 20px;
}
.day-side {
color: $color4;
font-size: 20px;
}
.month-side,
.year-side {
color: $foreground;
font-size: 15px;
}
.cal {
min-height: 200px;
@ -167,68 +172,54 @@ calendar {
}
}
$foreground: #ffffff;
$grey: #aaaaaa;
$foreground-alt: #465059;
$background: #0e1419;
$black: #000000;
$red: #ff6565;
$green: #b8cc52;
$yellow: #e6c446;
$blue: #68d4ff;
$magenta: #ffa3aa;
$cyan: #36a3d9;
$white: #ffffff;
//* {
// all: unset;
//}
//window {
// background: $background;
//}
.bar {
font-family: IosevkaLyteTerm Nerd Font;
font-size: 16px;
margin: 0 10px;
}
.icon-module {
margin: 0 5px;
& > &__icon {
margin-right: 5px;
font-weight: bold;
font-size: 15px;
font-family: IosevkaLyteTerm Nerd Font;
}
min-height: 28px;
}
.inline-clock {
margin-right: 1em;
}
.xtitle {
font-family: IosevkaLyteTerm Nerd Font;
background-color: rgba($color5,70%);
border-bottom: 3px solid $color5;
border-radius: 10px;
color: $color0;
padding: 0 1em;
}
.workspaces {
font-family: IosevkaLyteTerm Nerd Font;
font-size: 12px;
margin-right: 20px;
font-size: 15px;
margin-left: 1em;
min-height: 28px;
button {
margin: 0px 3px;
border-radius: 10px;
padding-left: 1em;
padding-right: 1em;
}
.occupied {
color: $grey;
color: #dfdfdf;
}
.focused {
color: $white;
color: $color0;
background-color: rgba($color5,70%);
border-bottom: 3px solid $color5;
}
.urgent {
color: $red;
color: #bd2c40;
}
.empty {
padding-top: 2px;
color: $foreground-alt;
font-size: 10px;
// font-family: "Font Awesome 5 Free Regular"
color: #777;
}
}

View file

@ -1,3 +1,33 @@
(deflisten workspaces
`workspaces`)
(deflisten cover-path :initial "/tmp/cover.png"
`inotifywait /tmp/cover.png -m -e CLOSE_WRITE --format %w --quiet`)
(deflisten music :initial "Title"
`playerctl metadata --format '{"title":"{{title}}","artist":"{{artist}}","album":"{{album}}"}' -F`)
(deflisten music-position :initial "{'position':'0','duration':' '}"
`playerctl metadata --format '{"elapsed":"{{duration(position)}}","total":"{{duration(mpris:length)}}","elapsed-ms":{{position}},"total-ms":{{mpris:length}}}' -F`)
(defpoll xtitle :interval "0.5s" :initial ""
`xdotool getactivewindow getwindowname`)
(defpoll music-position-percent :interval "1s" :initial "0"
`mixer position`)
(defpoll mascot :interval "30m" :initial "images/ikuyo.png"
`fish -c 'random choice "images/bocchi.png" "images/ikuyo.png" "images/ryo.png" "images/nijika.png"'`)
(defpoll time :interval "10s"
`date +'{"hour":"%H","min":"%M"}'`)
(defpoll date :interval "30m"
`date +'{"year":"%Y","month":"%m","day":"%d"}'`)
(defpoll cal :interval "30m"
`khal list | sed -e "s/Today/Aujourd'hui/g" -e "s/Tomorrow/Demain/g"`)
(defwidget clock []
(box :orientation "h" :class "clock" :space-evenly "false" :spacing 0
(image :path {mascot} :image-width 90 :image-height 225)
@ -26,29 +56,49 @@
)
)
(deflisten cover-path :initial "/tmp/cover.png"
`inotifywait /tmp/cover.png -m -e CLOSE_WRITE --format %w --quiet`)
(defwidget workspaces []
(literal :content workspaces)
)
(deflisten music :initial "Title"
`playerctl metadata --format '{"title":"{{title}}","artist":"{{artist}}","album":"{{album}}"}' -F`)
(defwidget inline-clock []
(box :orientation "h" :class "inline-clock" :space-evenly "false" :spacing 0 :halign "end"
(label :class "prefix" :text " ")
(box :class "hour-side" {time.hour})
(label :class "" :text ":")
(box :class "day-side" {time.min})
)
)
(deflisten music-position :initial "{'position':'0','duration':' '}"
`playerctl metadata --format '{"elapsed":"{{duration(position)}}","total":"{{duration(mpris:length)}}","elapsed-ms":{{position}},"total-ms":{{mpris:length}}}' -F`)
(defwidget inline-music []
(box :orientation "h" :class "inline-music" :space-evenly "false" :spacing 0 :halign "end"
(label :class "prefix" :text " ")
(label :class "" :text {music.title} :wrap "false" :limit-width 20 :truncate-left "true" :justify "fill")
(label :class "separator" :text "")
(box :class "day-side" {music-position.elapsed})
(label :class "separator" :text "")
(box :class "" {music-position.total})
)
)
(defpoll music-position-percent :interval "1s" :initial "0"
`mixer position`)
(defwidget xtitle []
(box :orientation "h" :class "xtitle" :space-evenly "false" :spacing 10 :halign "end"
(label :class "" :text {xtitle} :wrap "false" :limit-width 60)
)
)
(defpoll mascot :interval "30m" :initial "images/ikuyo.png"
`fish -c 'random choice "images/bocchi.png" "images/ikuyo.png" "images/ryo.png" "images/nijika.png"'`)
(defpoll time :interval "10s"
`date +'{"hour":"%H","min":"%M"}'`)
(defpoll date :interval "30m"
`date +'{"year":"%Y","month":"%m","day":"%d"}'`)
(defpoll cal :interval "30m"
`khal list | sed -e "s/Today/Aujourd'hui/g" -e "s/Tomorrow/Demain/g"`)
(defwidget bar []
(box :class "bar" :orientation "v" :space-evenly "false" :spacing 0
(progress-bar)
(centerbox :class "bar" :orientation "h"
(workspaces)
(xtitle)
(box :orientation "h" :space-evenly "false" :spacing 10 :halign "end"
(inline-music)
(inline-clock)
)
)
)
)
(defwindow calendar
:monitor 0
@ -98,3 +148,16 @@
:anchor "top right")
(cover)
)
(defwindow bar
:monitor 0
:stacking "bg"
:windowtype "desktop"
:geometry (geometry
:x "7px"
:y "3px"
:height "28px"
:width "1904px"
:anchor "top left")
(bar)
)

View file

@ -21,7 +21,7 @@ margin-bottom = 5
[bar/default]
enable_ipc = true
bottom = false
bottom = true
width = 100%:-14
#width = 90%
height = 28

View file

@ -143,7 +143,6 @@ position() {
toggle() {
playerctl --player="$(current_sink)" play-pause
eww open cover
eww open progress-bar
}
prev() {
@ -159,7 +158,6 @@ next() {
stop() {
playerctl --player="$(current_sink)" stop
eww close cover
eww close progress-bar
}
main() {

43
script/bin/workspaces Executable file
View file

@ -0,0 +1,43 @@
#!/usr/bin/env bash
# Checks if a list ($1) contains an element ($2)
contains() {
for e in $1; do
[ "$e" == "$2" ] && echo 1 && return
done
echo 0
}
print_workspaces() {
buf=""
desktops=($(bspc query -D))
desktops_icons=($(bspc query -D --names))
focused_desktop=$(bspc query -D -d focused)
occupied_desktops=$(bspc query -D -d .occupied)
urgent_desktops=$(bspc query -D -d .urgent)
for i in "${!desktops[@]}"; do
if [ "$(contains "$focused_desktop" "${desktops[$i]}")" -eq 1 ]; then
class="focused"
elif [ "$(contains "$occupied_desktops" "${desktops[$i]}")" -eq 1 ]; then
class="occupied"
elif [ "$(contains "$urgent_desktops" "${desktops[$i]}")" -eq 1 ]; then
class="urgent"
else
class="empty"
fi
ws=${desktops[$i]}
icon=${desktops_icons[$i]}
buf="$buf (eventbox :cursor \"hand\" (button :class \"$class\" :onclick \"bspc desktop -f $ws\" \"$icon \"))"
done
echo "(box :class \"workspaces\" :spacing 0 :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