refactor: eww bar modules

This commit is contained in:
hesam-init 2024-06-30 21:03:09 +03:30
parent ae8e8f956f
commit fe323d6f63
11 changed files with 76 additions and 45 deletions

View file

@ -1,6 +1,9 @@
(include "./src/widgets/_revealer.yuck")
(include "./src/_definitions.yuck") (include "./src/_definitions.yuck")
(include "./src/-components/_helpers.yuck")
(include "./src/-modules/_language.yuck")
(include "./src/-modules/_workspaces.yuck")
(include "./setups/sidebar.yuck") (include "./setups/sidebar.yuck")
(include "./setups/panel.yuck") (include "./setups/panel.yuck")
(include "./src/wallpapers/main.yuck") (include "./src/wallpapers/main.yuck")

View file

@ -0,0 +1,6 @@
#!/bin/bash
hyprctl devices | grep -A 3 "$DEVICE$" | grep "active keymap:" | tail -n 1 | awk '{print toupper(substr($3,1,2))}'
socat -u UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - |
stdbuf -o0 awk -F '>>|,' -e '/^activelayout>>/ {print toupper(substr($3, 1, 2))}'

View file

@ -0,0 +1,10 @@
#!/bin/bash
hyprctl \
--batch "$(
hyprctl devices -j |
jq -r '.keyboards[] | .name' |
while IFS= read -r keyboard; do
printf '%s %s %s;' 'switchxkblayout' "${keyboard}" 'next'
done
)"

View file

@ -24,14 +24,14 @@ control() {
LOCK_FILE="$HOME/.config/eww-control.lock" LOCK_FILE="$HOME/.config/eww-control.lock"
run() { run() {
${EWW_BIN} open control_panel ${EWW_BIN} open ControlPanel
} }
if [[ ! -f "$LOCK_FILE" ]]; then if [[ ! -f "$LOCK_FILE" ]]; then
touch "$LOCK_FILE" touch "$LOCK_FILE"
run && echo "ok good!" run && echo "ok good!"
else else
${EWW_BIN} close control_panel ${EWW_BIN} close ControlPanel
rm "$LOCK_FILE" && echo "closed" rm "$LOCK_FILE" && echo "closed"
fi fi
} }

View file

@ -1,4 +1,4 @@
(defwidget hovered-sign [var] (defwidget HoveredSign [var]
(box :space-evenly false (box :space-evenly false
(revealer :reveal {!var} (revealer :reveal {!var}
:duration "100ms" :duration "100ms"
@ -9,7 +9,7 @@
:transition "slideleft" :transition "slideleft"
(children :nth 1)))) (children :nth 1))))
(defwidget reveal_on_hover [var varname ?class ?duration ?transition] (defwidget RevealOnHover [var varname ?class ?duration ?transition]
(box (box
:class "${class}" :class "${class}"
:orientation "v" :orientation "v"
@ -33,7 +33,7 @@
) )
(defwidget clickbox [var varname ?class ?duration ?transition] (defwidget ClickBox [var varname ?class ?duration ?transition]
(box :class "${class} clickbox" :orientation "h" :space-evenly false (box :class "${class} clickbox" :orientation "h" :space-evenly false
(button :onclick "eww update ${varname}=${ var ? false : true }" (button :onclick "eww update ${varname}=${ var ? false : true }"
(children :nth 0)) (children :nth 0))

View file

@ -0,0 +1,11 @@
(defwidget Clock []
(eventbox
:cursor "pointer"
:onclick "${EWW_CMD} open calendar --toggle"
(box
:orientation "v"
:space-evenly false
:class "widget clock"
(label :text thour)
(label :text tmin)
(label :text tpm))))

View file

@ -0,0 +1,3 @@
(defwidget Language []
(button :class "widget" :onclick "./scripts/kb-layout/set-active"
(label :text {kbLayout})))

View file

@ -0,0 +1,26 @@
(defwidget Workspaces []
(eventbox
:cursor "pointer"
:onscroll "./scripts/workspace/set-active {} ${currentWorkspace}"
:onhover "${EWW_CMD} update showNoOfWindows=true"
:onhoverlost "${EWW_CMD} update showNoOfWindows=false"
(box
:class "workspaces"
:space-evenly false
:orientation "v"
(for workspace in {workspacesJson}
(button
:onclick "hyprctl dispatch workspace ${workspace.id}"
(box
:height 25
:class "workspace ${workspace.id == currentWorkspace ? "workspacethingactive" : "workspacething"}"
(revealer
:reveal { workspace.id == currentWorkspace}
:transition "slideup"
:duration 500
(box
:height 40))))))))

View file

@ -1,4 +1,6 @@
; Global ; Global
(defvar animationDuration "500ms")
(deflisten kbLayout :initial "en" "./scripts/kb-layout/get-active")
(defpoll thour :initial "0" :interval "60s" "date +'%I'") (defpoll thour :initial "0" :interval "60s" "date +'%I'")
(defpoll tmin :initial "0" :interval "60s" "date +'%M'") (defpoll tmin :initial "0" :interval "60s" "date +'%M'")
(defpoll tpm :initial "0" :interval "60s" "date +'%p'") (defpoll tpm :initial "0" :interval "60s" "date +'%p'")
@ -45,14 +47,13 @@
(defvar revealSystray true) (defvar revealSystray true)
; Dock ; Dock
(defvar revealDock true)
(deflisten tasksjson :initial "[]" "./scripts/tasklist.py") (deflisten tasksjson :initial "[]" "./scripts/tasklist.py")
(defvar revealDock false)
; Workspaces ; Workspaces
(defvar show_no_of_windows false) (defvar showNoOfWindows false)
(defpoll workspacesjson :initial "[]" :interval "60s" "./scripts/workspace/get-workspaces") (defpoll workspacesJson :initial "[]" :interval "60s" "./scripts/workspace/get-workspaces")
(deflisten current_workspace :initial "1" "./scripts/workspace/get-active") (deflisten currentWorkspace :initial "1" "./scripts/workspace/get-active")
; Notifications ; Notifications
(deflisten notifications :initial '{ (deflisten notifications :initial '{

View file

@ -24,7 +24,7 @@
:valign "start" :valign "start"
:vexpand false :vexpand false
(home) (home)
(workspaces) (Workspaces)
(hiddenctl) (hiddenctl)
)) ))
@ -49,41 +49,12 @@
:vexpand false :vexpand false
:hexpand false :hexpand false
; (systemtray) ; (systemtray)
(Language)
(sliders) (sliders)
(clock) (clock)
; (battery) ; (battery)
)) ))
(defwidget workspaces []
(eventbox
:cursor "pointer"
:onscroll "./scripts/workspace/set-active {} ${current_workspace}"
:onhover "${EWW_CMD} update show_no_of_windows=true"
:onhoverlost "${EWW_CMD} update show_no_of_windows=false"
(box
:class "workspaces"
:space-evenly false
:orientation "v"
(for workspace in {workspacesjson}
(button
:onclick "hyprctl dispatch workspace ${workspace.id}"
(box
:height 25
:class "workspace ${workspace.id == current_workspace ? "workspacethingactive" : "workspacething"}"
(revealer
:reveal { workspace.id == current_workspace }
:transition "slideup"
:duration 500
(box
:height 40))))
)
)
)
)
(defwidget home [] (defwidget home []
(box (box
:class "widget" :class "widget"
@ -209,7 +180,7 @@
(button :onclick "alacritty -e nmtui" :tooltip wifi_essid (button :onclick "alacritty -e nmtui" :tooltip wifi_essid
(label :class "icon" :style "font-size: 18px;" :text wifi_icon)) (label :class "icon" :style "font-size: 18px;" :text wifi_icon))
(reveal_on_hover (RevealOnHover
:var revealVolume :var revealVolume
:varname "revealVolume" :varname "revealVolume"
(box (box
@ -227,7 +198,7 @@
:min 0 :min 0
:flipped true)) :flipped true))
(reveal_on_hover (RevealOnHover
:var revealMicrophone :var revealMicrophone
:varname "revealMicrophone" :varname "revealMicrophone"
(box (box
@ -245,7 +216,7 @@
:min 0 :min 0
:flipped true)) :flipped true))
(reveal_on_hover (RevealOnHover
:var revealBrightness :var revealBrightness
:varname "revealBrightness" :varname "revealBrightness"
(box (box