1
0

add eww config

This commit is contained in:
2024-05-15 10:23:34 +02:00
parent 3dbc0a4ac8
commit d0a55a7437
10 changed files with 507 additions and 0 deletions

3
.config/eww/active-window Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env bash
i3-msg -t subscribe -m '{"type":"window"}' | jq --unbuffered -r .container.name | cut -c 1-24

181
.config/eww/eww.scss Normal file
View File

@@ -0,0 +1,181 @@
$primary: #d64937;
$secondary: #8abeb7;
$black: #000;
$red: #ff757a;
$dimred: mix($red, $black);
$orange: #fc9a6d;
$dimorange: mix($orange, $black);
$yellow: #f5be61;
$dimyellow: mix($yellow, $black);
$gray: #888;
$dimgray: mix($gray, $black);
$blue: #42ddd9;
$dimblue: mix($blue, $black);
$green: #7bdbb5;
$dimgreen: mix($green, $black);
$magenta: #d968c2;
$cyan: #5dc5ee;
$bg-color: rgba($black, 0.65);
$fg-color: #eee;
$hover: transparentize($primary, 0.4);
$border-color: rgba(white, 0.03);
$radius: 3px;
@mixin button() {
margin: 0;
padding: 0 5px;
color: $fg-color;
border: 0;
border-radius: $radius;
background-color: transparent;
background-image: none;
box-shadow: none;
label {
text-shadow: none;
}
&:focus {
color: $fg-color;
background-color: $hover;
}
&:hover {
color: $fg-color;
background-color: $hover;
}
&:active,
&.active {
color: $fg-color;
background-color: $primary;
}
}
.background {
background-color: $bg-color;
}
.bar {
padding: 4px 10px;
font-family: "JetBrains Mono Nerd Font";
}
.workspaces {
color: #666;
button {
@include button;
color: mix($fg-color, $black);
&.visible {
color: $fg-color;
font-weight: bold;
}
}
.workspace-visible {
color: #fff;
font-weight: bold;
}
.workspace-active {
color: #fff;
background: transparentize(#d64937, 0.0);
}
}
.active-window {
color: $gray;
}
.player {
button {
@include button;
padding-left: 8px;
padding-right: 8px;
&.play label {
padding-right: 4px;
}
}
}
.metric {
progressbar {
padding: 6px 6px 6px 10px;
trough {
min-width: 100px;
min-height: 14px;
background-color: $dimgray;
border: 0;
progress {
background-color: $gray;
min-height: 14px;
border: 0;
}
}
}
&.disk {
label { color: $red; }
trough {
background-color: $dimred;
progress { background-color: $red; }
}
}
&.memory {
label { color: $orange; }
trough {
background-color: $dimorange;
progress { background-color: $orange; }
}
}
&.cpu {
label { color: $yellow; }
trough {
background-color: $dimyellow;
progress { background-color: $yellow; }
}
}
}
.volume {
label { color: $green; }
scale {
padding: 6px 6px 6px 6px;
trough {
min-width: 100px;
min-height: 12px;
background-color: $dimgreen;
border: 1px solid $dimgreen;
border-radius: $radius;
slider {
background-color: white;
background-image: none;
border: 0;
}
highlight {
background-color: $green;
border: 0;
}
}
}
}
.sound-control {
padding: 8px;
button {
@include button;
padding: 2px 5px;
}
}

260
.config/eww/eww.yuck Normal file
View File

@@ -0,0 +1,260 @@
; https://github.com/trapano-monogamo/my_eww_bar/blob/master/eww-bar/eww.yuck
; https://github.com/natperron/dotfiles/tree/main/.config/eww
; https://github.com/Aylur/dotfiles/tree/eww/.config/eww
; https://github.com/gh0stzk/dotfiles/blob/master/config/bspwm/eww/calendar/calendar.yuck
(defvar output "DP-0")
(defvar workspaces "[]")
(defpoll datetime
:interval "1s"
:initial "{\"weekday\": \"\", \"date\": \"\", \"time\": \"\"}"
`date +'{\"weekday\": \"%a\", \"date\": \"%d.%b\", \"time\": \"%H:%M\"}'`
)
(defvar show-date false)
(defpoll volume
:interval "1s"
:initial "0"
`~/.config/eww/get-volume`
)
(defpoll mute
:interval "1s"
:initial false
`~/.config/eww/get-mute`
)
(defpoll mpd-status
:interval "1s"
:initial "{}"
`~/.config/eww/mpd-status`
)
(deflisten active-window
:initial ""
`~/.config/eww/active-window`
)
(defpoll pulse-sinks
:interval "1s"
:initial "[]"
`~/.config/eww/list-sinks`
)
(defvar dummy "")
(defwindow primary
:monitor "DP-0"
:windowtype "dock"
:wm-ignore false
:geometry (geometry :width "100%" :anchor "top center")
:reserve (struts :side "top" :distance "10%")
(primary_bar)
)
(defwindow secondary
:monitor "HDMI-0"
:windowtype "dock"
:wm-ignore false
:geometry (geometry :width "100%" :anchor "top center")
:reserve (struts :side "top" :distance "10%")
(secondary_bar)
)
(defwidget primary_bar []
(centerbox
:class "bar bar-primary"
:orientation "horizontal"
:hexpand false
(left :monitor "DP-0")
(center)
(right :monitor "DP-0")
)
)
(defwidget secondary_bar []
(centerbox
:class "bar bar-secondary"
:orientation "horizontal"
:hexpand false
(left :monitor "HDMI-0")
(center)
(right :monitor "HDMI-0")
)
)
(defwidget left [monitor]
(box
:spacing 20
:space-evenly false
(workspaces :monitor monitor)
(label :text dummy)
; (active-window :monitor monitor)
)
)
(defwidget workspaces [monitor]
(box
:class "workspaces"
:space-evenly false
(for workspace in workspaces
(eventbox
:cursor "pointer"
:visible {workspace.output == monitor}
(button
:class "${workspace.focused ? "active" : ""} ${workspace.visible ? "visible" : ""}"
:onclick "i3-msg workspace ${workspace.name}"
"${workspace.name}"
)
)
)
)
)
(defwidget active-window [monitor]
(box
:class "active-window"
(label :text "${active-window}")
)
)
(defwidget center []
(box
:spacing 20
:space-evenly false
(player)
)
)
(defwidget player []
(box
:visible {mpd-status.status != "[empty]"}
:class "player"
:spacing 6
:space-evenly false
(label :text "${mpd-status.song} (${mpd-status.artist})" )
(box
(button
:onclick "mpc prev"
""
)
(button
:class "play"
:onclick "mpc toggle"
"${mpd-status.status == "[playing]" ? "" : ""}"
)
(button
:onclick "mpc next"
""
)
)
)
)
(defwidget metric [class label value tooltip]
(box
:orientation "h"
:class "metric ${class}"
:space-evenly false
:tooltip tooltip
(box :width 16 label)
(progress :value value)
)
)
(defwidget right [monitor]
(box
:halign "end"
:spacing 20
:space-evenly false
(metric
:class "disk"
:label "󰋊"
:value { EWW_DISK["/"].used_perc }
:tooltip "${ round(EWW_DISK["/"].free / 1024 / 1024 / 1024, 2) } GiB frei")
(metric
:class "memory"
:label ""
:value { EWW_RAM.used_mem_perc }
:tooltip "${ round(EWW_RAM.free_mem / 1024 / 1024 / 1024, 2) } GiB frei")
(metric
:class "cpu"
:label ""
:value { EWW_CPU.avg }
:tooltip "${ round(EWW_CPU.avg, 2) }% benutzt")
(sound)
(systray
:spacing 4
:icon-size 20)
(time)
)
)
(defwidget revealer-on-hover [var varname ?class ?duration ?transition]
(box :class "${class} revealer-on-hover"
:orientation "h"
:space-evenly false
(eventbox :class "eventbox"
:onhover "eww update ${varname}=true"
:onhoverlost "eww update ${varname}=false"
(box :space-evenly false
(children :nth 0)
(revealer :reveal var
:transition {transition ?: "slideright"}
:duration {duration ?: "500ms"}
(children :nth 1)
)
(children :nth 2)
)
)
)
)
(defwidget sound []
(box
:class "volume"
:space-evenly false
:tooltip "${volume}%"
(eventbox
:onclick "~/.config/eww/mute-volume"
:onrightclick "eww open --toggle --arg monitor=${output} sound-control"
(label
:width 16
:text "${mute ? "󰝟" : volume <= 33 ? "󰕿" : volume <= 66 ? "󰖀" : "󰕾"}"
)
)
(scale
:min 0
:max 100
:value {volume}
:onchange "~/.config/eww/set-volume {}"
)
)
)
(defwidget time []
(revealer-on-hover
:var show-date
:varname "show-date"
:transition "slideleft"
(label :text "${datetime.weekday} ")
(label :text "${datetime.date} ")
(label :text "${datetime.time}")
)
)
(defwindow sound-control [monitor]
:monitor monitor
:geometry (geometry :x "40%" :y "40" :anchor "center top")
:wm-ignore true
(box
:class "sound-control"
:orientation "v"
(for sink in pulse-sinks
(button
:halign "start"
:onclick "~/.config/eww/move-sink-inputs ${sink.index}"
(box
:spacing 10
:space-evenly false
(label :style "min-width: 16px" :text "${sink.state == "RUNNING" ? "" : ""}")
(label :text "${sink.description}")
)
)
)
)
)

4
.config/eww/get-mute Executable file
View File

@@ -0,0 +1,4 @@
#!/usr/bin/env bash
mute="$(pactl get-sink-mute @DEFAULT_SINK@ | sed 's/.*\(ja\|nein\)/\1/')"
[ "ja" = "$mute" ] && echo true || echo false

3
.config/eww/get-volume Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env bash
pactl get-sink-volume @DEFAULT_SINK@ | awk -F '[^0-9]+' '/left:/{print $3}'

3
.config/eww/list-sinks Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env bash
pactl -f json list sinks

8
.config/eww/move-sink-inputs Executable file
View File

@@ -0,0 +1,8 @@
#!/usr/bin/env bash
sink="$1"
pactl set-default-sink "$sink"
pactl list short sink-inputs | cut -f1 | while read id; do
pactl move-sink-input "$id" "$sink"
done

37
.config/eww/mpd-status Executable file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/env bash
STATUS="$(mpc status)"
if [ $(echo "$STATUS" | wc -l | tr -d ' ') == "1" ]; then
status="[empty]"
else
artist=$(echo "$STATUS" | awk -F" - " 'NR==1{print $1}')
song=$(echo "$STATUS" | awk -F" - " 'NR==1{print $2}')
status=$(echo "$STATUS" | awk 'NR==2{print $1}')
track_data=$(echo "$STATUS" | awk 'NR==2{print $2}')
current_track_number=$(echo "$track_data" | awk -F"/" '{print $1}')
total_track_count=$(echo "$track_data" | awk -F"/" '{print $2}')
elapsed=$(echo "$STATUS" | awk 'NR==2{print $3}')
current_time=$(echo "${elapsed}" | awk -F"/" '{print $1}')
track_length=$(echo "${elapsed}" | awk -F"/" '{print $2}')
volume=$(
echo "$STATUS" \
| awk -F":" 'NR==3{print $2}' \
| awk '{print $1}'
)
fi
echo "{
\"artist\": \"${artist}\",
\"song\": \"${song}\",
\"elapsed\": \"${elapsed}\",
\"currentTime\": \"${current_time}\",
\"trackLength\": \"${track_length}\",
\"currentTrackNumber\": \"${current_track_number/\#/}\",
\"totalTrackCount\": \"${total_track_count}\",
\"status\": \"${status}\",
\"volume\": \"${volume}\"
}"

3
.config/eww/mute-volume Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env bash
pactl set-sink-mute @DEFAULT_SINK@ toggle

5
.config/eww/set-volume Executable file
View File

@@ -0,0 +1,5 @@
#!/usr/bin/env bash
volume="$1"
pactl set-sink-volume @DEFAULT_SINK@ "${volume}%"