From cd7e93374e5ec5143b4f6e4383b583ef8aa8f2cb Mon Sep 17 00:00:00 2001 From: willifan Date: Sat, 1 Jun 2024 17:20:15 +0200 Subject: [PATCH] updated eww files and bash scripts --- eww/eww.scss | 18 +++++++--- eww/eww.yuck | 82 ++++++++++++++++++++++++++++++++----------- eww/templates.yuck | 14 ++++++-- eww/variables.yuck | 14 ++++---- scripts/bluetooth.sh | 10 +++--- scripts/brightness.sh | 2 +- scripts/media.sh | 4 +-- scripts/monitors.sh | 7 ++-- scripts/network.sh | 8 ++--- scripts/test.sh | 16 ++++----- scripts/volume.sh | 4 +-- 11 files changed, 119 insertions(+), 60 deletions(-) diff --git a/eww/eww.scss b/eww/eww.scss index d055673..5fb3471 100644 --- a/eww/eww.scss +++ b/eww/eww.scss @@ -1,8 +1,15 @@ - +@import url("file:///home/willifan/.config/gtk-4.0/gtk.css"); window { - border-width: 2px; - border-color: #595959; - border-radius: 12.5px; + background-image: none; + box-shadow: none; + background-color: rgba(12, 12, 12, 0.0); +} + +.barbox { + border-width: 2px; + border-color: #595959; + border-radius: 15px; + background-color: rgba(12, 12, 12, 0.9); } .calendar { @@ -93,4 +100,5 @@ window { .smallBox:active { background-color: #52341A; -} \ No newline at end of file +} + diff --git a/eww/eww.yuck b/eww/eww.yuck index 3750e78..c3d524f 100644 --- a/eww/eww.yuck +++ b/eww/eww.yuck @@ -22,6 +22,8 @@ (box :space-evenly false :spacing 3 + :valign "center" + :height 20 (for workspace in workspaces (workspace :activeOn {workspace.normal.activeOn} @@ -96,24 +98,34 @@ ;; Widget blocks -;;(defwidget media [] -;; (box -;; :class "smallBox" -;; :height 20 -;; :valign "center" -;; :space-evenly false -;; :visible {media.status == "Playing" ? true : false} -;; (smallSpacer) -;; (label -;; :text {media.name} -;; :tooltip {media.name} -;; :limit-width 40) -;; (smallSpacer))) +(defwidget media [] + (box + :visible {media.status == "Playing" ? true : false} + :spacing 3 + :space-evenly false + :halign "end" + :valign "center" + :height 20 + (seperator) + (box + :class "smallBox" + :height 20 + :valign "center" + :space-evenly false + (space) + (label + :text {media.name} + :tooltip {media.name} + :limit-width 40) + (space)))) (defwidget processing [] (eventbox :onclick 'hyprctl dispatch exec "[float; pin; size 40% 40%; move 100%-41% 40] kitty bpytop -b proc"' :class "smallBox" + :halign "end" + :valign "center" + :height 20 (box :space-evenly false :halign "end" @@ -129,6 +141,9 @@ (eventbox :onclick 'hyprctl dispatch exec "[float; pin; size 40% 40%; move 100%-41% 40] kitty pulsemixer"' :class "smallBox" + :halign "end" + :valign "center" + :height 20 (box :space-evenly false :halign "end" @@ -144,11 +159,14 @@ (eventbox :onclick "`networkmanager_dmenu`" :class "smallBox" + :halign "end" + :valign "center" + :height 20 (box :space-evenly false :halign "end" :valign "center" - :height 20 + :height 24 (smallSpacer) (network) (space) @@ -157,8 +175,10 @@ (defwidget energy [] (eventbox - :onclick `sleep 1 && systemctl hibernate` + :onclick `wlogout -r 25 -c 25 -m 300 &` :class "smallBox" + :valign "center" + :height 20 (box :space-evenly false :halign "end" @@ -173,17 +193,28 @@ (defwidget start [] (box + :class "barbox" :orientation "h" :space-evenly false + :height 30 :halign "start" + :valign "center" + :spacing 3 (space) - (time))) + (time) + (media) + (space))) (defwidget center [monitor] (box + :class "barbox" :orientation "h" :space-evenly false + :spacing 3 + :height 30 :halign "center" + :valign "center" + (space) (workspace :activeOn {workspaces[0].special.activeOn} :occupied {workspaces[0].special.occupied} @@ -211,15 +242,26 @@ :occupied {workspaces[3].special.occupied} :id {workspaces[3].special.id} :icon {workspaces[3].special.icon} - :monitor {monitor}))) + :monitor {monitor}) + (space))) (defwidget end [] (box + :class "barbox" :spacing 2 :orientation "h" :space-evenly false + :height 30 :valign "center" :halign "end" + (space) +;; (systray +;; :spacing 2 +;; :orientation "h" +;; :space-evenly true +;; :icon-size 16) +;; +;; (seperator) (processing) @@ -238,7 +280,8 @@ (space))) (defwidget bar [monitor] - (centerbox :orientation "h" + (centerbox + :orientation "h" (start) (center :monitor {monitor}) @@ -247,7 +290,6 @@ (defwindow bar [monitor width height] :monitor {monitor} - :class "bar" :geometry (geometry :x "0%" :y "5px" @@ -257,4 +299,4 @@ :stacking "fg" :exclusive true (bar - :monitor {monitor})) \ No newline at end of file + :monitor {monitor})) diff --git a/eww/templates.yuck b/eww/templates.yuck index 54fa6c2..9f19d6f 100644 --- a/eww/templates.yuck +++ b/eww/templates.yuck @@ -1,5 +1,6 @@ (defwidget imageDPI [image size visible] (overlay + :valign "center" :width "${size}" :height "${size}" :visible "${visible}" @@ -53,28 +54,35 @@ :width 20 (box :halign "center" + :valign "center" :space-evenly false (smallSpacer) (label :class {occupied > 0 ? "" : "unoccupiedWorkspace"} :width 16 + :valign "center" :text {matches(id, "special:") ? substring(id, 8, 1) : id }) (imageDPI :visible {occupied > 0 ? true : false} - :image "/usr/share/icons/Papirus-Dark/128x128/apps/${icon}" + :valign "center" + :image "/run/current-system/sw/share/icons/Papirus-Dark/128x128/apps/${icon}" :size "16") (smallSpacer)))) (defwidget smallSpacer [] (box + :valign "center" :width 2)) (defwidget space [] (box - :width 5)) + :valign "center" + :width 3)) (defwidget seperator [] (box + :valign "center" (label + :valign "center" :text "|" - ))) \ No newline at end of file + ))) diff --git a/eww/variables.yuck b/eww/variables.yuck index d433660..e6f3fba 100644 --- a/eww/variables.yuck +++ b/eww/variables.yuck @@ -4,7 +4,7 @@ (deflisten network :initial '{"name":"No Connection","image":"n.A."}' - `scripts/network.sh`) + `sh scripts/network.sh`) (deflisten workspaces :initial '' @@ -13,13 +13,13 @@ (defpoll bluetooth :initial '{"name":"","battery":"0"}' :interval "2s" - `scripts/bluetooth.sh`) + `sh scripts/bluetooth.sh`) (deflisten volume :initial '{"volume":"0","muted":"0"}' - `scripts/volume.sh`) + `sh scripts/volume.sh`) -;;(defpoll media -;; :initial '{"status":"","name":""}' -;; :interval "2s" -;; `scripts/media.sh`) \ No newline at end of file +(defpoll media + :initial '{"status":"","name":""}' + :interval "2s" + `scripts/media.sh`) diff --git a/scripts/bluetooth.sh b/scripts/bluetooth.sh index 08db287..1432dc9 100755 --- a/scripts/bluetooth.sh +++ b/scripts/bluetooth.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Get the list of connected Bluetooth devices devices=$(bluetoothctl devices Connected | awk '{print $2}') @@ -9,15 +9,15 @@ i=0 for device in $devices; do # Get the device info using bluetoothctl - info=$(bluetoothctl info $device) + info=$(bluetoothctl info "$device") # Extract the name and battery percentage from the device info - name[$i]=$(echo "$info" | awk '/Name:/ {for(i=2; i<=NF; i++) printf "%s ", $i;}') - battery[$i]=$(echo "$info" | awk '/Battery Percentage:/ {print $4}' | tr -d '()') + name[i]=$(echo "$info" | awk '/Name:/ {for(i=2; i<=NF; i++) printf "%s ", $i;}') + battery[i]=$(echo "$info" | awk '/Battery Percentage:/ {print $4}' | tr -d '()') ((i=i+1)) done -echo '{"name":"'${name[0]}'","battery":"'${battery[0]}'"}' \ No newline at end of file +echo '{"name":"'"${name[0]}"'","battery":"'"${battery[0]}"'"}' \ No newline at end of file diff --git a/scripts/brightness.sh b/scripts/brightness.sh index 501e237..b8f7398 100755 --- a/scripts/brightness.sh +++ b/scripts/brightness.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash FILE_TO_WATCH="/sys/class/backlight/intel_backlight/brightness" # Replace with the actual file path diff --git a/scripts/media.sh b/scripts/media.sh index 53fb4ee..cce0335 100755 --- a/scripts/media.sh +++ b/scripts/media.sh @@ -1,6 +1,6 @@ -#!/bin/bash +#!/usr/bin/env bash status=$(playerctl status) name=$(playerctl metadata title) -echo '{"status":"'$status'","name":"'$name'"}' \ No newline at end of file +echo '{"status":"'"$status"'","name":"'"$name"'"}' \ No newline at end of file diff --git a/scripts/monitors.sh b/scripts/monitors.sh index 809e77d..254c3af 100755 --- a/scripts/monitors.sh +++ b/scripts/monitors.sh @@ -1,6 +1,7 @@ -#!/bin/bash +#!/usr/bin/env bash - + + unset id name horizontal vertical scale activeWorkspace i=0 @@ -34,6 +35,6 @@ for ((i = 0; i < ${#id[@]}; i++)); do monitorID=$(xrandr --listactivemonitors | grep +"${name[$i]}" | awk '{sub(/.$/,"",$1); print $1}') - eww open bar --id bar"${monitorID}" --arg monitor="${monitorID}" --arg width="${new_width}" --arg height=25 + eww open bar --id bar"${monitorID}" --arg monitor="${monitorID}" --arg width="${new_width}" --arg height=30 sleep 2 done diff --git a/scripts/network.sh b/scripts/network.sh index 3d2a4b6..7c3a193 100755 --- a/scripts/network.sh +++ b/scripts/network.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ethernet() { name="Wired" @@ -28,16 +28,16 @@ while true; do networkInfo=$(nmcli -f NAME,TYPE connection show --active | awk '!/loopback/ && NR > 1') - if [[ $(awk '/wifi/' <<< $networkInfo) ]]; then + if [[ $(awk '/wifi/' <<< "$networkInfo") ]]; then wifi fi - if [[ $(awk '/ethernet/' <<< $networkInfo) ]]; then + if [[ $(awk '/ethernet/' <<< "$networkInfo") ]]; then ethernet fi - echo '{"name":"'$name'","image":"'$image'"}' + echo '{"name":"'"$name"'","image":"'"$image"'"}' sleep 2 done diff --git a/scripts/test.sh b/scripts/test.sh index 578cecf..f40915a 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -1,25 +1,25 @@ -#!/bin/bash +#!/usr/bin/env bash getIcon() { local desktop="" # Search for desktop files by WM class if [ -n "$1" ]; then - desktop=$(grep -l "StartupWMClass.*$1$" /usr/share/applications/*.desktop) - [ -z "$desktop" ] && desktop=$(grep -Pl "Name\s*=\s*$1$" /usr/share/applications/*.desktop) - [ -z "$desktop" ] && desktop=$(ls /usr/share/applications/${1}.desktop 2>/dev/null) + desktop=$(grep -l "StartupWMClass.*$1$" /run/current-system/sw/share/applications/*.desktop) + [ -z "$desktop" ] && desktop=$(grep -Pl "Name\s*=\s*$1$" /run/current-system/sw/share/applications/*.desktop) + [ -z "$desktop" ] && desktop=$(ls /run/current-system/sw/share/applications/"${1}".desktop 2>/dev/null) fi # If not found by WM class, search by process name if [ -z "$desktop" ] && [ -n "$2" ]; then - process=$(ps -p ${2} -o comm=) - desktop=$(grep -Pl "$process" /usr/share/applications/*.desktop) - [ -n "$desktop" ] && desktop="$desktop" + process=$(ps -p "${2}" -o comm=) + desktop=$(grep -Pl "$process" /run/current-system/sw/share/applications/*.desktop) + [ -n "$desktop" ] fi # If not found by WM class or process name, search by name or description if [ -z "$desktop" ] && [ -n "$1" ]; then - desktop=$(grep -Pl "$1" /usr/share/applications/*.desktop) + desktop=$(grep -Pl "$1" /run/current-system/sw/share/applications/*.desktop) fi echo "$desktop" diff --git a/scripts/volume.sh b/scripts/volume.sh index 7c74477..9ba7f35 100755 --- a/scripts/volume.sh +++ b/scripts/volume.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash generate() { message=$(wpctl get-volume @DEFAULT_AUDIO_SINK@) @@ -10,7 +10,7 @@ generate() { muted=0 fi - echo '{"volume":"'$volume'","muted":"'$muted'"}' + echo '{"volume":"'"$volume"'","muted":"'"$muted"'"}' } generate