feat: eww bar

This commit is contained in:
hesam-init 2024-02-19 23:32:33 +03:30
parent 08a3768272
commit ebf470e071
15 changed files with 495 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -0,0 +1,5 @@
* {
all: unset;
font-family: feather;
font-family: mononoki Nerd Font;
}

View file

@ -0,0 +1,54 @@
@import "./assets/scss/main.scss";
.bar {
background-color: #0f0f17;
padding: 0.5rem;
border-radius: 0.8rem;
}
.sidestuff slider {
all: unset;
color: #ffd5cd;
}
.metric scale trough highlight {
all: unset;
background-color: #D35D6E;
color: #000000;
border-radius: 10px;
}
.metric scale trough {
all: unset;
background-color: #4e4e4e;
border-radius: 50px;
min-height: 3px;
min-width: 50px;
margin-left: 10px;
margin-right: 20px;
}
.metric scale trough highlight {
all: unset;
background-color: #D35D6E;
color: #000000;
border-radius: 10px;
}
.metric scale trough {
all: unset;
background-color: #4e4e4e;
border-radius: 50px;
min-height: 3px;
min-width: 50px;
margin-left: 10px;
margin-right: 20px;
}
.label-ram {
font-size: large;
}
.workspaces button:hover {
color: #D35D6E;
}

View file

@ -0,0 +1,96 @@
; variables :
(deflisten workspace "scripts/workspace")
(deflisten music :initial ""
"playerctl --follow metadata --format '{{ artist }} - {{ title }}' || true")
(defpoll volume :interval "1s"
"scripts/getvol")
(defpoll time :interval "10s"
"date '+%H:%M %b %d, %Y'")
(defwidget workspaces []
(literal
:content workspace
:valign "center"))
(defwidget bar []
(centerbox :orientation "w"
(workspaces)
(music)
(sidestuff)))
(defwidget sidestuff []
(box :class "sidestuff" :orientation "h" :space-evenly false :halign "end"
(metric :label "🔊"
:value volume
:onchange "amixer -D pulse sset Master {}%")
(metric :label ""
:value {EWW_RAM.used_mem_perc}
:onchange "")
(metric :label "💾"
:value {round((1 - (EWW_DISK["/"].free / EWW_DISK["/"].total)) * 100, 0)}
:onchange "")
time))
(defwidget music []
(box :class "music"
:orientation "h"
:space-evenly false
:halign "center"
{music != "" ? "🎵${music}" : ""}))
(defwidget metric [label value onchange]
(box :orientation "h"
:class "metric"
:space-evenly false
(box :class "label" label)
(scale :min 0
:max 101
:active {onchange != ""}
:value value
:onchange onchange)))
(defwidget left []
(box :orientation "h"
:space-evenly false
:halign "end"
:class "left_modules"
(bright)
(volume)
(wifi)
(sep)
(bat)
(mem)
(sep)
(clock_module)))
(defwidget right []
(box :orientation "h"
:space-evenly false
:halign "start"
:class "right_modules"
(workspaces)))
(defwidget center []
(box :orientation "h"
:space-evenly false
:halign "center"
:class "center_modules"
(music)))
(defwindow bar
:monitor 0
:geometry
(geometry
:anchor "top center"
:y "5px"
:width "99%"
:height "36px"
)
:stacking "fg"
:exclusive "true"
:focusable "false"
(bar)
)

14
eww/.config/eww/bar/launch_bar Executable file
View file

@ -0,0 +1,14 @@
#!/bin/bash
EWW="eww -c $HOME/.config/eww/bar"
if [[ ! $(pidof eww) ]]; then
eww daemon
sleep 1
fi
run_eww() {
${EWW} open bar
}
run_eww

View file

@ -0,0 +1,17 @@
#!/bin/bash
battery() {
BAT=`ls /sys/class/power_supply | grep BAT | head -n 1`
cat /sys/class/power_supply/${BAT}/capacity
}
battery_stat() {
BAT=`ls /sys/class/power_supply | grep BAT | head -n 1`
cat /sys/class/power_supply/${BAT}/status
}
if [[ "$1" == "--bat" ]]; then
battery
elif [[ "$1" == "--bat-st" ]]; then
battery_stat
fi

View file

@ -0,0 +1,15 @@
#!/bin/sh
total="$(free -m | grep Mem: | awk '{ print $2 }')"
used="$(free -m | grep Mem: | awk '{ print $3 }')"
free=$(expr $total - $used)
if [ "$1" = "total" ]; then
echo $total
elif [ "$1" = "used" ]; then
echo $used
elif [ "$1" = "free" ]; then
echo $free
fi

View file

@ -0,0 +1,3 @@
#!/bin/sh
printf "%.0f\n" $(free -m | grep Mem | awk '{print ($3/$2)*100}')

View file

@ -0,0 +1,98 @@
#!/bin/bash
# scripts by adi1090x
## Get data
STATUS="$(mpc status)"
COVER="/tmp/.music_cover.png"
MUSIC_DIR="$HOME/Music"
## Get status
get_status() {
if [[ $STATUS == *"[playing]"* ]]; then
echo ""
else
echo "奈"
fi
}
## Get song
get_song() {
song=`mpc -f %title% current`
if [[ -z "$song" ]]; then
echo "Offline"
else
echo "$song"
fi
}
## Get artist
get_artist() {
artist=`mpc -f %artist% current`
if [[ -z "$artist" ]]; then
echo ""
else
echo "$artist"
fi
}
## Get time
get_time() {
time=`mpc status | grep "%)" | awk '{print $4}' | tr -d '(%)'`
if [[ -z "$time" ]]; then
echo "0"
else
echo "$time"
fi
}
get_ctime() {
ctime=`mpc status | grep "#" | awk '{print $3}' | sed 's|/.*||g'`
if [[ -z "$ctime" ]]; then
echo "0:00"
else
echo "$ctime"
fi
}
get_ttime() {
ttime=`mpc -f %time% current`
if [[ -z "$ttime" ]]; then
echo "0:00"
else
echo "$ttime"
fi
}
## Get cover
get_cover() {
ffmpeg -i "${MUSIC_DIR}/$(mpc current -f %file%)" "${COVER}" -y &> /dev/null
STATUS=$?
# Check if the file has a embbeded album art
if [ "$STATUS" -eq 0 ];then
echo "$COVER"
else
echo "images/music.png"
fi
}
## Execute accordingly
if [[ "$1" == "--song" ]]; then
get_song
elif [[ "$1" == "--artist" ]]; then
get_artist
elif [[ "$1" == "--status" ]]; then
get_status
elif [[ "$1" == "--time" ]]; then
get_time
elif [[ "$1" == "--ctime" ]]; then
get_ctime
elif [[ "$1" == "--ttime" ]]; then
get_ttime
elif [[ "$1" == "--cover" ]]; then
get_cover
elif [[ "$1" == "--toggle" ]]; then
mpc -q toggle
elif [[ "$1" == "--next" ]]; then
{ mpc -q next; get_cover; }
elif [[ "$1" == "--prev" ]]; then
{ mpc -q prev; get_cover; }
fi

92
eww/.config/eww/bar/scripts/pop Executable file
View file

@ -0,0 +1,92 @@
#!/bin/bash
calendar() {
LOCK_FILE="$HOME/.cache/eww-calendar.lock"
EWW_BIN="$HOME/.local/bin/eww/eww"
run() {
${EWW_BIN} -c $HOME/.config/eww/bar open calendar
}
# Open widgets
if [[ ! -f "$LOCK_FILE" ]]; then
${EWW_BIN} -c $HOME/.config/eww/bar close system music_win audio_ctl
touch "$LOCK_FILE"
run && echo "ok good!"
else
${EWW_BIN} -c $HOME/.config/eww/bar close calendar
rm "$LOCK_FILE" && echo "closed"
fi
}
system() {
LOCK_FILE_MEM="$HOME/.cache/eww-system.lock"
EWW_BIN="$HOME/.local/bin/eww/eww"
run() {
${EWW_BIN} -c $HOME/.config/eww/bar open system
}
# Open widgets
if [[ ! -f "$LOCK_FILE_MEM" ]]; then
${EWW_BIN} -c $HOME/.config/eww/bar close calendar music_win audio_ctl
touch "$LOCK_FILE_MEM"
run && echo "ok good!"
else
${EWW_BIN} -c $HOME/.config/eww/bar close system
rm "$LOCK_FILE_MEM" && echo "closed"
fi
}
music() {
LOCK_FILE_SONG="$HOME/.cache/eww-song.lock"
EWW_BIN="$HOME/.local/bin/eww/eww"
run() {
${EWW_BIN} -c $HOME/.config/eww/bar open music_win
}
# Open widgets
if [[ ! -f "$LOCK_FILE_SONG" ]]; then
${EWW_BIN} -c $HOME/.config/eww/bar close system calendar
touch "$LOCK_FILE_SONG"
run && echo "ok good!"
else
${EWW_BIN} -c $HOME/.config/eww/bar close music_win
rm "$LOCK_FILE_SONG" && echo "closed"
fi
}
audio() {
LOCK_FILE_AUDIO="$HOME/.cache/eww-audio.lock"
EWW_BIN="$HOME/.local/bin/eww/eww"
run() {
${EWW_BIN} -c $HOME/.config/eww/bar open audio_ctl
}
# Open widgets
if [[ ! -f "$LOCK_FILE_AUDIO" ]]; then
${EWW_BIN} -c $HOME/.config/eww/bar close system calendar music
touch "$LOCK_FILE_AUDIO"
run && echo "ok good!"
else
${EWW_BIN} -c $HOME/.config/eww/bar close audio_ctl
rm "$LOCK_FILE_AUDIO" && echo "closed"
fi
}
if [ "$1" = "calendar" ]; then
calendar
elif [ "$1" = "system" ]; then
system
elif [ "$1" = "music" ]; then
music
elif [ "$1" = "audio" ]; then
audio
fi

View file

@ -0,0 +1,26 @@
#!/bin/bash
status=$(nmcli g | grep -oE "disconnected")
essid=$(nmcli c | grep wlp2s0 | awk '{print ($1)}')
if [ $status ] ; then
icon=""
text=""
col="#575268"
else
icon=""
text="${essid}"
col="#a1bdce"
fi
if [[ "$1" == "--COL" ]]; then
echo $col
elif [[ "$1" == "--ESSID" ]]; then
echo $text
elif [[ "$1" == "--ICON" ]]; then
echo $icon
fi

View file

@ -0,0 +1,75 @@
#! /bin/bash
#define icons for workspaces 1-9
ic=(0     輸  " " " " )
# ic=(0 1 2 3 4 5 6 7 8 9)
# ic=(0 一 二 三 四 五 六 七 八 九 )
#initial check for occupied workspaces
for num in $(hyprctl workspaces | grep ID | awk '{print $3}'); do
export o"$num"="$num"
done
#initial check for focused workspace
for num in $(hyprctl monitors | grep -B 4 "focused: yes" | awk 'NR==1{print $3}'); do
export f"$num"="$num"
export fnum=f"$num"
export mon=$(hyprctl monitors | grep -B 2 "\($num\)" | awk 'NR==1{print $2}')
done
workspaces() {
if [[ ${1:0:9} == "workspace" ]] && [[ ${1:11} != "special" ]]; then #set focused workspace
unset -v "$fnum"
num=${1:11}
export f"$num"="$num"
export fnum=f"$num"
elif [[ ${1:0:10} == "focusedmon" ]]; then #set focused workspace following monitor focus change
unset -v "$fnum"
string=${1:12}
num=${string##*,}
export mon=${string/,*/}
export f"$num"="$num"
export fnum=f"$num"
elif [[ ${1:0:13} == "moveworkspace" ]] && [[ ${1##*,} == "$mon" ]]; then #Set focused workspace following swapactiveworkspace
unset -v "$fnum"
string=${1:15}
num=${string/,*/}
export f"$num"="$num"
export fnum=f"$num"
elif [[ ${1:0:15} == "createworkspace" ]]; then #set Occupied workspace
num=${1:17}
export o"$num"="$num"
export onum=o"$num"
elif [[ ${1:0:16} == "destroyworkspace" ]]; then #unset unoccupied workspace
num=${1:18}
unset -v o"$num"
fi
}
module() {
#output eww widget
echo "(eventbox :onscroll \"echo {} | sed -e 's/up/-1/g' -e 's/down/+1/g' | xargs hyprctl dispatch workspace\" \
(box :class \"works\" :orientation \"h\" :spacing 5 :space-evenly \"false\" :valign \"center\" \
(button :onclick \"hyprctl dispatch exec \'~/.config/hypr/themes/winter/scripts/workspace 1\'\" :onrightclick \"hyprctl dispatch workspace 1 && $HOME/.config/hypr/themes/winter/scripts/default_app\" :class \"ws-btn 0$o1$f1\" \"${ic[1]}\") \
(button :onclick \"hyprctl dispatch exec \'~/.config/hypr/themes/winter/scripts/workspace 2\'\" :onrightclick \"hyprctl dispatch workspace 2 && $HOME/.config/hypr/themes/winter/scripts/default_app\" :class \"ws-btn 0$o2$f2\" \"${ic[2]}\") \
(button :onclick \"hyprctl dispatch exec \'~/.config/hypr/themes/winter/scripts/workspace 3\'\" :onrightclick \"hyprctl dispatch workspace 3 && $HOME/.config/hypr/themes/winter/scripts/default_app\" :class \"ws-btn 0$o3$f3\" \"${ic[3]}\") \
(button :onclick \"hyprctl dispatch exec \'~/.config/hypr/themes/winter/scripts/workspace 4\'\" :onrightclick \"hyprctl dispatch workspace 4 && $HOME/.config/hypr/themes/winter/scripts/default_app\" :class \"ws-btn 0$o4$f4\" \"${ic[4]}\") \
(button :onclick \"hyprctl dispatch exec \'~/.config/hypr/themes/winter/scripts/workspace 5\'\" :onrightclick \"hyprctl dispatch workspace 5 && $HOME/.config/hypr/themes/winter/scripts/default_app\" :class \"ws-btn 0$o5$f5\" \"${ic[5]}\") \
(button :onclick \"hyprctl dispatch exec \'~/.config/hypr/themes/winter/scripts/workspace 6\'\" :onrightclick \"hyprctl dispatch workspace 6 && $HOME/.config/hypr/themes/winter/scripts/default_app\" :class \"ws-btn 0$o6$f6\" \"${ic[6]}\") \
(button :onclick \"hyprctl dispatch exec \'~/.config/hypr/themes/winter/scripts/workspace 7\'\" :onrightclick \"hyprctl dispatch workspace 7 && $HOME/.config/hypr/themes/winter/scripts/default_app\" :class \"ws-btn 0$o7$f7\" \"${ic[7]}\") \
(button :onclick \"hyprctl dispatch exec \'~/.config/hypr/themes/winter/scripts/workspace 8\'\" :onrightclick \"hyprctl dispatch workspace 8 && $HOME/.config/hypr/themes/winter/scripts/default_app\" :class \"ws-btn 0$o8$f8\" \"${ic[8]}\") \
(button :onclick \"hyprctl dispatch exec \'~/.config/hypr/themes/winter/scripts/workspace 9\'\" :onrightclick \"hyprctl dispatch workspace 9 && $HOME/.config/hypr/themes/winter/scripts/default_app\" :class \"ws-btn 0$o9$f9\" \"${ic[9]}\") \
(button :onclick \"hyprctl dispatch exec \'~/.config/hypr/themes/winter/scripts/workspace 10\'\" :onrightclick \"hyprctl dispatch workspace 10 && $HOME/.config/hypr/themes/winter/scripts/default_app\" :class \"ws-btn 0$o10$f10\" \"${ic[10]}\") \
)\
)"
}
module
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | while read -r event; do
workspaces "$event"
module
done