Introduces eww bar

This commit is contained in:
Michel Fedde 2025-11-11 17:44:06 +01:00
parent 75bc7eb6a7
commit e58899e4ae
30 changed files with 279 additions and 1147 deletions

View file

@ -0,0 +1,40 @@
(include "./widgets/bar/elements/time.yuck")
(include "./widgets/bar/elements/workspaces.yuck")
(include "./widgets/bar/elements/audio.yuck")
(defwidget bar []
(centerbox
:class "bar"
(box
(bar-workspaces)
)
(box
(bar-time)
)
(box
:space-evenly false
:halign "end"
:spacing 10
(bar-audio)
(systray
:class "widget default-padding"
:space-evenly false
:spacing 10
:hexpand false
:halign "end"
)
)
)
)
(defwindow bar [monitor]
:monitor {monitor}
:geometry (geometry
:x "0px"
:y "10px"
:width "100%"
:height "0px"
:anchor "top center")
:stacking "fg"
(bar)
)

View file

@ -0,0 +1,22 @@
(defpoll bar-audio-icon :interval "1s" :initial "" `~/.config/eww/widgets/bar/scripts/audio.sh`)
(defpoll bar-audio-volume :interval "1s" :initial "" `pactl --format="json" get-sink-volume $(pactl get-default-sink) | jq '.volume | map(.value) | length as $amount | add / $amount'`)
(defwidget bar-audio []
(eventbox
:onclick "hyprctl dispatch exec pavucontrol"
:onrightclick "hyprctl dispatch exec rofi -show pactl"
(box
:hexpand false
:halign "end"
:space-evenly false
:spacing 20
:class "widget default-padding"
{bar-audio-icon}
(progress
:valign "center"
:value {(bar-audio-volume / 65536) * 100}
)
)
)
)

View file

@ -0,0 +1,8 @@
(defpoll bar-time-display :interval "1s" :initial "" `date +"󰃭 %d  %R"`)
(defwidget bar-time []
(box
:class "widget default-padding"
{bar-time-display}
)
)

View file

@ -0,0 +1,76 @@
(defpoll bar-workspace-data :interval "0.1s" :initial "[]" `~/.config/eww/widgets/bar/scripts/workspaces.sh`)
(defwidget bar-workspaces []
(box
:class "widget workspaces"
:space-evenly false
:hexpand false
:halign "start"
(for workspace in bar-workspace-data
(eventbox
:onclick "${EWW_CMD} open bar-workspace-window --arg workspaceId=${workspace.id}"
:cursor "pointer"
(box
:space-evenly false
:spacing 10
:class "workspace ${workspace.activeOnAnyScreen ? "active": ""} ${workspace.activeOnCurrentScreen ? "current": ""}"
(box
:space-evenly false
:spacing 10
(label
:text {workspace.name}
)
(box
:spacing 10
(for window in {workspace.windows}
(label
:text {window.icon}
)
)
)
)
)
)
)
)
)
(defwindow bar-workspace-window [workspaceId]
:monitor 1
:geometry (geometry
:x "10px"
:y "50px"
:width "512px"
:height "0px"
:anchor "top left")
:stacking "fg"
(box
(for workspace in bar-workspace-data
(box
:orientation "v"
:vexpand false
:valign "start"
:class "widget default-padding"
:space-evenly false
:spacing 10
:visible {workspaceId == workspace.id}
(for window in {workspace.windows}
(eventbox
:cursor "pointer"
:onclick "hyprctl dispatch focuswindow pid:${window.pid} && ${EWW_CMD} close bar-workspace-window"
:onrightclick "${EWW_CMD} close bar-workspace-window"
(label
:halign "start"
:text "${window.icon} ${window.title}"
:truncate false
)
)
)
)
)
)
)

View file

@ -0,0 +1,6 @@
{
"alsa_output.pci-0000_08_00.0.iec958-stereo": "󱟛",
"alsa_output.usb-Razer_Razer_Nari-00.pro-output-1": "",
"alsa_output.usb-Razer_Razer_Nari-00.pro-output-0": "",
"bluez_output.B4_9A_95_D3_B3_9E.1": "󰂯 󱟛"
}

View file

@ -0,0 +1,5 @@
#!/bin/bash
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
cat "$SCRIPT_DIR/audio-icons.json" | jq -r --arg currentSink "$(pactl get-default-sink)" '.[$currentSink]'

View file

@ -0,0 +1,39 @@
{
"firefox|org.mozilla.firefox|librewolf|floorp|mercury-browser|[Cc]achy-browser": "",
"kitty|konsole|com.mitchellh.ghostty": "",
"kitty-dropterm": "",
"Chromium|Thorium": "",
"zen": "󰰷",
"thunar": "󰝰",
"[Tt]hunderbird|[Tt]hunderbird-esr": "",
"eu.betterbird.Betterbird": "",
"discord|[Ww]ebcord|Vesktop": "",
"subl": "󰅳",
"mpv": "",
"celluloid|Zoom": "",
"Cider": "󰎆",
"virt-manager": "",
".virt-manager-wrapped": "",
"codeblocks": "󰅩",
"mousepad": "",
"libreoffice-writer": "",
"libreoffice-startcenter": "󰏆",
"com.obsproject.Studio": "",
"polkit-gnome-authentication-agent-1": "󰒃",
"nwg-look": "",
"waterfox|waterfox-bin": "",
"microsoft-edge": "",
"vlc": "󰕼",
"steam": "",
"microsoftteams-nativefier-6234c0": "󰊻",
"org.remmina.Remmina": "",
"com.github.th_ch.youtube_music": "",
"feishin": "",
"ONLYOFFICE": "",
"Beeper": "󰭹",
"blender": "",
"heroic": "",
"net.lutris.Lutris": "",
"Unity": "",
"jetbrains-rider|jetbrains-phpstorm": ""
}

View file

@ -0,0 +1,17 @@
$workspaces | map({
id: .id,
name: .name,
activeOnCurrentScreen: .id == $activeWorkspace.id,
activeOnAnyScreen: (.id as $workspaceId | any($monitors[]; .activeWorkspace.id == $workspaceId)),
windows: (
.id as $workspaceId | $clients | map ( select(.workspace.id == $workspaceId) | {
class: .class,
title: .title,
pid: .pid,
icon: (
.class as $class |
($clientIcons | keys | .[] | select(. as $regex | $class | test($regex)) | $clientIcons[.]) // " "
)
})
)
}) | sort_by(.id)

View file

@ -0,0 +1,11 @@
#!/bin/bash
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
jq --null-input \
--argjson activeWorkspace "$(hyprctl -j activeworkspace)" \
--argjson workspaces "$(hyprctl -j workspaces)" \
--argjson monitors "$(hyprctl -j monitors)" \
--argjson clients "$(hyprctl -j clients)" \
--argjson clientIcons "$(cat "$SCRIPT_DIR/clientIcons.json")" \
--from-file "$SCRIPT_DIR/workspaces.jq"

View file

@ -0,0 +1,22 @@
.bar {
margin: 0 10px;
.default-padding {
padding: 0.5rem 1rem;
}
}
.workspaces {
padding-right: 1rem;
.workspace {
padding: 0.5 1rem;
border-radius: $border-radius;
&.active {
box-shadow: 0 -1px 0 0 green inset;
}
&.current {
box-shadow: 0 -1px 0 0 yellow inset;
}
}
}

View file

@ -94,11 +94,11 @@
(defwindow media
:monitor 1
:geometry (geometry
:x "10px"
:y "50px"
:width "0px"
:height "10%"
:anchor "top right")
:x "10px"
:y "50px"
:width "0px"
:height "10%"
:anchor "top right")
:stacking "fg"
(media-control)
)