refactore directory structure

This commit is contained in:
Chris Cochrun 2023-06-09 06:06:37 -05:00
parent 3830eef1f4
commit e87bfb7c39
485 changed files with 66 additions and 1696 deletions

40
.config/eww/scripts/appname Executable file
View file

@ -0,0 +1,40 @@
#!/usr/bin/env bash
#define icons for workspaces 1-9
#icontheme=$(geticons -U)
icontheme=$(grep "gtk-icon-theme-name" "$HOME"/.config/gtk-3.0/settings.ini | cut --delimiter="=" -f 2)
workspaces() {
# if [[ ${1:0:12} == "activewindowv2" ]]; then
# fi
if [[ ${1:0:12} == "activewindow" ]]; then #set focused workspace
line=$(hyprctl activewindow | rg Window | cut -f 4- -d ' ' | sed 's/://')
class=$(hyprctl activewindow | rg "class:" | awk '{print $2}')
export iconpath=$(geticons "$class" -s 32 -c 1 -t "$icontheme" | head -n 1)
export title=$line
fi
}
module() {
#output eww widget
echo "(box \
:orientation \"h\" \
:halign \"start\" \
:valign \"center\" \
:space-evenly false \
(image \
:class \"app-icon\" \
:path \"$iconpath\" \
:image-width \"18\") \
(label \
:class \"app-name\" \
:limit-width \"45\" \
:text \"$title\" \
:tooltip \"$title\"))"
}
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | while read -r event; do
workspaces "$event"
module
done

17
.config/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

3
.config/eww/scripts/bright Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
brightnessctl | rg Current | awk '{print $4}' | sed 's/(\(.*\)%)/\1/'

@ -0,0 +1 @@
Subproject commit 2f0215d4e1003599a72a9b140ee3abe3c83fa799

15
.config/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
.config/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
.config/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

View file

@ -0,0 +1,55 @@
#!/usr/bin/env bash
tmp=/tmp/dunst-history.json
notif() {
export ids=($(dunstctl history | jq '.data[] | .[].id.data'))
printf "\n (box \
:orientation \"v\" \
:space-evenly \"false\" \
:spacing \"20\" \
:halign \"start\" "
for id in "${ids[@]}"; do
mapfile -t notif < <(jq -r ".data[] | .[] | select(.id.data == $id) | .appname.data, .icon_path.data, .summary.data, .body.data" "$tmp" | sed -r '/^\s*$/d' | sed -e 's/\%/ percent/g')
printf "(eventbox :onclick \"dunstctl history-pop $id && dunstctl action 0 && dunstctl close\" \
(box \
:class \"notification\" \
:orientation \"h\" \
:width 350 \
:space-evenly \"false\" \
(image \
:class \"notification-icon\" \
:path \"${notif[1]}\" \
:image-height 50 \
:image-width 100) \
(box \
:orientation \"v\" \
:space-evenly \"false\" \
:valign \"left\" \
:width 350 \
:spacing 10 \
(label \
:xalign 0 \
:wrap "true" \
:class \"notification-appname\" \
:text \"${notif[0]}\") \
(label \
:xalign 0 \
:wrap "true" \
:class \"notification-summary\" \
:text \"${notif[2]}\") \
(label \
:xalign 0 \
:wrap "true" \
:class \"notification-body\" \
:text \"${notif[3]}\"))))"
done
printf ") \n"
}
notif
tail --follow $tmp 2> /dev/null | grep --line-buffered "aa{sv}" | while read -r; do
notif
done

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

@ -0,0 +1,92 @@
#!/usr/bin/env bash
calendar() {
LOCK_FILE="$HOME/.cache/eww-calendar.lock"
EWW_BIN="$HOME/.local/bin/eww/eww"
run() {
eww open calendar
}
# Open widgets
if [[ ! -f "$LOCK_FILE" ]]; then
eww close system music_win audio_ctl
touch "$LOCK_FILE"
run && echo "ok good!"
else
eww 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 open system
}
# Open widgets
if [[ ! -f "$LOCK_FILE_MEM" ]]; then
eww close calendar music_win audio_ctl
touch "$LOCK_FILE_MEM"
run && echo "ok good!"
else
eww 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 open music_win
}
# Open widgets
if [[ ! -f "$LOCK_FILE_SONG" ]]; then
eww close system calendar
touch "$LOCK_FILE_SONG"
run && echo "ok good!"
else
eww 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 open audio_ctl
}
# Open widgets
if [[ ! -f "$LOCK_FILE_AUDIO" ]]; then
eww close system calendar music
touch "$LOCK_FILE_AUDIO"
run && echo "ok good!"
else
eww 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

29
.config/eww/scripts/wifi Executable file
View file

@ -0,0 +1,29 @@
#!/bin/sh
status=$(nmcli g | grep -oE "disconnected")
essid=$(nmcli -t -f active,ssid dev wifi | grep '^yes' | cut -d: -f2)
device=$(nmcli d | rg -w "connected" | awk '{print $1}')
if [ $status ] ; then
icon="睊"
text=""
col="#575268"
else
if [ $device == "enp0s31f6" ]; then
icon=""
text="ethernet"
col="#a1bdce"
else
icon=""
text="${essid}"
col="#a1bdce"
fi
fi
case $1 in
--COL) echo $col;;
--ESSID) echo $text;;
--ICON) echo $icon;;
esac

67
.config/eww/scripts/workspace Executable file
View file

@ -0,0 +1,67 @@
#!/usr/bin/env bash
#define icons for workspaces 1-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\" :valign \"center\" \
(box :class \"works\" :orientation \"h\" :spacing 5 :space-evenly \"false\" :valign \"center\" \
(button :onclick \"hyprctl dispatch workspace 1\" :onrightclick \"hyprctl dispatch workspace 1 && $HOME/.config/hypr/themes/neon/scripts/default_app\" :class \"0$o1$f1\" \"${ic[1]}\") \
(button :onclick \"hyprctl dispatch workspace 2\" :onrightclick \"hyprctl dispatch workspace 2 && $HOME/.config/hypr/themes/neon/scripts/default_app\" :class \"0$o2$f2\" \"${ic[2]}\") \
(button :onclick \"hyprctl dispatch workspace 3\" :onrightclick \"hyprctl dispatch workspace 3 && $HOME/.config/hypr/themes/neon/scripts/default_app\" :class \"0$o3$f3\" \"${ic[3]}\") \
(button :onclick \"hyprctl dispatch workspace 4\" :onrightclick \"hyprctl dispatch workspace 4 && $HOME/.config/hypr/themes/neon/scripts/default_app\" :class \"0$o4$f4\" \"${ic[4]}\") \
)\
)"
}
module
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | while read -r event; do
workspaces "$event"
module
done