From e2add462c0d66120867cdb7181a0d9c413f3e4c1 Mon Sep 17 00:00:00 2001 From: Justine Smithies Date: Tue, 6 Feb 2024 20:44:09 +0000 Subject: Initial commit of Eww config --- .config/eww/eww.scss | 107 +++++++++++++++ .config/eww/eww.yuck | 206 ++++++++++++++++++++++++++++ .config/eww/scripts/arch-updates.sh | 40 ++++++ .config/eww/scripts/battery.py | 89 ++++++++++++ .config/eww/scripts/brightnesscontrol | 44 ++++++ .config/eww/scripts/calendar.sh | 26 ++++ .config/eww/scripts/date-time.sh | 12 ++ .config/eww/scripts/dispatch.sh | 12 ++ .config/eww/scripts/idleinhibit.sh | 29 ++++ .config/eww/scripts/keyboardlayout.sh | 8 ++ .config/eww/scripts/monitor.sh | 11 ++ .config/eww/scripts/network.sh | 45 ++++++ .config/eww/scripts/scratchpad-indicator.sh | 36 +++++ .config/eww/scripts/start.sh | 19 +++ .config/eww/scripts/volumecontrol | 107 +++++++++++++++ .config/eww/scripts/workspace.sh | 44 ++++++ 16 files changed, 835 insertions(+) create mode 100644 .config/eww/eww.scss create mode 100644 .config/eww/eww.yuck create mode 100755 .config/eww/scripts/arch-updates.sh create mode 100755 .config/eww/scripts/battery.py create mode 100755 .config/eww/scripts/brightnesscontrol create mode 100755 .config/eww/scripts/calendar.sh create mode 100755 .config/eww/scripts/date-time.sh create mode 100755 .config/eww/scripts/dispatch.sh create mode 100755 .config/eww/scripts/idleinhibit.sh create mode 100755 .config/eww/scripts/keyboardlayout.sh create mode 100755 .config/eww/scripts/monitor.sh create mode 100755 .config/eww/scripts/network.sh create mode 100755 .config/eww/scripts/scratchpad-indicator.sh create mode 100755 .config/eww/scripts/start.sh create mode 100755 .config/eww/scripts/volumecontrol create mode 100755 .config/eww/scripts/workspace.sh (limited to '.config') diff --git a/.config/eww/eww.scss b/.config/eww/eww.scss new file mode 100644 index 0000000..6ac2238 --- /dev/null +++ b/.config/eww/eww.scss @@ -0,0 +1,107 @@ +* { + all: unset; //Unsets everything so you can style everything from scratch +} + +//Global Styles +.bar0, .bar1 { + background-color: rgba(0, 0, 0, 0); + color: #ffd5cd; + font-family: GoMono Nerd Font; + font-size: 12px; +} + +.bar { + background-color: rgba(0, 0, 0, 0.7); + box-shadow: 2px 4px 2px 1px rgba(0, 0, 0, 0.5); + margin: 2px 10px 4px 10px; + border-radius: 5px; +} + +// Styles on classes (see eww.yuck for more information) + +.sidestuff { + color: #ffd5cd; +} + +.audio { + color: #ffd5cd; + padding-right: 10px; +} + +.brightness { + color: #ffd5cd; + padding-right: 10px; +} + +.net { + color: #ffd5cd; + padding-right: 10px; +} + +.paru { + color: #98971a; + padding-right: 10px; +} + +.paru-empty { + color: #98971a; + padding-right: 0px; +} + +.scratchpad { + color: #ffd5cd; + padding-right: 10px; +} + +.scratchpad-empty { + color: #ffd5cd; + padding-right: 0px; +} + +.clock { + color: #ffd5cd; +} + +.idle { + color: #ffd5cd; + padding-right: 10px; +} + +.language { + color: #ffd5cd; + padding-right: 10px; +} + +.battery { + color: #ffd5cd; + padding-right: 10px; +} + +.w0, .w01, .w02, .w03, .w04, .w05, .w06, .w07, .w08, .w09, .w011, .w022, .w033, .w044, .w055, .w066, .w077, .w088, .w099 { + padding: 3px 5px; + box-shadow: inset 0 -2px transparent; +} + +/* Unoccupied */ +.w0 { + color: #a89984; +} + +/* Occupied */ +.w01, .w02, .w03, .w04, .w05, .w06, .w07, .w08, .w09 { + color: #fbf1c7; +} + +/* Focused */ +.w011, .w022, .w033, .w044, .w055, .w066, .w077, .w088, .w099 { + color: #fbf1c7; + box-shadow: inset 0 -3px #98971a; +} + +.workspace { +padding: 0 10px; +} + +.workspace button:hover { + box-shadow: inset 0 -3px #ffffff; +} diff --git a/.config/eww/eww.yuck b/.config/eww/eww.yuck new file mode 100644 index 0000000..d0e832a --- /dev/null +++ b/.config/eww/eww.yuck @@ -0,0 +1,206 @@ +(defwidget bar0 [] +(box :class "bar" + (centerbox :orientation "h" + (workspaces0) + (clock) + (sidestuff))) +) + +(defwidget bar1 [] +(box :class "bar" + (centerbox :orientation "h" + (workspaces1) + (clock) + (sidestuff))) +) + +(defwidget sidestuff [] + (box :class "sidestuff" :orientation "h" :space-evenly false :halign "end" + (updates) + (scratchpad-indicator) + (language) + (idleinhibit) + (bright) + (audio) + (net) + (battery) + )) + +(deflisten workspace0 + "scripts/workspace.sh 0") + +(defwidget workspaces0 [] + (literal :content workspace0)) + +(deflisten workspace1 + "scripts/workspace.sh 1") + +(defwidget workspaces1 [] + (literal :content workspace1)) + +(defwidget language [] + (box :class "language" + :orientation "h" + :space-evenly false + :halign "end" + :spacing 10 + (button + :class "" + :onclick "scripts/keyboardlayout.sh toggle" + language) +)) + +(defwidget clock [] + (box :class "clock" + :orientation "h" + :space-evenly false + :halign "center" + (button + :class "" + :onclick "scripts/calendar.sh show" + date-time) +)) + +(defwidget audio [] + (box :class "audio" + :orientation "h" + :space-evenly false + :halign "end" + :spacing 10 + (button + :class "" + :onclick "scripts/volumecontrol down" + :onmiddleclick "scripts/volumecontrol mute" + :onrightclick "scripts/volumecontrol up" + volume) +)) + +(defwidget bright [] + (box :class "brightness" + :orientation "h" + :space-evenly false + :halign "end" + :spacing 10 + (button + :class "" + :onclick "scripts/brightnesscontrol down" + :onrightclick "scripts/brightnesscontrol up" + brightness) +)) + +(defwidget updates [] + (box + :class "${matches(arch-updates, '^\s*$')?'paru-empty':'paru'}" + :orientation "h" + :space-evenly false + :halign "end" + :spacing 10 + (button + :class "" + :onclick "foot bash -c 'paru; ~/.config/eww/scripts/arch-updates.sh Refresh'&" + arch-updates) +)) + +(defwidget scratchpad-indicator [] + (box + :class "${matches(scratchpad, '^\s*$')?'scratchpad-empty':'scratchpad'}" + :orientation "h" + :space-evenly false + :halign "end" + :spacing 10 + (button + :class "" + :onclick "scripts/scratchpad-indicator.sh ShowInfo" + scratchpad) +)) + +(defwidget idleinhibit [] + (box :class "idle" + :orientation "h" + :space-evenly false + :halign "end" + :spacing 10 + (button + :class "" + :onclick "scripts/idleinhibit.sh toggle" + idle) +)) + +(defwidget net [] + (box :class "net" + :orientation "h" + :space-evenly false + :halign "end" + :spacing 10 + (button + :class "" + :onclick "scripts/network.sh ShowInfo" + network) +)) + +(defwidget battery [] + (box :class "battery" + :orientation "h" + :space-evenly false + :halign "end" + :spacing 10 + (button + :class "" + :onclick "scripts/battery.py --c left-click" + :onmiddleclick "scripts/battery.py --c middle-click" + :onrightclick "scripts/battery.py --c right-click" + battery) +)) + +(defpoll battery :interval "10s" + "scripts/battery.py --c status") + +(defpoll scratchpad :interval "1s" + "scripts/scratchpad-indicator.sh Update || echo null") + +(defpoll language :interval "1s" + "scripts/keyboardlayout.sh") + +(defpoll network :interval "1s" + "scripts/network.sh") + +(defpoll idle :interval "1s" + "scripts/idleinhibit.sh") + +(defpoll arch-updates :interval "600s" + "scripts/arch-updates.sh") + +(defpoll volume :interval "1s" + "scripts/volumecontrol") + +(defpoll brightness :interval "1s" + "scripts/brightnesscontrol") + +(defpoll date-time :interval "1s" + "scripts/date-time.sh") + +(defwindow bar0 + :monitor 0 + :windowtype "dock" + :geometry (geometry :x "0%" + :y "10px" + :width "100%" + :height "20px" + :anchor "top center") + :stacking "bt" + :exclusive true + :focusable false + (bar0)) + +(defwindow bar1 + :monitor 1 + :windowtype "dock" + :geometry (geometry :x "0%" + :y "10px" + :width "100%" + :height "20px" + :anchor "top center") + :stacking "bt" + :exclusive true + :focusable false + (bar1)) diff --git a/.config/eww/scripts/arch-updates.sh b/.config/eww/scripts/arch-updates.sh new file mode 100755 index 0000000..62bfe4a --- /dev/null +++ b/.config/eww/scripts/arch-updates.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +function CheckUpdates() { +updates="$(checkupdates;paru -Qum)" +arch="$(checkupdates | wc -l)" +aur="$(paru -Qum | wc -l)" +number=$((arch+aur)) + +if [ "$number" -gt 0 ]; then + text=" $number" +else + text="" +fi + +echo "$text" +} + +function RefreshUpdates() { + value="$(CheckUpdates)" + eww update arch-updates="$value" +} + +function Update() { + foot 'paru' + RefreshUpdates +} + +case "$1" in + Refresh) + RefreshUpdates + exit 0 + ;; + Update) + Update + exit 0 + ;; + *) + CheckUpdates + exit 0 +esac diff --git a/.config/eww/scripts/battery.py b/.config/eww/scripts/battery.py new file mode 100755 index 0000000..79d3471 --- /dev/null +++ b/.config/eww/scripts/battery.py @@ -0,0 +1,89 @@ +#!/usr/bin/env python3 + +import psutil +import argparse +import subprocess + + +def secs2hours(secs): + mm, ss = divmod(secs, 60) + hh, mm = divmod(mm, 60) + return "%d:%02d:%02d" % (hh, mm, ss) + + +parser = argparse.ArgumentParser() +parser.add_argument('--c', + choices=('status', 'left-click', 'middle-click', 'right-click'), + dest='command', + default='status', + help='Allowed values are status, left-click, middle-click and right-click' + ) +args = parser.parse_args() + +battery = psutil.sensors_battery() +icon = "" +percent = int(battery.percent) +time_left = battery.secsleft +isPlugged = battery.power_plugged +remaining = secs2hours(time_left) + +if args.command == "status": + if isPlugged: + if percent == 100: + icon = "󰂅" + elif percent > 89 and percent < 100: + icon = "󰂋" + elif percent > 79 and percent < 90: + icon = "󰂊" + elif percent > 69 and percent < 80: + icon = "󰢞" + elif percent > 59 and percent < 70: + icon = "󰂉" + elif percent > 49 and percent < 60: + icon = "󰢝" + elif percent > 39 and percent < 50: + icon = "󰂈" + elif percent > 29 and percent < 40: + icon = "󰂇" + elif percent > 19 and percent < 30: + icon = "󰂆" + elif percent > 9 and percent < 20: + icon = "󰢜" + elif percent > 0 and percent < 10: + icon = "󰢟" + message = str(percent) + "%" + print(icon, message, end="") + else: + if percent == 100: + icon = "" + elif percent > 89 and percent < 100: + icon = "󰂂" + elif percent > 79 and percent < 90: + icon = "󰂁" + elif percent > 69 and percent < 80: + icon = "󰂀" + elif percent > 59 and percent < 70: + icon = "󰁿" + elif percent > 49 and percent < 60: + icon = "󰁾" + elif percent > 39 and percent < 50: + icon = "󰁽" + elif percent > 29 and percent < 40: + icon = "󰁼" + elif percent > 19 and percent < 30: + icon = "󰁻" + elif percent > 9 and percent < 20: + icon = "󰁺" + elif percent > 0 and percent < 10: + icon = "󱃍" + message = str(percent) + "%" + print(icon, message, end="") +if args.command == "left-click": + if not isPlugged: + subprocess.call(["notify-send", "-r", "55555", "-u", "normal", "Est remaining time left: " + remaining]) + else: + subprocess.call(["notify-send", "-r", "55555", "-u", "normal", str(percent) + "% Charged"]) +if args.command == "middle-click": + print("Middle click") +if args.command == "right-click": + print("Right click") diff --git a/.config/eww/scripts/brightnesscontrol b/.config/eww/scripts/brightnesscontrol new file mode 100755 index 0000000..304c187 --- /dev/null +++ b/.config/eww/scripts/brightnesscontrol @@ -0,0 +1,44 @@ +#!/bin/bash + +# You can call this script like this: +# brightnessControl up +# brightnessControl down + +# Script inspired by these wonderful people: +# https://github.com/dastorm/volume-notification-dunst/blob/master/volume.sh +# https://gist.github.com/sebastiencs/5d7227f388d93374cebdf72e783fbd6a + +function send_notification { + icon=/usr/share/icons/Papirus-Dark/16x16/actions/brightnesssettings.svg + brightness=$(light -G) + brightness=$(echo "$brightness" | awk '{print ($0-int($0)<0.499)?int($0):int($0)+1}') + # Make the bar with the special character ─ (it's not dash -) + # https://en.wikipedia.org/wiki/Box-drawing_character + bar=$(seq -s "─" 0 $((brightness / 10 )) | sed 's/[0-9]//g') + #brightness=$((brightness *100 / 255 )) + #echo $bar + #echo $test + # Send the notification + notify-send -i "$icon" -r 5555 -u normal "$bar $brightness" +} + +case $1 in + up) + # increase the backlight by 5% + light -A 5 + send_notification + canberra-gtk-play -i audio-volume-change + ;; + down) + # decrease the backlight by 5% + light -U 5 + send_notification + canberra-gtk-play -i audio-volume-change + ;; + *) + brightness=$(light -G) + brightness=$(echo "$brightness" | awk '{print ($0-int($0)<0.499)?int($0):int($0)+1}') + icon="󰃞" + printf "%s" "$icon $brightness" "%" + ;; +esac diff --git a/.config/eww/scripts/calendar.sh b/.config/eww/scripts/calendar.sh new file mode 100755 index 0000000..3c6b16f --- /dev/null +++ b/.config/eww/scripts/calendar.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Calendar script + +function ShowCalendar() { + notify-send -i "calendar" " 📅 Calendar" "$(cal --color=always | sed "s/..7m//;s/..0m/<\/span><\/b>/")" -r 124 +} + +function EditCalendar() { + echo +} + +case "$1" in + show) + ShowCalendar + ;; + + edit) + EditCalendar + ;; + + *) + echo $"Usage: ${0##*/} {show|edit}" + exit 1 + +esac diff --git a/.config/eww/scripts/date-time.sh b/.config/eww/scripts/date-time.sh new file mode 100755 index 0000000..6968cec --- /dev/null +++ b/.config/eww/scripts/date-time.sh @@ -0,0 +1,12 @@ +#!/bin/sh +DaySuffix() { + case `date +%-d` in + 1|21|31) echo "st";; + 2|22) echo "nd";; + 3|23) echo "rd";; + *) echo "th";; + esac +} +date=$(date "+%A %-d`DaySuffix` %B %Y - %H:%M") +icon="" +printf "%s" "$date" diff --git a/.config/eww/scripts/dispatch.sh b/.config/eww/scripts/dispatch.sh new file mode 100755 index 0000000..e40f883 --- /dev/null +++ b/.config/eww/scripts/dispatch.sh @@ -0,0 +1,12 @@ +#! /bin/bash + +activemonitor=$(hyprctl monitors -j | jq '.[] | select(.focused == true).id') +passivemonitor=$(hyprctl monitors -j | jq '.[] | select(.focused == false).id') +activews=$(hyprctl monitors -j | jq '.[] | select(.focused == true).activeWorkspace.id') +passivews=$(hyprctl monitors -j | jq '.[] | select(.focused == false).activeWorkspace.id') + +# Comment out all lines below except the last to switch back to the default Hyprland dispatch method +[[ $1 -eq $passivews ]] && [[ $passivemonitor != "$activemonitor" ]] && (hyprctl dispatch swapactiveworkspaces "$activemonitor $passivemonitor") +hyprctl dispatch moveworkspacetomonitor "$1 $activemonitor" +hyprctl dispatch focusmonitor "$activemonitor" +hyprctl dispatch workspace "$1" diff --git a/.config/eww/scripts/idleinhibit.sh b/.config/eww/scripts/idleinhibit.sh new file mode 100755 index 0000000..e8ac78e --- /dev/null +++ b/.config/eww/scripts/idleinhibit.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Swayidle toggle +function toggle { + if pgrep "swayidle" > /dev/null + then + pkill swayidle + notify-send -r 5556 -u normal " Swayidle Inactive" + else + swayidle timeout 300 'swaylock -F -i ~/.cache/wallpaper --effect-blur 10x5 --clock --indicator' timeout 600 'hyprctl dispatch dpms off' resume 'hyprctl dispatch dpms on' & + notify-send -r 5556 -u normal " Swayidle Active" + fi +} + +case $1 in + toggle) + toggle + ;; + *) + if pgrep "swayidle" > /dev/null + then + icon="" + else + icon="" + fi + printf "%s" "$icon " + ;; +esac + diff --git a/.config/eww/scripts/keyboardlayout.sh b/.config/eww/scripts/keyboardlayout.sh new file mode 100755 index 0000000..aa98833 --- /dev/null +++ b/.config/eww/scripts/keyboardlayout.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Get long name +# echo "$(hyprctl devices | grep -A 2 "at-translated-set-2-keyboard" | awk 'NR==3 {print $3" "$4}')" + +# Get short name +echo "$(hyprctl devices | grep -A 2 "at-translated-set-2-keyboard" | awk 'NR==3 {print $4}'| grep -Po '(?<=\().*(?=\))' )" + diff --git a/.config/eww/scripts/monitor.sh b/.config/eww/scripts/monitor.sh new file mode 100755 index 0000000..a211054 --- /dev/null +++ b/.config/eww/scripts/monitor.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +function handle { + if [[ ${1:0:12} == "monitoradded" ]]; then + ~/.config/eww/scripts/start.sh + elif [[ ${1:0:14} == "monitorremoved" ]]; then + ~/.config/eww/scripts/start.sh + fi +} + +socat - UNIX-CONNECT:/tmp/hypr/$(echo $HYPRLAND_INSTANCE_SIGNATURE)/.socket2.sock | while read line; do handle $line; done diff --git a/.config/eww/scripts/network.sh b/.config/eww/scripts/network.sh new file mode 100755 index 0000000..cceebd7 --- /dev/null +++ b/.config/eww/scripts/network.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# This script requires dnsutils aka bind to fetch the WAN IP address + +# Shows the connections names +# nmcli connection show --active | grep 'ethernet' | awk '{ print $1 }' FS=' ' +# nmcli connection show --active | grep 'wifi' | awk '{ print $1 }' FS=' ' + +# Show ethernet interface name +# nmcli connection show --active | grep 'ethernet' | awk '{ print $6 }' FS=' ' + +# Show wifi interface name +# nmcli connection show --active | grep 'wifi' | awk '{ print $4 }' FS=' ' + +function ShowInfo { + if [ "$(nmcli connection show --active | grep -oh "\w*ethernet\w*")" == "ethernet" ]; then + wan="$(dig +short myip.opendns.com @resolver1.opendns.com)" + connection="$(nmcli connection show --active | grep 'ethernet' | awk '{ print $6 }' FS=' '): $(nmcli connection show --active | grep 'ethernet' | awk '{ print $1 }' FS=' ') - $(nmcli -t -f IP4.ADDRESS dev show $(nmcli connection show --active | grep 'ethernet' | awk '{ print $6 }' FS=' ') | awk '{print $2}' FS='[:/]') +WAN IP: $wan" + elif [ "$(nmcli connection show --active | grep -oh "\w*wifi\w*")" == "wifi" ]; then + wan="$(dig +short myip.opendns.com @resolver1.opendns.com)" + connection="$(nmcli connection show --active | grep 'wifi' | awk '{ print $4 }' FS=' '): $(nmcli connection show --active | grep 'wifi' | awk '{ print $1 }' FS=' ') - $(nmcli -t -f IP4.ADDRESS dev show $(nmcli connection show --active | grep 'wifi' | awk '{ print $4 }' FS=' ') | awk '{print $2}' FS='[:/]') +WAN IP: $wan" + else + connection="No active connection." + fi + notify-send -i "network-idle" "$connection" -r 123 +} + +function IconUpdate() { + if [ "$(nmcli connection show --active | grep -oh "\w*ethernet\w*")" == "ethernet" ]; then + icon="󰈀" + elif [ "$(nmcli connection show --active | grep -oh "\w*wifi\w*")" == "wifi" ]; then + icon="" + else + icon="󰲜" + fi + printf "%s" "$icon" +} + +if [ "$1" = "ShowInfo" ]; then + ShowInfo +else + IconUpdate +fi diff --git a/.config/eww/scripts/scratchpad-indicator.sh b/.config/eww/scripts/scratchpad-indicator.sh new file mode 100755 index 0000000..b0911d9 --- /dev/null +++ b/.config/eww/scripts/scratchpad-indicator.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Scratchpad indicator for Hyprland + +output="$(hyprctl clients -j | jq -r '.[] | select(.workspace.id==-99) |""+.class+" : "+.title+""')" +number="$(hyprctl clients -j | jq -r '.[] | select(.workspace.id==-99) | (tostring)' | wc -l)" +file=~/.config/eww/eww.scss + +if [ "$number" -gt 0 ]; then + text=" $number" +else + text="" +fi + +output="$(echo "$output" | sed -r 's/[&]+/and/g')" # Replace unprintable & character with the word 'and' +tooltip="\n" +tooltip+="$(echo "$output" | sed -z 's/\n/\\n/g')" +tooltip=${tooltip::-2} + +function ShowInfo() { + if [ "$number" -eq 0 ]; then + exit + else + tooltip="$(echo -e $tooltip)" + notify-send " Scratchpad" "$tooltip" -r 123 + fi +} + +function Update() { + printf "%s" "$text" +} + +if [ "$1" = "ShowInfo" ]; then + ShowInfo +else + Update +fi diff --git a/.config/eww/scripts/start.sh b/.config/eww/scripts/start.sh new file mode 100755 index 0000000..f464058 --- /dev/null +++ b/.config/eww/scripts/start.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# kill any running instances if they exist +eww kill + +# start a bar for each monitor +monitors=$(hyprctl monitors -j | jq '.[] | .id') +# monitors=$(hyprctl monitors -j | jq '.[] | .id' | wc -l) + +for monitor in ${monitors}; do + eww open bar${monitor} +done + +# eww open bar0 +# if [ $monitors -gt 1 ]; then +# for ((i = 1 ; i <= $monitors ; i++)); do +# eww open bar${i} +# done +# fi diff --git a/.config/eww/scripts/volumecontrol b/.config/eww/scripts/volumecontrol new file mode 100755 index 0000000..4d24d29 --- /dev/null +++ b/.config/eww/scripts/volumecontrol @@ -0,0 +1,107 @@ +#!/bin/bash + +# You can call this script like this: +# volumecontrol up +# volumecontrol down +# volumecontrol mute + +function get_volume { + amixer get Master | grep '%' | head -n 1 | cut -d '[' -f 2 | cut -d '%' -f 1 +} + +function is_mute { + amixer get Master | grep '%' | grep -oE '[^ ]+$' | grep off > /dev/null +} + +function send_notification { + volume=$(get_volume) + # Make the bar with the special character ─ (it's not dash -) + # https://en.wikipedia.org/wiki/Box-drawing_character +if [ "$volume" = "0" ]; then + icon_name="/usr/share/icons/Adwaita/16x16/legacy/audio-volume-muted.png" +notify-send -i "$icon_name" -r 5556 -u normal "$volume" + else + if [ "$volume" -lt "10" ]; then + icon_name="/usr/share/icons/Adwaita/16x16/legacy/audio-volume-low.png" +notify-send -i "$icon_name" -r 5556 -u normal "$volume" + else + if [ "$volume" -lt "30" ]; then + icon_name="/usr/share/icons/Adwaita/16x16/legacy/audio-volume-low.png" + else + if [ "$volume" -lt "70" ]; then + icon_name="/usr/share/icons/Adwaita/16x16/legacy/audio-volume-medium.png" + else + icon_name="/usr/share/icons/Adwaita/16x16/legacy/audio-volume-high.png" + fi + fi + fi +fi +bar=$(seq -s "─" $(($volume/5)) | sed 's/[0-9]//g') +# Send the notification +notify-send -i "$icon_name" -r 5556 -u normal "$bar $volume" +} + +case $1 in + up) + # Set the volume on (if it was muted) + amixer set Master on > /dev/null + # Up the volume (+ 2%) + amixer sset Master 2%+ > /dev/null + send_notification + canberra-gtk-play -i audio-volume-change + ;; + down) + amixer set Master on > /dev/null + amixer sset Master 2%- > /dev/null + send_notification + canberra-gtk-play -i audio-volume-change + ;; + mute) + # Toggle mute + amixer set Master 1+ toggle > /dev/null + if is_mute ; then + notify-send -i "/usr/share/icons/Adwaita/16x16/legacy/audio-volume-muted.png" -r 5556 -u normal "$bar Audio Muted" + else + send_notification + canberra-gtk-play -i audio-volume-change + fi + ;; + *) + volume="$(get_volume)" + + if [[ $volume == "100" ]]; then + icon="" + elif [[ $volume -ge "89" && $volume -le "100" ]]; then + icon="" + elif [[ $volume -ge "79" && $volume -le "90" ]]; then + icon="" + elif [[ $volume -ge "69" && $volume -le "80" ]]; then + icon="" + elif [[ $volume -ge "59" && $volume -le "70" ]]; then + icon="" + elif [[ $volume -ge "49" && $volume -le "60" ]]; then + icon="" + elif [[ $volume -ge "39" && $volume -le "50" ]]; then + icon="" + elif [[ $volume -ge "29" && $volume -le "40" ]]; then + icon="" + elif [[ $volume -ge "19" && $volume -le "30" ]]; then + icon="" + elif [[ $volume -ge "9" && $volume -le "20" ]]; then + icon="" + elif [[ $volume -gt "0" && $volume -le "10" ]]; then + icon="" + elif [[ $volume -eq "0" ]]; then + icon="󰝟" + volume="M " + fi + + +if is_mute; then + icon="󰝟" + volume="M " +fi + +printf "%s" "$icon $volume%" + ;; +esac diff --git a/.config/eww/scripts/workspace.sh b/.config/eww/scripts/workspace.sh new file mode 100755 index 0000000..1f49e11 --- /dev/null +++ b/.config/eww/scripts/workspace.sh @@ -0,0 +1,44 @@ +#! /bin/bash + +#define icons for workspaces 1-9 +ic=(0         󰻧) + +workspaces() { + + unset -v \ + o1 o2 o3 o4 o5 o6 o7 o8 o9 \ + f1 f2 f3 f4 f5 f6 f7 f8 f9 + +# Get occupied workspaces and remove workspace -99 aka scratchpad if it exists +# a="$(hyprctl workspaces | grep ID | awk '{print $3}')" +# a="$(echo "${a//-99/}" | sed '/^[[:space:]]*$/d')" +ows="$(hyprctl workspaces -j | jq '.[] | del(select(.id == -99)) | .id')" + +for num in $ows; do + export o"$num"="$num" +done + +# Get Focused workspace for current monitor ID +arg="$1" +num="$(hyprctl monitors -j | jq --argjson arg "$arg" '.[] | select(.id == $arg).activeWorkspace.id')" +export f"$num"="$num" + +echo "(eventbox :onscroll \"echo {} | sed -e 's/up/-1/g' -e 's/down/+1/g' | xargs hyprctl dispatch workspace\" \ + (box :class \"workspace\" :orientation \"h\" :space-evenly \"false\" \ + (button :onclick \"scripts/dispatch.sh 1\" :class \"w0$o1$f1\" \"${ic[1]} ₁\") \ + (button :onclick \"scripts/dispatch.sh 2\" :class \"w0$o2$f2\" \"${ic[2]} ₂\") \ + (button :onclick \"scripts/dispatch.sh 3\" :class \"w0$o3$f3\" \"${ic[3]} ₃\") \ + (button :onclick \"scripts/dispatch.sh 4\" :class \"w0$o4$f4\" \"${ic[4]} ₄\") \ + (button :onclick \"scripts/dispatch.sh 5\" :class \"w0$o5$f5\" \"${ic[5]} ₅\") \ + (button :onclick \"scripts/dispatch.sh 6\" :class \"w0$o6$f6\" \"${ic[6]} ₆\") \ + (button :onclick \"scripts/dispatch.sh 7\" :class \"w0$o7$f7\" \"${ic[7]} ₇\") \ + (button :onclick \"scripts/dispatch.sh 8\" :class \"w0$o8$f8\" \"${ic[8]} ₈\") \ + (button :onclick \"scripts/dispatch.sh 9\" :class \"w0$o9$f9\" \"${ic[9]} ₉\") \ + )\ + )" +} + +workspaces $1 +socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | while read -r; do +workspaces $1 +done -- cgit v1.2.3