updates for eww and ydotool

This commit is contained in:
Chris Cochrun 2022-11-19 05:54:20 -06:00
parent f153a71270
commit 25853d63db
19 changed files with 1147 additions and 31 deletions

17
eww/scripts/battery Executable file
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

15
eww/scripts/mem-ad Executable file
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

3
eww/scripts/memory Executable file
View file

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

98
eww/scripts/music_info Executable file
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/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

26
eww/scripts/wifi Executable file
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

56
eww/scripts/workspace Executable file
View file

@ -0,0 +1,56 @@
#!/bin/sh
workspaces() {
ws1="1"
ws2="2"
ws3="3"
ws4="4"
ws5="5"
ws6="6"
# Unoccupied
un="0"
# check if Occupied
o1=$(bspc query -D -d .occupied --names | grep "$ws1" )
o2=$(bspc query -D -d .occupied --names | grep "$ws2" )
o3=$(bspc query -D -d .occupied --names | grep "$ws3" )
o4=$(bspc query -D -d .occupied --names | grep "$ws4" )
o5=$(bspc query -D -d .occupied --names | grep "$ws5" )
o6=$(bspc query -D -d .occupied --names | grep "$ws6" )
# check if Focused
f1=$(bspc query -D -d focused --names | grep "$ws1" )
f2=$(bspc query -D -d focused --names | grep "$ws2" )
f3=$(bspc query -D -d focused --names | grep "$ws3" )
f4=$(bspc query -D -d focused --names | grep "$ws4" )
f5=$(bspc query -D -d focused --names | grep "$ws5" )
f6=$(bspc query -D -d focused --names | grep "$ws6" )
ic_1=""
ic_2=""
ic_3=""
ic_4=""
ic_5=""
ic_6=""
if [ $f1 ]; then
ic_1=""
elif [ $f2 ]; then
ic_2=""
elif [ $f3 ]; then
ic_3=""
elif [ $f4 ]; then
ic_4=""
elif [ $f5 ]; then
ic_5=""
elif [ $f6 ]; then
ic_6=""
fi
echo "(box :class \"works\" :orientation \"h\" :spacing 5 :space-evenly \"false\" (button :onclick \"bspc desktop -f $ws1\" :class \"$un$o1$f1\" \"$ic_1\") (button :onclick \"bspc desktop -f $ws2\" :class \"$un$o2$f2\" \"$ic_2\") (button :onclick \"bspc desktop -f $ws3\" :class \"$un$o3$f3\" \"$ic_3\") (button :onclick \"bspc desktop -f $ws4\" :class \"$un$o4$f4\" \"$ic_4\") (button :onclick \"bspc desktop -f $ws5\" :class \"$un$o5$f5\" \"$ic_5\") (button :onclick \"bspc desktop -f $ws6\" :class \"$un$o6$f6\" \"$ic_6\"))"
}
workspaces
bspc subscribe desktop node_transfer | while read -r _ ; do
workspaces
done