feat : weekly update

This commit is contained in:
coolnsx
2023-11-02 13:06:34 +05:30
parent f81fc475b4
commit 61d772b93d
10 changed files with 269 additions and 265 deletions

View File

@@ -1,16 +1,17 @@
#!/bin/sh #!/bin/sh
datadir="/tmp/yt-music"
case $1 in case $1 in
songdata) songdata)
out=$(printf '{ "command": ["get_property", "pause"]}\n' | socat - /tmp/yt-music/yt-music-mpvsocket 2>/dev/null) if [ -f "$datadir/current" ];then
if [ -n "$out" ] && pgrep -f mpvsocket >/dev/null 2>&1;then out=$(printf '{ "command": ["get_property", "pause"]}\n' | socat - "$datadir/yt-music-mpvsocket" 2>/dev/null)
printf '{"name":"%s","artist":"%s","cover":"/tmp/yt-music/default.jpg","next":"%s","prev":"%s"}' "$(cut -d'>' -f1 < "/tmp/yt-music/current" | cut -d':' -f2- | sed 's|[^-]*$||;s|-$||;s| $||;s|^ ||')" "$(cut -d'>' -f1 < "/tmp/yt-music/current" | sed 's_.* - __;s| $||')" "$(sed -n "/$(cut -d'>' -f2 < /tmp/yt-music/current )/{n;p}" /tmp/yt-music/next | cut -f1)" "$(sed -n "$(cat /tmp/yt-music/counter)p" /tmp/yt-music/next | cut -f1)" printf '{"name":"%s","artist":"%s","cover":"%s","next":"%s","prev":"%s"}' "$(cut -d'>' -f1 < "$datadir/current" | cut -d':' -f2- | sed 's|[^-]*$||;s|-$||;s| $||;s|^ ||')" "$(cut -d'>' -f1 < "$datadir/current" | sed 's_.* - __;s| $||')" "$datadir/default.jpg" "$(sed -n "/$(cut -d'>' -f2 < "$datadir/current" )/{n;p}" $datadir/next | cut -f1)" "$(sed -n "$(cat $datadir/counter)p" $datadir/next | cut -f1)"
else else
printf '{"name":"OFFLINE","artist":"offline","cover":"%s/.config/eww/music.png"}' "$HOME" printf '{"name":"OFFLINE","artist":"offline","cover":"%s/.config/eww/music.png"}' "$HOME"
fi fi
;; ;;
status) status)
out=$(printf '{ "command": ["get_property", "pause"]}\n' | socat - /tmp/yt-music/yt-music-mpvsocket 2>/dev/null) out=$(printf '{ "command": ["get_property", "pause"]}\n' | socat - "$datadir/yt-music-mpvsocket" 2>/dev/null)
if [ -z "$out" ];then if [ -z "$out" ];then
printf "" printf ""
elif printf "%s" "$out" | grep -q "true";then elif printf "%s" "$out" | grep -q "true";then
@@ -20,29 +21,26 @@ case $1 in
fi fi
;; ;;
lyrics) lyrics)
if [ -f "/tmp/yt-music/lyrics" ]; then if [ -f "$datadir/lyrics" ]; then
awk -F'\t' -v value="$(echo '{ "command": ["get_property", "time-pos"] }' | socat - /tmp/yt-music/yt-music-mpvsocket | sed -nE 's|.*data":([^,]*).*|\1|p')" '$1 > value*1000 {print $2;exit}' /tmp/yt-music/lyrics awk -F'\t' -v value="$(echo '{ "command": ["get_property", "time-pos"] }' | socat - "$datadir/yt-music-mpvsocket" | sed -nE 's|.*data":([^,]*).*|\1|p')" '$1 > value*1000 {print $2;exit}' "$datadir/lyrics"
else else
printf "Lyrics will show here" printf "Lyrics will show here"
fi fi
;; ;;
time) time)
out=$(echo '{"command" :["get_property" , "percent-pos"]}' | socat - /tmp/yt-music/yt-music-mpvsocket 2>/dev/null | sed -nE 's_.*data":([^,]*).*_\1_p') out=$(echo '{"command" :["get_property" , "percent-pos"]}' | socat - "$datadir/yt-music-mpvsocket" 2>/dev/null | sed -nE 's_.*data":([^,]*).*_\1_p')
printf '%s' "${out:-100}" printf '%s' "${out:-100}"
;; ;;
play_toggle) play_toggle)
echo cycle pause | socat - "/tmp/yt-music/yt-music-mpvsocket" echo cycle pause | socat - "$datadir/yt-music-mpvsocket"
;; ;;
next) next)
pgrep -f mpvsocket >/dev/null 2>&1 && "$HOME/repos_scripts/yt-music" play_next pgrep -f mpvsocket >/dev/null 2>&1 && "$HOME/repos_scripts/yt-music" play_next
;; ;;
next_song)
sed -n "$(cat /tmp/yt-music/counter){n;p}" /tmp/yt-music/next | cut -f1
;;
prev) prev)
pgrep -f mpvsocket >/dev/null 2>&1 && counter=$(cat /tmp/yt-music/counter) && [ "$counter" -gt 0 ] && "$HOME/repos_scripts/yt-music" play "$(sed -n "${counter}p" /tmp/yt-music/next)" && printf "%s" "$((counter-1))" > /tmp/yt-music/counter & pgrep -f mpvsocket >/dev/null 2>&1 && counter=$(cat "$datadir/counter") && [ "$counter" -gt 0 ] && "$HOME/repos_scripts/yt-music" play "$(sed -n "${counter}p" "$datadir/next")" && printf "%s" "$((counter-1))" > "$datadir/counter" &
;; ;;
seek) seek)
echo "{\"command\" :[\"seek\" ,\"$2\",\"relative-percent\"]}" | socat - /tmp/yt-music/yt-music-mpvsocket echo "{\"command\" :[\"seek\" ,\"$2\",\"relative-percent\"]}" | socat - "$datadir/yt-music-mpvsocket"
;; ;;
esac esac

View File

@@ -9,12 +9,12 @@ oshi_file="$HOME/.cache/oshi-urls"
case $1 in case $1 in
add) add)
if [ -z "$data" ];then if [ -z "$data" ]; then
notify-send "Please select anything to bookmark" notify-send "Please select anything to bookmark"
elif grep -q "${data}" "$file";then elif grep -q "${data}" "$file"; then
notify-send -i "bookmark-missing" "Already bookmarked" notify-send -i "bookmark-missing" "Already bookmarked"
else else
printf "%s" "$data" >> "$file" printf "%s" "$data" >>"$file"
notify-send -i "user-bookmarks" "Bookmarked" "$data" notify-send -i "user-bookmarks" "Bookmarked" "$data"
fi fi
;; ;;
@@ -29,7 +29,7 @@ case $1 in
;; ;;
*) *)
result="$(sed '/^$/d' "$file" "$oshi_file" | sed -E 's/.*DL: ([^|]*).*/\1/g' | bemenu --fn 'Roboto 15' -i -c -W 0.6 -B 3 -l 30 -p "Put-bookmark :" | tr '\`' '\n')" result="$(sed '/^$/d' "$file" "$oshi_file" | sed -E 's/.*DL: ([^|]*).*/\1/g' | bemenu --fn 'Roboto 15' -i -c -W 0.6 -B 3 -l 30 -p "Put-bookmark :" | tr '\`' '\n')"
if printf '%s' "$result" | grep -q 'B>';then if printf '%s' "$result" | grep -q 'B>'; then
google-chrome-stable "$(printf '%s' "$result" | cut -d'>' -f2- | tr -d '\n ')" google-chrome-stable "$(printf '%s' "$result" | cut -d'>' -f2- | tr -d '\n ')"
else else
wtype -d 10 "$result" wtype -d 10 "$result"
@@ -38,4 +38,4 @@ case $1 in
esac esac
sed -i '/^$/d' "$file" sed -i '/^$/d' "$file"
printf "\n" >> "$file" printf "\n" >>"$file"

View File

@@ -1,8 +1,8 @@
#!/bin/sh #!/bin/sh
i=5 i=5
while [ $i -gt 0 ];do while [ $i -gt 0 ]; do
notify-send -i "/usr/share/icons/Papirus/16x16/panel/clockify-blue.svg" "$(date)" -h "string:x-canonical-private-synchronous:${0##*/}" -t 1200 & notify-send -i "/usr/share/icons/Papirus/16x16/panel/clockify-blue.svg" "$(date)" -h "string:x-canonical-private-synchronous:${0##*/}" -t 1200 &
sleep 1 sleep 1
: $((i-=1)) : $((i -= 1))
done done

View File

@@ -1,5 +1,5 @@
# See https://wiki.hyprland.org/Configuring/Monitors/ # See https://wiki.hyprland.org/Configuring/Monitors/
monitor=,preferred,auto,1 monitor=,highrr,auto,1
$hypr_dir="$HOME/.config/hypr" $hypr_dir="$HOME/.config/hypr"
# See https://wiki.hyprland.org/Configuring/Keywords/ for more # See https://wiki.hyprland.org/Configuring/Keywords/ for more
@@ -172,5 +172,5 @@ exec-once=cd $HOME/github/arrpc && node src > /tmp/arrpc-log
exec-once=swaybg -i $HOME/.config/wall/12.jpg exec-once=swaybg -i $HOME/.config/wall/12.jpg
exec-once=xrdb -merge $HOME/.config/.Xresource exec-once=xrdb -merge $HOME/.config/.Xresource
exec-once=$hypr_dir/workspace 'focus' exec-once=$hypr_dir/workspace 'focus'
exec-once=sleep 5 && $hypr_dir/workspace exec-once=sleep 2 && $hypr_dir/workspace
exec-once=sleep 2 && google-chrome-stable 'https://web.skype.com/?openPstnPage=true' exec-once=sleep 2 && google-chrome-stable 'https://web.skype.com/?openPstnPage=true'

View File

@@ -1,9 +1,9 @@
#!/bin/sh #!/bin/sh
i=1 i=1
while [ $i -le 5 ];do while [ $i -le 5 ]; do
mem=$(sed -nE 's_.*MemAvailable:[[:space:]]*(.*) kB_\1_p' /proc/meminfo) mem=$(sed -nE 's_.*MemAvailable:[[:space:]]*(.*) kB_\1_p' /proc/meminfo)
mem="$(((7919488 - mem)/1000))" mem="$(((7919488 - mem) / 1000))"
temp=$(cat /sys/class/thermal/thermal_zone0/temp) temp=$(cat /sys/class/thermal/thermal_zone0/temp)
temp=$((temp / 1000)) temp=$((temp / 1000))
bat_stats=$(cat /sys/class/power_supply/BAT*/status) bat_stats=$(cat /sys/class/power_supply/BAT*/status)
@@ -11,6 +11,6 @@ while [ $i -le 5 ];do
[ "$bat_stats" = "Discharging" ] && bat_icon=🔋 || bat_icon=🔌 [ "$bat_stats" = "Discharging" ] && bat_icon=🔋 || bat_icon=🔌
[ "$vol_stats" = "true" ] && vol_icon=🔇 || vol_icon=🔊 [ "$vol_stats" = "true" ] && vol_icon=🔇 || vol_icon=🔊
notify-send -i "lol" "<----------(STATS)---------->" "🧠 CPU usage : $(top -ibn1 | sed -nE 's_%Cpu\(s\):(.*)us.*_\1_p' | cut -d' ' -f2-3) %\n🌡 Cpu Temp : $temp °C\n🔳 RAM : $mem MB / 7733 MB\n$bat_icon Battery : $(cat /sys/class/power_supply/BAT*/capacity) (${bat_stats})\n☀ Brightness : $(light -G | cut -d'.' -f1)%\n$vol_icon Volume : $(pamixer --get-volume-human)\n🎵 $(pgrep -af mpvsocket >/dev/null && cut -d ">" -f1 /tmp/yt-music/current | cut -d":" -f2)" -h "string:x-canonical-private-synchronous:${0##*/}" -t 1500 & notify-send -i "lol" "<----------(STATS)---------->" "🧠 CPU usage : $(top -ibn1 | sed -nE 's_%Cpu\(s\):(.*)us.*_\1_p' | cut -d' ' -f2-3) %\n🌡 Cpu Temp : $temp °C\n🔳 RAM : $mem MB / 7733 MB\n$bat_icon Battery : $(cat /sys/class/power_supply/BAT*/capacity) (${bat_stats})\n☀ Brightness : $(light -G | cut -d'.' -f1)%\n$vol_icon Volume : $(pamixer --get-volume-human)\n🎵 $(pgrep -af mpvsocket >/dev/null && cut -d ">" -f1 /tmp/yt-music/current | cut -d":" -f2)" -h "string:x-canonical-private-synchronous:${0##*/}" -t 1500 &
: $((i+=1)) : $((i += 1))
sleep 1 sleep 1
done done

View File

@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
if nmcli radio wifi | grep -q 'enabled' ; then if nmcli radio wifi | grep -q 'enabled'; then
nmcli radio wifi off nmcli radio wifi off
wifi_icon="offline" wifi_icon="offline"
else else

View File

@@ -1,9 +1,9 @@
#!/bin/sh #!/bin/sh
setup_dual_monitor(){ setup_dual_monitor() {
sed -i "s/monitor=,1920x1080,0x0,1,mirror,eDP-1/monitor=,preferred,auto,1/g" "$HOME/.config/hypr/hyprland.conf" sed -i "s/monitor=,1920x1080,0x0,1,mirror,eDP-1/monitor=,highrr,auto,1/g" "$HOME/.config/hypr/hyprland.conf"
sleep 2 sleep 2
if hyprctl monitors | grep -q "HDMI-A-1";then if hyprctl monitors | grep -q "HDMI-A-1"; then
notify-send "Setting up dual monitor workflow" notify-send "Setting up dual monitor workflow"
hyprctl dispatch moveworkspacetomonitor "1 0" hyprctl dispatch moveworkspacetomonitor "1 0"
hyprctl dispatch moveworkspacetomonitor "2 0" hyprctl dispatch moveworkspacetomonitor "2 0"
@@ -14,12 +14,12 @@ setup_dual_monitor(){
fi fi
} }
handle_it(){ handle_it() {
[ -z "$1" ] || notify-send "$1" [ -z "$1" ] || notify-send "$1"
choice=$(printf "Mirror\nExtend" | bemenu --fn 'Roboto 15' -i -c -W 0.2 -B 3 -l 20 -p "what to do??: " -m 1) choice=$(printf "Mirror\nExtend" | bemenu --fn 'Roboto 15' -i -c -W 0.2 -B 3 -l 20 -p "what to do??: " -m 1)
[ -z "$choice" ] && return 0 [ -z "$choice" ] && return 0
notify-send "${choice}ing screen" notify-send "${choice}ing screen"
if [ "$choice" = "Extend" ];then if [ "$choice" = "Extend" ]; then
setup_dual_monitor setup_dual_monitor
else else
sed -i "s/monitor=,highrr,auto,1/monitor=,1920x1080,0x0,1,mirror,eDP-1/g" "$HOME/.config/hypr/hyprland.conf" sed -i "s/monitor=,highrr,auto,1/monitor=,1920x1080,0x0,1,mirror,eDP-1/g" "$HOME/.config/hypr/hyprland.conf"
@@ -29,27 +29,33 @@ handle_it(){
case $1 in case $1 in
list) list)
#only lists the open applications with their workspace number so u can safely close them #only lists the open applications with their workspace number so u can safely close them
for i in $(seq 4);do i=4
while [ $i -gt 0 ]; do
notify-send -i "lol" "$(hyprctl clients | sed -nE 's_.*class: ([^ ]*).*_\1_p;s_.*workspace: ([^ ]*).*_workspace \1 : _p' | sed 'N;s/\n/ /')" -h "string:x-canonical-private-synchronous:${0##*/}" -t 1500 notify-send -i "lol" "$(hyprctl clients | sed -nE 's_.*class: ([^ ]*).*_\1_p;s_.*workspace: ([^ ]*).*_workspace \1 : _p' | sed 'N;s/\n/ /')" -h "string:x-canonical-private-synchronous:${0##*/}" -t 1500
: $((i -= 1))
sleep 1 sleep 1
done ;; done
;;
focus) focus)
#shows the workspace number as notification whenever u switch workspaces and also handles the dual monitor setup on the fly(perfect for laptop users) #shows the workspace number as notification whenever u switch workspaces and also handles the dual monitor setup on the fly(perfect for laptop users)
socat - "UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" | while read -r line;do socat - "UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" | while read -r line; do
printf "%s" "$line" | grep -q "monitoradded" && handle_it "$line" printf "%s" "$line" | grep -q "monitoradded" && handle_it "$line"
printf "%s" "$line" | grep -q "monitorremoved" && sed -i "s/monitor=,1920x1080,0x0,1,mirror,eDP-1/monitor=,highrr,auto,1/g" "$HOME/.config/hypr/hyprland.conf" && eww kill && eww open_many time_0 music_0 printf "%s" "$line" | grep -q "monitorremoved" && sed -i "s/monitor=,1920x1080,0x0,1,mirror,eDP-1/monitor=,highrr,auto,1/g" "$HOME/.config/hypr/hyprland.conf" && eww kill && eww open_many time_0 music_0
#recent workspace switcher #recent workspace switcher
current=$(printf "%s" "$line" | sed -nE 's_^(workspace)>>([^ ]*)_\1 \2_p') current=$(printf "%s" "$line" | sed -nE 's_^(workspace)>>([^ ]*)_\1 \2_p')
if [ -n "$current" ];then if [ -n "$current" ]; then
cat /tmp/workcurr > /tmp/workprev cat /tmp/workcurr >/tmp/workprev
printf "%s" "$current" > /tmp/workcurr printf "%s" "$current" >/tmp/workcurr
fi fi
notify-send -i "lol" "$(printf "%s" "$line" | sed -nE 's_^(workspace)>>([^ ]*)_\1 \2_p')" -h 'string:x-canonical-private-synchronous:monitor' -t 700 2>/dev/null notify-send -i "lol" "$(printf "%s" "$line" | sed -nE 's_^(workspace)>>([^ ]*)_\1 \2_p')" -h "string:x-canonical-private-synchronous:monitor" -t 700 2>/dev/null
done ;; done
;;
toggle) toggle)
#toggle between mirror and extend setup. this function should be keybinded #toggle between mirror and extend setup. this function should be keybinded
handle_it ;; handle_it
;;
*) *)
#to be executed once after booting to setup dual montiors by default if the monitor is connected #to be executed once after booting to setup dual montiors by default if the monitor is connected
setup_dual_monitor ;; setup_dual_monitor
;;
esac esac