From 61d772b93d069237f36f041f9f80283f4afd288e Mon Sep 17 00:00:00 2001 From: coolnsx Date: Thu, 2 Nov 2023 13:06:34 +0530 Subject: [PATCH] feat : weekly update --- eww/script | 24 ++- hypr/bkmark | 30 ++-- hypr/bluetooth | 406 ++++++++++++++++++++++----------------------- hypr/date | 4 +- hypr/hyprland.conf | 4 +- hypr/info | 24 +-- hypr/launch | 2 +- hypr/screenshot | 2 +- hypr/wifi | 2 +- hypr/workspace | 36 ++-- 10 files changed, 269 insertions(+), 265 deletions(-) diff --git a/eww/script b/eww/script index 27c846d..27c4898 100755 --- a/eww/script +++ b/eww/script @@ -1,16 +1,17 @@ #!/bin/sh +datadir="/tmp/yt-music" case $1 in songdata) - out=$(printf '{ "command": ["get_property", "pause"]}\n' | socat - /tmp/yt-music/yt-music-mpvsocket 2>/dev/null) - if [ -n "$out" ] && pgrep -f mpvsocket >/dev/null 2>&1;then - 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)" + if [ -f "$datadir/current" ];then + out=$(printf '{ "command": ["get_property", "pause"]}\n' | socat - "$datadir/yt-music-mpvsocket" 2>/dev/null) + 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 printf '{"name":"OFFLINE","artist":"offline","cover":"%s/.config/eww/music.png"}' "$HOME" fi ;; 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 printf "" elif printf "%s" "$out" | grep -q "true";then @@ -20,29 +21,26 @@ case $1 in fi ;; lyrics) - if [ -f "/tmp/yt-music/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 + if [ -f "$datadir/lyrics" ]; then + 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 printf "Lyrics will show here" fi ;; 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}" ;; play_toggle) - echo cycle pause | socat - "/tmp/yt-music/yt-music-mpvsocket" + echo cycle pause | socat - "$datadir/yt-music-mpvsocket" ;; 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) - 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) - 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 diff --git a/hypr/bkmark b/hypr/bkmark index 536ce30..d06c889 100755 --- a/hypr/bkmark +++ b/hypr/bkmark @@ -7,29 +7,29 @@ data="$(wl-paste -p | tr '\n' '\`' | sed 's/$/ /g')" file="$HOME/.cache/bookmarks" oshi_file="$HOME/.cache/oshi-urls" -case $1 in +case $1 in add) - if [ -z "$data" ];then - notify-send "Please select anything to bookmark" - elif grep -q "${data}" "$file";then - notify-send -i "bookmark-missing" "Already bookmarked" - else - printf "%s" "$data" >> "$file" - notify-send -i "user-bookmarks" "Bookmarked" "$data" - fi + if [ -z "$data" ]; then + notify-send "Please select anything to bookmark" + elif grep -q "${data}" "$file"; then + notify-send -i "bookmark-missing" "Already bookmarked" + else + printf "%s" "$data" >>"$file" + notify-send -i "user-bookmarks" "Bookmarked" "$data" + fi ;; rm) - data="$(sed '/^$/d' "$file" | nl -n'ln')" - [ -z "$data" ] && notify-send "Bookmark is empty" && exit 0 - del=$(printf "%s" "$data" | bemenu --fn 'Roboto 15' -i -c -W 0.6 -B 3 -l 30 -p "delete-bookmark :" | cut -f1) - [ -z "$del" ] || (sed -i "${del}d" "$file" && notify-send -i "bookmark-missing" "Bookmark deleted" -u critical) + data="$(sed '/^$/d' "$file" | nl -n'ln')" + [ -z "$data" ] && notify-send "Bookmark is empty" && exit 0 + del=$(printf "%s" "$data" | bemenu --fn 'Roboto 15' -i -c -W 0.6 -B 3 -l 30 -p "delete-bookmark :" | cut -f1) + [ -z "$del" ] || (sed -i "${del}d" "$file" && notify-send -i "bookmark-missing" "Bookmark deleted" -u critical) ;; copy) 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' | wl-copy && notify-send "Copied to clipboard" -i "com.github.davidmhewitt.clipped" ;; *) 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 ')" else wtype -d 10 "$result" @@ -38,4 +38,4 @@ case $1 in esac sed -i '/^$/d' "$file" -printf "\n" >> "$file" +printf "\n" >>"$file" diff --git a/hypr/bluetooth b/hypr/bluetooth index bf7a26e..ef546aa 100755 --- a/hypr/bluetooth +++ b/hypr/bluetooth @@ -23,280 +23,280 @@ goback="Back" # Checks if bluetooth controller is powered on power_on() { - if bluetoothctl show | grep -F -q "Powered: yes"; then - return 0 - else - return 1 - fi + if bluetoothctl show | grep -F -q "Powered: yes"; then + return 0 + else + return 1 + fi } # Toggles power state toggle_power() { - if power_on; then - bluetoothctl power off - show_menu - else - if rfkill list bluetooth | grep -F -q 'blocked: yes'; then - rfkill unblock bluetooth && sleep 3 - fi - bluetoothctl power on - show_menu - fi + if power_on; then + bluetoothctl power off + show_menu + else + if rfkill list bluetooth | grep -F -q 'blocked: yes'; then + rfkill unblock bluetooth && sleep 3 + fi + bluetoothctl power on + show_menu + fi } # Checks if controller is scanning for new devices scan_on() { - if bluetoothctl show | grep -F -q "Discovering: yes"; then - echo "Scan: on" - return 0 - else - echo "Scan: off" - return 1 - fi + if bluetoothctl show | grep -F -q "Discovering: yes"; then + echo "Scan: on" + return 0 + else + echo "Scan: off" + return 1 + fi } # Toggles scanning state toggle_scan() { - if scan_on; then - kill "$(pgrep -F -f "bluetoothctl scan on")" - bluetoothctl scan off - show_menu - else - bluetoothctl scan on & - echo "Scanning..." - sleep 5 - show_menu - fi + if scan_on; then + kill "$(pgrep -F -f "bluetoothctl scan on")" + bluetoothctl scan off + show_menu + else + bluetoothctl scan on & + echo "Scanning..." + sleep 5 + show_menu + fi } # Checks if controller is able to pair to devices pairable_on() { - if bluetoothctl show | grep -F -q "Pairable: yes"; then - echo "Pairable: on" - return 0 - else - echo "Pairable: off" - return 1 - fi + if bluetoothctl show | grep -F -q "Pairable: yes"; then + echo "Pairable: on" + return 0 + else + echo "Pairable: off" + return 1 + fi } # Toggles pairable state toggle_pairable() { - if pairable_on; then - bluetoothctl pairable off - show_menu - else - bluetoothctl pairable on - show_menu - fi + if pairable_on; then + bluetoothctl pairable off + show_menu + else + bluetoothctl pairable on + show_menu + fi } # Checks if controller is discoverable by other devices discoverable_on() { - if bluetoothctl show | grep -F -q "Discoverable: yes"; then - echo "Discoverable: on" - return 0 - else - echo "Discoverable: off" - return 1 - fi + if bluetoothctl show | grep -F -q "Discoverable: yes"; then + echo "Discoverable: on" + return 0 + else + echo "Discoverable: off" + return 1 + fi } # Toggles discoverable state toggle_discoverable() { - if discoverable_on; then - bluetoothctl discoverable off - show_menu - else - bluetoothctl discoverable on - show_menu - fi + if discoverable_on; then + bluetoothctl discoverable off + show_menu + else + bluetoothctl discoverable on + show_menu + fi } # Checks if a device is connected device_connected() { - device_info=$(bluetoothctl info "$1") - if echo "$device_info" | grep -F -q "Connected: yes"; then - return 0 - else - return 1 - fi + device_info=$(bluetoothctl info "$1") + if echo "$device_info" | grep -F -q "Connected: yes"; then + return 0 + else + return 1 + fi } # Toggles device connection toggle_connection() { - if device_connected "$1"; then - bluetoothctl disconnect "$1" - # device_menu "$device" - else - bluetoothctl connect "$1" - # device_menu "$device" - fi + if device_connected "$1"; then + bluetoothctl disconnect "$1" + # device_menu "$device" + else + bluetoothctl connect "$1" + # device_menu "$device" + fi } # Checks if a device is paired device_paired() { - device_info=$(bluetoothctl info "$1") - if echo "$device_info" | grep -F -q "Paired: yes"; then - echo "Paired: yes" - return 0 - else - echo "Paired: no" - return 1 - fi + device_info=$(bluetoothctl info "$1") + if echo "$device_info" | grep -F -q "Paired: yes"; then + echo "Paired: yes" + return 0 + else + echo "Paired: no" + return 1 + fi } # Toggles device paired state toggle_paired() { - if device_paired "$1"; then - bluetoothctl remove "$1" - device_menu "$device" - else - bluetoothctl pair "$1" - device_menu "$device" - fi + if device_paired "$1"; then + bluetoothctl remove "$1" + device_menu "$device" + else + bluetoothctl pair "$1" + device_menu "$device" + fi } # Checks if a device is trusted device_trusted() { - device_info=$(bluetoothctl info "$1") - if echo "$device_info" | grep -F -q "Trusted: yes"; then - echo "Trusted: yes" - return 0 - else - echo "Trusted: no" - return 1 - fi + device_info=$(bluetoothctl info "$1") + if echo "$device_info" | grep -F -q "Trusted: yes"; then + echo "Trusted: yes" + return 0 + else + echo "Trusted: no" + return 1 + fi } # Toggles device connection toggle_trust() { - if device_trusted "$1"; then - bluetoothctl untrust "$1" - device_menu "$device" - else - bluetoothctl trust "$1" - device_menu "$device" - fi + if device_trusted "$1"; then + bluetoothctl untrust "$1" + device_menu "$device" + else + bluetoothctl trust "$1" + device_menu "$device" + fi } # Prints a short string with the current bluetooth status # Useful for status bars like polybar, etc. print_status() { - if power_on; then - printf '' + if power_on; then + printf '' - mapfile -t paired_devices < <(bluetoothctl paired-devices | grep -F Device | cut -d ' ' -f 2) - counter=0 + mapfile -t paired_devices < <(bluetoothctl paired-devices | grep -F Device | cut -d ' ' -f 2) + counter=0 - for device in "${paired_devices[@]}"; do - if device_connected "$device"; then - device_alias="$(bluetoothctl info "$device" | grep -F "Alias" | cut -d ' ' -f 2-)" + for device in "${paired_devices[@]}"; do + if device_connected "$device"; then + device_alias="$(bluetoothctl info "$device" | grep -F "Alias" | cut -d ' ' -f 2-)" - if [ $counter -gt 0 ]; then - printf ", %s" "$device_alias" - else - printf " %s" "$device_alias" - fi + if [ $counter -gt 0 ]; then + printf ", %s" "$device_alias" + else + printf " %s" "$device_alias" + fi - ((counter++)) - fi - done - printf "\n" - else - echo "" - fi + ((counter++)) + fi + done + printf "\n" + else + echo "" + fi } # A submenu for a specific device that allows connecting, pairing, and trusting device_menu() { - device=$1 + device=$1 - # Get device name and mac address - device_name="$(echo "$device" | cut -d ' ' -f 3-)" - mac="$(echo "$device" | cut -d ' ' -f 2)" + # Get device name and mac address + device_name="$(echo "$device" | cut -d ' ' -f 3-)" + mac="$(echo "$device" | cut -d ' ' -f 2)" - # Build options - if device_connected "$mac"; then - connected="Connected: yes" - else - connected="Connected: no" - fi - paired=$(device_paired "$mac") - trusted=$(device_trusted "$mac") - options="$connected\n$paired\n$trusted\n$divider\n$goback\nExit" + # Build options + if device_connected "$mac"; then + connected="Connected: yes" + else + connected="Connected: no" + fi + paired=$(device_paired "$mac") + trusted=$(device_trusted "$mac") + options="$connected\n$paired\n$trusted\n$divider\n$goback\nExit" - # Open dmenu menu, read chosen option - chosen="$(echo -e "$options" | run_dmenu "$device_name")" + # Open dmenu menu, read chosen option + chosen="$(echo -e "$options" | run_dmenu "$device_name")" - # Match chosen option to command - case $chosen in - "" | "$divider") - echo "No option chosen." - ;; - "$connected") - toggle_connection "$mac" - ;; - "$paired") - toggle_paired "$mac" - ;; - "$trusted") - toggle_trust "$mac" - ;; - "$goback") - show_menu - ;; - esac + # Match chosen option to command + case $chosen in + "" | "$divider") + echo "No option chosen." + ;; + "$connected") + toggle_connection "$mac" + ;; + "$paired") + toggle_paired "$mac" + ;; + "$trusted") + toggle_trust "$mac" + ;; + "$goback") + show_menu + ;; + esac } # Opens a dmenu menu with current bluetooth status and options to connect show_menu() { - # Get menu options - if power_on; then - power="Power: on" + # Get menu options + if power_on; then + power="Power: on" - # Human-readable names of devices, one per line - # If scan is off, will only list paired devices - devices=$(bluetoothctl devices | grep -F Device | cut -d ' ' -f 3-) + # Human-readable names of devices, one per line + # If scan is off, will only list paired devices + devices=$(bluetoothctl devices | grep -F Device | cut -d ' ' -f 3-) - # Get controller flags - scan=$(scan_on) - pairable=$(pairable_on) - discoverable=$(discoverable_on) + # Get controller flags + scan=$(scan_on) + pairable=$(pairable_on) + discoverable=$(discoverable_on) - # Options passed to dmenu - options="$devices\n$divider\n$power\n$scan\n$pairable\n$discoverable\nExit" - else - power="Power: off" - options="$power\nExit" - fi + # Options passed to dmenu + options="$devices\n$divider\n$power\n$scan\n$pairable\n$discoverable\nExit" + else + power="Power: off" + options="$power\nExit" + fi - # Open dmenu menu, read chosen option - chosen="$(echo -e "$options" | run_dmenu "Bluetooth")" + # Open dmenu menu, read chosen option + chosen="$(echo -e "$options" | run_dmenu "Bluetooth")" - # Match chosen option to command - case $chosen in - "" | "$divider") - echo "No option chosen." - ;; - "$power") - toggle_power - ;; - "$scan") - toggle_scan - ;; - "$discoverable") - toggle_discoverable - ;; - "$pairable") - toggle_pairable - ;; - *) - device=$(bluetoothctl devices | grep -F "$chosen") - # Open a submenu if a device is selected - if [[ $device ]]; then device_menu "$device"; fi - ;; - esac + # Match chosen option to command + case $chosen in + "" | "$divider") + echo "No option chosen." + ;; + "$power") + toggle_power + ;; + "$scan") + toggle_scan + ;; + "$discoverable") + toggle_discoverable + ;; + "$pairable") + toggle_pairable + ;; + *) + device=$(bluetoothctl devices | grep -F "$chosen") + # Open a submenu if a device is selected + if [[ $device ]]; then device_menu "$device"; fi + ;; + esac } original_args=("$@") @@ -304,14 +304,14 @@ original_args=("$@") # dmenu command to pipe into. Extra arguments to dmenu-bluetooth are passed through to dmenu. This # allows the user to set fonts, sizes, colours, etc. run_dmenu() { - bemenu "${original_args[@]}" --fn 'Roboto 16' -i -l 10 -c -W 0.4 -B 3 -p "$1" + bemenu "${original_args[@]}" --fn 'Roboto 16' -i -l 10 -c -W 0.4 -B 3 -p "$1" } case "$1" in - --status) - print_status - ;; - *) - show_menu - ;; + --status) + print_status + ;; + *) + show_menu + ;; esac diff --git a/hypr/date b/hypr/date index cef0e50..b4f5ab3 100755 --- a/hypr/date +++ b/hypr/date @@ -1,8 +1,8 @@ #!/bin/sh 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 & sleep 1 - : $((i-=1)) + : $((i -= 1)) done diff --git a/hypr/hyprland.conf b/hypr/hyprland.conf index e682ea0..2cbac84 100644 --- a/hypr/hyprland.conf +++ b/hypr/hyprland.conf @@ -1,5 +1,5 @@ # See https://wiki.hyprland.org/Configuring/Monitors/ -monitor=,preferred,auto,1 +monitor=,highrr,auto,1 $hypr_dir="$HOME/.config/hypr" # 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=xrdb -merge $HOME/.config/.Xresource 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' diff --git a/hypr/info b/hypr/info index 52fee31..6d7d21d 100755 --- a/hypr/info +++ b/hypr/info @@ -1,16 +1,16 @@ #!/bin/sh i=1 -while [ $i -le 5 ];do - mem=$(sed -nE 's_.*MemAvailable:[[:space:]]*(.*) kB_\1_p' /proc/meminfo) - mem="$(((7919488 - mem)/1000))" - temp=$(cat /sys/class/thermal/thermal_zone0/temp) - temp=$((temp / 1000)) - bat_stats=$(cat /sys/class/power_supply/BAT*/status) - vol_stats=$(pamixer --get-mute) - [ "$bat_stats" = "Discharging" ] && bat_icon=🔋 || bat_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 & - : $((i+=1)) - sleep 1 +while [ $i -le 5 ]; do + mem=$(sed -nE 's_.*MemAvailable:[[:space:]]*(.*) kB_\1_p' /proc/meminfo) + mem="$(((7919488 - mem) / 1000))" + temp=$(cat /sys/class/thermal/thermal_zone0/temp) + temp=$((temp / 1000)) + bat_stats=$(cat /sys/class/power_supply/BAT*/status) + vol_stats=$(pamixer --get-mute) + [ "$bat_stats" = "Discharging" ] && bat_icon=🔋 || bat_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 & + : $((i += 1)) + sleep 1 done diff --git a/hypr/launch b/hypr/launch index af6a046..85e0f89 100755 --- a/hypr/launch +++ b/hypr/launch @@ -1,7 +1,7 @@ #!/bin/sh menu() { - bemenu --fn 'IBM Plex Sans 15' -i -c -W "0.${2:-5}" -B 3 -p "$1" -l 25 -P ">>" + bemenu --fn 'IBM Plex Sans 15' -i -c -W "0.${2:-5}" -B 3 -p "$1" -l 25 -P ">>" } [ -z "$1" ] && dir="$HOME/repos_scripts" || dir="$1" diff --git a/hypr/screenshot b/hypr/screenshot index ccb4ead..fcee975 100755 --- a/hypr/screenshot +++ b/hypr/screenshot @@ -1,6 +1,6 @@ #!/bin/sh -icon="/usr/share/icons/Papirus/16x16/apps/applets-screenshooter.svg" +icon="/usr/share/icons/Papirus/16x16/apps/applets-screenshooter.svg" killall grim slurp [ "$*" = "fullclip" ] && grim - | wl-copy -t image/png && notify-send -i "$icon" "Screenshot copied to clipboard" [ "$*" = "fullsave" ] && grim && notify-send -i "$icon" "Screenshot saved" diff --git a/hypr/wifi b/hypr/wifi index 19dc04b..082d871 100755 --- a/hypr/wifi +++ b/hypr/wifi @@ -1,5 +1,5 @@ #!/bin/bash -if nmcli radio wifi | grep -q 'enabled' ; then +if nmcli radio wifi | grep -q 'enabled'; then nmcli radio wifi off wifi_icon="offline" else diff --git a/hypr/workspace b/hypr/workspace index 3ce261f..52d3be4 100755 --- a/hypr/workspace +++ b/hypr/workspace @@ -1,9 +1,9 @@ #!/bin/sh -setup_dual_monitor(){ - sed -i "s/monitor=,1920x1080,0x0,1,mirror,eDP-1/monitor=,preferred,auto,1/g" "$HOME/.config/hypr/hyprland.conf" +setup_dual_monitor() { + sed -i "s/monitor=,1920x1080,0x0,1,mirror,eDP-1/monitor=,highrr,auto,1/g" "$HOME/.config/hypr/hyprland.conf" 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" hyprctl dispatch moveworkspacetomonitor "1 0" hyprctl dispatch moveworkspacetomonitor "2 0" @@ -14,12 +14,12 @@ setup_dual_monitor(){ fi } -handle_it(){ +handle_it() { [ -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) [ -z "$choice" ] && return 0 notify-send "${choice}ing screen" - if [ "$choice" = "Extend" ];then + if [ "$choice" = "Extend" ]; then setup_dual_monitor else 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 list) #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 + : $((i -= 1)) sleep 1 - done ;; + done + ;; 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) - 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 "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 current=$(printf "%s" "$line" | sed -nE 's_^(workspace)>>([^ ]*)_\1 \2_p') - if [ -n "$current" ];then - cat /tmp/workcurr > /tmp/workprev - printf "%s" "$current" > /tmp/workcurr + if [ -n "$current" ]; then + cat /tmp/workcurr >/tmp/workprev + printf "%s" "$current" >/tmp/workcurr 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 - done ;; + 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 + ;; toggle) #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 - setup_dual_monitor ;; + setup_dual_monitor + ;; esac