From 54b772cae06eb25adf33297e35234f33ded81a7b Mon Sep 17 00:00:00 2001 From: Saumit Dinesan Date: Sat, 12 Mar 2022 19:54:51 +0530 Subject: neovim addition --- .scripts/4chget | 24 +++++ .scripts/4chgetw | 19 ++++ .scripts/battery | 37 ++++++++ .scripts/bts | 37 ++++++++ .scripts/clock | 29 ++++++ .scripts/cpu | 12 +++ .scripts/cpubars | 44 +++++++++ .scripts/dcalc | 4 + .scripts/disk | 23 +++++ .scripts/dmenuhandler | 21 ++++ .scripts/dmount | 67 +++++++++++++ .scripts/dmrsyncfon | 24 +++++ .scripts/dumount | 44 +++++++++ .scripts/emojisel | 19 ++++ .scripts/emojiselw | 19 ++++ .scripts/fmenu | 77 +++++++++++++++ .scripts/hotrebootdwm | 4 + .scripts/internet | 26 +++++ .scripts/iplocate | 9 ++ .scripts/linkhandler | 23 +++++ .scripts/memory | 12 +++ .scripts/mntwindows | 7 ++ .scripts/nettraf | 29 ++++++ .scripts/not needed/doppler | 206 ++++++++++++++++++++++++++++++++++++++++ .scripts/not needed/forecast | 35 +++++++ .scripts/not needed/help-icon | 17 ++++ .scripts/not needed/kbselect | 16 ++++ .scripts/not needed/mailbox | 20 ++++ .scripts/not needed/moonphase | 37 ++++++++ .scripts/not needed/mpdup | 8 ++ .scripts/not needed/music | 19 ++++ .scripts/not needed/news | 17 ++++ .scripts/not needed/pacpackages | 29 ++++++ .scripts/not needed/popupgrade | 9 ++ .scripts/not needed/tasks | 20 ++++ .scripts/not needed/torrent | 27 ++++++ .scripts/null | 1 + .scripts/otp | 53 +++++++++++ .scripts/pdfconv | 3 + .scripts/pidkill | 9 ++ .scripts/price | 50 ++++++++++ .scripts/redeat | 108 +++++++++++++++++++++ .scripts/reload_dunst | 21 ++++ .scripts/rsyncfon | 24 +++++ .scripts/serch | 5 + .scripts/setbg | 23 +++++ .scripts/setdef | 7 ++ .scripts/st-copyout | 1 + .scripts/st-urlhandler | 1 + .scripts/sxivf | 8 ++ .scripts/todo | 28 ++++++ .scripts/trashy | 5 + .scripts/upmenu | 46 +++++++++ .scripts/urbandictserch | 15 +++ .scripts/volume | 30 ++++++ .scripts/vpn-menu | 5 + .scripts/wifi-menu | 13 +++ .scripts/wifi-menu-custom | 22 +++++ 58 files changed, 1548 insertions(+) create mode 100755 .scripts/4chget create mode 100755 .scripts/4chgetw create mode 100755 .scripts/battery create mode 100755 .scripts/bts create mode 100755 .scripts/clock create mode 100755 .scripts/cpu create mode 100755 .scripts/cpubars create mode 100755 .scripts/dcalc create mode 100755 .scripts/disk create mode 100755 .scripts/dmenuhandler create mode 100755 .scripts/dmount create mode 100755 .scripts/dmrsyncfon create mode 100755 .scripts/dumount create mode 100755 .scripts/emojisel create mode 100755 .scripts/emojiselw create mode 100755 .scripts/fmenu create mode 100755 .scripts/hotrebootdwm create mode 100755 .scripts/internet create mode 100755 .scripts/iplocate create mode 100644 .scripts/linkhandler create mode 100755 .scripts/memory create mode 100755 .scripts/mntwindows create mode 100755 .scripts/nettraf create mode 100755 .scripts/not needed/doppler create mode 100755 .scripts/not needed/forecast create mode 100755 .scripts/not needed/help-icon create mode 100755 .scripts/not needed/kbselect create mode 100755 .scripts/not needed/mailbox create mode 100755 .scripts/not needed/moonphase create mode 100755 .scripts/not needed/mpdup create mode 100755 .scripts/not needed/music create mode 100755 .scripts/not needed/news create mode 100755 .scripts/not needed/pacpackages create mode 100755 .scripts/not needed/popupgrade create mode 100755 .scripts/not needed/tasks create mode 100755 .scripts/not needed/torrent create mode 100755 .scripts/null create mode 100644 .scripts/otp create mode 100755 .scripts/pdfconv create mode 100755 .scripts/pidkill create mode 100755 .scripts/price create mode 100755 .scripts/redeat create mode 100755 .scripts/reload_dunst create mode 100755 .scripts/rsyncfon create mode 100755 .scripts/serch create mode 100755 .scripts/setbg create mode 100755 .scripts/setdef create mode 120000 .scripts/st-copyout create mode 120000 .scripts/st-urlhandler create mode 100755 .scripts/sxivf create mode 100755 .scripts/todo create mode 100755 .scripts/trashy create mode 100755 .scripts/upmenu create mode 100755 .scripts/urbandictserch create mode 100755 .scripts/volume create mode 100755 .scripts/vpn-menu create mode 100755 .scripts/wifi-menu create mode 100755 .scripts/wifi-menu-custom (limited to '.scripts') diff --git a/.scripts/4chget b/.scripts/4chget new file mode 100755 index 0000000..41fd446 --- /dev/null +++ b/.scripts/4chget @@ -0,0 +1,24 @@ +#!/bin/bash + +echo "Welcome to 4chan web/image scrapping script" +#echo -e "What would you like to do?\r\n1)sync from phone to pc 2)sync from pc to phone " +echo "Is it wallpaper/general (wg) or anime wallpaper (w)?" +read option +echo "Enter folder name:" +read dir +echo "Enter thread no.: (#######)" +read thread +if [[ $option = w ]] ; then + mkdir -p /home/$USER/Pictures/Wallpaper/4chget/w/$dir +else + mkdir -p /home/$USER/Pictures/Wallpaper/4chget/wg/$dir +fi + +case "$option" in + "wg") + wget -P Pictures/Wallpaper/4chget/wg/$dir -nd -r -l 1 -H -D i.4cdn.org,is2.4chan.org -A png,jpg,jpeg -R '?????????????s.*' https://boards.4chan.org/wg/thread/$thread ;; + + "w") + wget -P Pictures/Wallpaper/4chget/w/$dir -nd -r -l 1 -H -D i.4cdn.org,is2.4chan.org -A png,jpg,jpeg -R '?????????????s.*' https://boards.4channel.org/w/thread/$thread ;; +esac + diff --git a/.scripts/4chgetw b/.scripts/4chgetw new file mode 100755 index 0000000..efdb038 --- /dev/null +++ b/.scripts/4chgetw @@ -0,0 +1,19 @@ +#!/bin/bash + +option=$(echo -e "wg\nw" | dmenu -p "Is it wallpaper/general (wg) or anime wallpaper (w)?") +thread=$(echo "" | dmenu -p "Enter thread no.: (#######)") +dir=$(echo "" | dmenu -p "Enter folder name") + +if [[ $option = w ]] ; then + mkdir -p /home/saumit/Pictures/Wallpaper/4chget/w/$dir + else + mkdir -p /home/saumit/Pictures/Wallpaper/4chget/wg/$dir +fi + +case "$option" in + "wg") + wget -P Pictures/Wallpaper/4chget/wg/$dir -nd -r -l 1 -H -D i.4cdn.org,is2.4chan.org -A png,jpg,jpeg -R '?????????????s.*' https://boards.4chan.org/wg/thread/$thread ;; + + "w") + wget -P Pictures/Wallpaper/4chget/w/$dir -nd -r -l 1 -H -D i.4cdn.org,is2.4chan.org -A png,jpg,jpeg -R '?????????????s.*' https://boards.4channel.org/w/thread/$thread ;; + esac diff --git a/.scripts/battery b/.scripts/battery new file mode 100755 index 0000000..1f308a5 --- /dev/null +++ b/.scripts/battery @@ -0,0 +1,37 @@ +#!/bin/sh + +# Prints all batteries, their percentage remaining and an emoji corresponding +# to charge status (πŸ”Œ for plugged up, πŸ”‹ for discharging on battery, etc.). + +case $BLOCK_BUTTON in + 3) notify-send "πŸ”‹ Battery module" "πŸ”‹: discharging +πŸ›‘: not charging +β™» : stagnant charge +πŸ”Œ: charging +⚑: charged +❗: battery very low! +- Scroll to change adjust xbacklight." ;; + 4) xbacklight -inc 10 ;; + 5) xbacklight -dec 10 ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +# Loop through all attached batteries and format the info +for battery in /sys/class/power_supply/BAT?*; do + # If non-first battery, print a space separator. + [ -n "${capacity+x}" ] && printf " " + # Sets up the status and capacity + case "$(cat "$battery/status" 2>&1)" in + "Full") status="⚑" ;; + "Discharging") status="πŸ”‹" ;; + "Charging") status="πŸ”Œ" ;; + "Not charging") status="πŸ›‘" ;; + "Unknown") status="♻️ " ;; + *) exit 1 ;; + esac + capacity="$(cat "$battery/capacity" 2>&1)" + # Will make a warn variable if discharging and low + [ "$status" = "πŸ”‹" ] && [ "$capacity" -le 25 ] && warn="❗" + # Prints the info + printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn +done && printf "\\n" diff --git a/.scripts/bts b/.scripts/bts new file mode 100755 index 0000000..7b85aac --- /dev/null +++ b/.scripts/bts @@ -0,0 +1,37 @@ +#!/bin/bash +option=$(echo -e "Connect\nDisconnect\nChange profile"| dmenu -p "Do you wish to connect/disconnect or change soundprofile of your bluetooth device:") +MAC=$(echo "A1:B3:EC:B1:53:60") +case $option in + "Connect") + status=$(systemctl status bluetooth | grep Active | cut -d " " -f 7) + case $status in + "active") + bluetoothctl power on + bluetoothctl connect $MAC && sleep 2 && [ $(bluetoothctl info $MAC|grep "Connected"|awk -F'[:][ ]' '/^[^#]/{print $2}') == "yes" ] && notify-send "Connected" "Bluetooth Device is connected" || notify-send "Unable to connect!" "Check whether the bluetooth device is switched on.";; + + "inactive" | "failed") + sudo -A systemctl start bluetooth + #st -e sudo systemctl start bluetooth && + notify-send "Bluetooth daemon is running" + bluetoothctl power on + bluetoothctl connect $MAC && sleep 1 && [ $(bluetoothctl info $MAC|grep "Connected"|awk -F'[:][ ]' '/^[^#]/{print $2}') == "yes" ] && notify-send "Connected" "Bluetooth Device is disconnected" || notify-send "Unable to connect!" "Check whether the bluetooth device is switched on."; + esac;; + + "Disconnect") + bluetoothctl power off && sudo -A systemctl stop bluetooth + notify-send "Disconnected" "Bluetooth Device is connected" || notify-send "Unable to connect!" "Check whether the bluetooth device is switched on.";; + + "Change profile") + past_profile=$(pactl list | grep "Active Profile" | sed '2p;d' | cut -d ' ' -f 3) + profile=$(echo -e "a2dp_sink(pure audio output)\nhandsfree_head_unit(inferior audio output + mic enable)" | dmenu -p "Choose the profile for your sound card") + cardindex=$(pacmd list-cards | grep 'index' | awk 'NR==2' | cut -d ' ' -f6) + + case $profile in + "a2dp_sink(pure audio output)") + pactl set-card-profile $cardindex a2dp_sink && + dunstify "Switched card profile from $past_profile to $profile" -i audio-headphones;; + "handsfree_head_unit(inferior audio output + mic enable)") + pactl set-card-profile $cardindex handsfree_head_unit + notify-send "Switched card profile from $past_profile to $profile" -i audio-headset;; + esac +esac diff --git a/.scripts/clock b/.scripts/clock new file mode 100755 index 0000000..d25e8d0 --- /dev/null +++ b/.scripts/clock @@ -0,0 +1,29 @@ +#!/bin/sh + +clock=$(date '+%I') + +case "$clock" in + "00") icon="πŸ•›" ;; + "01") icon="πŸ•" ;; + "02") icon="πŸ•‘" ;; + "03") icon="πŸ•’" ;; + "04") icon="πŸ•“" ;; + "05") icon="πŸ•”" ;; + "06") icon="πŸ••" ;; + "07") icon="πŸ•–" ;; + "08") icon="πŸ•—" ;; + "09") icon="πŸ•˜" ;; + "10") icon="πŸ•™" ;; + "11") icon="πŸ•š" ;; + "12") icon="πŸ•›" ;; +esac + +case $BLOCK_BUTTON in + 1) notify-send "This Month" "$(cal --color=always | sed "s/..7m//;s/..27m/<\/span><\/b>/")" && notify-send "Appointments" "$(calcurse -d3)" ;; + 2) setsid -f "$TERMINAL" -e calcurse ;; + 3) notify-send "πŸ“… Time/date module" "\- Left click to show upcoming appointments for the next three days via \`calcurse -d3\` and show the month via \`cal\` +- Middle click opens calcurse if installed" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +date "+%Y %b %d (%a) $icon%I:%M%p" diff --git a/.scripts/cpu b/.scripts/cpu new file mode 100755 index 0000000..1572b52 --- /dev/null +++ b/.scripts/cpu @@ -0,0 +1,12 @@ +#!/bin/sh + +case $BLOCK_BUTTON in + 1) notify-send "πŸ–₯ CPU hogs" "$(ps axch -o cmd:15,%cpu --sort=-%cpu | head)\\n(100% per core)" ;; + 2) setsid -f "$TERMINAL" -e htop ;; + 3) notify-send "πŸ–₯ CPU module " "\- Shows CPU temperature. +- Click to show intensive processes. +- Middle click to open htop." ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +sensors | awk '/Core 0/ {print "🌑" $3}' diff --git a/.scripts/cpubars b/.scripts/cpubars new file mode 100755 index 0000000..f318b87 --- /dev/null +++ b/.scripts/cpubars @@ -0,0 +1,44 @@ +#!/bin/sh + +# Module showing CPU load as a changing bars. +# Just like in polybar. +# Each bar represents amount of load on one core since +# last run. + +# Cache in tmpfs to improve speed and reduce SSD load +cache=/tmp/cpubarscache + +case $BLOCK_BUTTON in + 2) setsid -f "$TERMINAL" -e htop ;; + 3) notify-send "πŸͺ¨ CPU load module" "Each bar represents +one CPU core";; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +# id total idle +stats=$(awk '/cpu[0-9]+/ {printf "%d %d %d\n", substr($1,4), ($2 + $3 + $4 + $5), $5 }' /proc/stat) +[ ! -f $cache ] && echo "$stats" > "$cache" +old=$(cat "$cache") +printf "πŸͺ¨" +echo "$stats" | while read -r row; do + id=${row%% *} + rest=${row#* } + total=${rest%% *} + idle=${rest##* } + + case "$(echo "$old" | awk '{if ($1 == id) + printf "%d\n", (1 - (idle - $3) / (total - $2))*100 /12.5}' \ + id="$id" total="$total" idle="$idle")" in + + "0") printf "▁ ";; + "1") printf "β–‚ ";; + "2") printf "β–ƒ ";; + "3") printf "β–„ ";; + "4") printf "β–… ";; + "5") printf "β–† ";; + "6") printf "β–‡ ";; + "7") printf "β–ˆ ";; + "8") printf "β–ˆ ";; + esac +done; printf "\\n" +echo "$stats" > "$cache" diff --git a/.scripts/dcalc b/.scripts/dcalc new file mode 100755 index 0000000..5355f4b --- /dev/null +++ b/.scripts/dcalc @@ -0,0 +1,4 @@ +#!/bin/sh +Equation=$(echo "" | dmenu -n -p "Enter equation" | xargs -I % calc %) + +notify-send "Result" "$Equation" diff --git a/.scripts/disk b/.scripts/disk new file mode 100755 index 0000000..e947509 --- /dev/null +++ b/.scripts/disk @@ -0,0 +1,23 @@ +#!/bin/sh + +# Status bar module for disk space +# $1 should be drive mountpoint, otherwise assumed /. + +location=${1:-/} + +[ -d "$location" ] || exit + +case $BLOCK_BUTTON in + 1) notify-send "πŸ’½ Disk space" "$(df -h --output=target,used,size)" ;; + 3) notify-send "πŸ’½ Disk module" "\- Shows used hard drive space. +- Click to show all disk info." ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +case "$location" in + "/home"* ) icon="🏠" ;; + "/mnt"* ) icon="πŸ’Ύ" ;; + *) icon="πŸ–₯";; +esac + +printf "%s: %s\n" "$icon" "$(df -h "$location" | awk ' /[0-9]/ {print $3 "/" $2}')" diff --git a/.scripts/dmenuhandler b/.scripts/dmenuhandler new file mode 100755 index 0000000..ce9159d --- /dev/null +++ b/.scripts/dmenuhandler @@ -0,0 +1,21 @@ +#!/bin/sh + +# Feed this script a link and it will give dmenu +# some choice programs to use to open it. +feed="${1:-$(printf "%s" | dmenu -p 'Paste URL or file path')}" + +case "$(printf "Copy URL\\nsxiv\\nsetbg\\nPDF\\nbrowser\\nlynx\\nvim\\nmpv\\nmpv loop\\nmpv float\\nqueue download\\nqueue yt-dl\\nqueue yt-dl audio" | dmenu -i -p "Open it with?")" in + "Copy URL") echo "$feed" | xclip -selection clipboard ;; + mpv) setsid -f mpv -quiet "$feed" >/dev/null 2>&1 ;; + "mpv loop") setsid -f mpv -quiet --loop "$feed" >/dev/null 2>&1 ;; + "mpv float") setsid -f "$TERMINAL" -e mpv --geometry=+0-0 --autofit=30% --title="mpvfloat" "$feed" >/dev/null 2>&1 ;; + "queue yt-dl") qndl "$feed" >/dev/null 2>&1 ;; + "queue yt-dl audio") qndl "$feed" 'youtube-dl --add-metadata -icx -f bestaudio/best' >/dev/null 2>&1 ;; + "queue download") qndl "$feed" 'curl -LO' >/dev/null 2>&1 ;; + PDF) curl -sL "$feed" > "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" && zathura "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 ;; + sxiv) curl -sL "$feed" > "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" && sxiv -a "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 ;; + vim) curl -sL "$feed" > "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" && setsid -f "$TERMINAL" -e "$EDITOR" "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 ;; + setbg) curl -L "$feed" > $XDG_CACHE_HOME/pic ; xwallpaper --zoom $XDG_CACHE_HOME/pic >/dev/null 2>&1 ;; + browser) setsid -f "$BROWSER" "$feed" >/dev/null 2>&1 ;; + lynx) lynx "$feed" >/dev/null 2>&1 ;; +esac diff --git a/.scripts/dmount b/.scripts/dmount new file mode 100755 index 0000000..7449574 --- /dev/null +++ b/.scripts/dmount @@ -0,0 +1,67 @@ +#!/bin/sh + +# Gives a dmenu prompt to mount unmounted drives and Android phones. If +# they're in /etc/fstab, they'll be mounted automatically. Otherwise, you'll +# be prompted to give a mountpoint from already existsing directories. If you +# input a novel directory, it will prompt you to create that directory. + +getmount() { \ + [ -z "$chosen" ] && exit 1 + # shellcheck disable=SC2086 + mp="$(find $1 2>/dev/null | dmenu -i -p "Type in mount point.")" || exit 1 + test -z "$mp" && exit 1 + if [ ! -d "$mp" ]; then + mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?") || exit 1 + [ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp") + fi + } + +mountusb() { \ + chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?")" || exit 1 + chosen="$(echo "$chosen" | awk '{print $1}')" + sudo -A mount "$chosen" 2>/dev/null && dunstify "USB mounting" "$chosen mounted." -i media-removable && exit 0 + alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not ( -path *%s -prune ) ",$3}') + getmount "/mnt /media /mount /home -maxdepth 5 -type d $alreadymounted" + partitiontype="$(lsblk -no "fstype" "$chosen")" + case "$partitiontype" in + "vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000;; + "exfat") sudo -A mount "$chosen" "$mp" -o uid="$(id -u)",gid="$(id -g)";; + *) sudo -A mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" "$mp";; + esac + dunstify "USB mounting" "$chosen mounted to $mp." -i media-removable + } + +mountandroid() { \ + chosen="$(echo "$anddrives" | dmenu -i -p "Which Android device?")" || exit 1 + chosen="$(echo "$chosen" | cut -d : -f 1)" + getmount "$HOME -maxdepth 3 -type d" + simple-mtpfs --device "$chosen" "$mp" + echo "OK" | dmenu -i -p "Tap Allow on your phone if it asks for permission and then press enter" || exit 1 + simple-mtpfs --device "$chosen" "$mp" + dunstify "Android Mounting" "Android device mounted to $mp." -i phone + } + +asktype() { \ + choice="$(printf "USB\\nAndroid" | dmenu -i -p "Mount a USB drive or Android device?")" || exit 1 + case $choice in + USB) mountusb ;; + Android) mountandroid ;; + esac + } + +anddrives=$(simple-mtpfs -l 2>/dev/null) +usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | grep 'part\|rom' | awk '$4==""{printf "%s (%s)\n",$1,$3}')" + +if [ -z "$usbdrives" ]; then + [ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit + echo "Android device(s) detected." + mountandroid +else + if [ -z "$anddrives" ]; then + echo "USB drive(s) detected." + mountusb + else + echo "Mountable USB drive(s) and Android device(s) detected." + asktype + fi +fi diff --git a/.scripts/dmrsyncfon b/.scripts/dmrsyncfon new file mode 100755 index 0000000..6d01cb6 --- /dev/null +++ b/.scripts/dmrsyncfon @@ -0,0 +1,24 @@ +#!/bin/bash + +echo "Welcome to rsyncfon a fon to pc and vice-versa file-syncing script using the rsync algorithm!" +echo -e "What would you like to do?\r\n1)sync from phone to pc 2)sync from pc to phone " +read option +case "$option" in + "1") + echo -e "Enter public IP on mobile device (starting with 192.): \r\n!Make sure the device and the desktop are connected to the same network!" + read IP + echo "Enter file/folder to be rsync'd (Leave empty if entire sdcard) (/sdcard/*)" + read file + echo "Enter desination path on PC \r\n!!!Make sure to check whether it had sufficient space or not!!!" + read dest + rsync --update --progress -e 'ssh -p 2222' -azv $IP:/sdcard/$file $dest;; + "2") + echo "Enter file/folder from pc to be rsync'd" + read file + echo "Enter public IP" + read IP + echo "Enter destination location( /sdcard/*)" + read dest + rsync --update --progress -e 'ssh -p 2222' -azv $file root@$IP:$dest +esac + diff --git a/.scripts/dumount b/.scripts/dumount new file mode 100755 index 0000000..946d12c --- /dev/null +++ b/.scripts/dumount @@ -0,0 +1,44 @@ +#!/bin/sh + +# A dmenu prompt to unmount drives. +# Provides you with mounted partitions, select one to unmount. +# Drives mounted at /, /boot and /home will not be options to unmount. + +unmountusb() { + [ -z "$drives" ] && exit + chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1 + chosen="$(echo "$chosen" | awk '{print $1}')" + [ -z "$chosen" ] && exit + sudo -A umount "$chosen" && notify-send "πŸ’» USB unmounting" "$chosen unmounted." + } + +unmountandroid() { \ + chosen="$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -i -p "Unmount which device?")" || exit 1 + [ -z "$chosen" ] && exit + sudo -A umount -l "$chosen" && notify-send "πŸ€– Android unmounting" "$chosen unmounted." + } + +asktype() { \ + choice="$(printf "USB\\nAndroid" | dmenu -i -p "Unmount a USB drive or Android device?")" || exit 1 + case "$choice" in + USB) unmountusb ;; + Android) unmountandroid ;; + esac + } + +drives=$(lsblk -nrpo "name,type,size,mountpoint,label" | awk -F':' '{gsub(/ /,":")}$4!~/\/boot|\/efi|\/home$|SWAP/&&length($4)>1{printf "%s (%s) %s\n",$4,$3,$5}') + +if ! grep simple-mtpfs /etc/mtab; then + [ -z "$drives" ] && echo "No drives to unmount." && exit + echo "Unmountable USB drive detected." + unmountusb +else + if [ -z "$drives" ] + then + echo "Unmountable Android device detected." + unmountandroid + else + echo "Unmountable USB drive(s) and Android device(s) detected." + asktype + fi +fi diff --git a/.scripts/emojisel b/.scripts/emojisel new file mode 100755 index 0000000..adab4eb --- /dev/null +++ b/.scripts/emojisel @@ -0,0 +1,19 @@ +#!/bin/sh + +# The famous "get a menu of emojis to copy" script. + +# Get user selection via dmenu from emoji file. +chosen=$(cut -d ';' -f1 ~/.local/share/emoji | dmenu -i -l 30 | sed "s/ .*//") + +# Exit if none chosen. +[ -z "$chosen" ] && exit + +# If you run this command with an argument, it will automatically insert the +# character. Otherwise, show a message that the emoji has been copied. +if [ -n "$1" ]; then + xdotool type "$chosen" +else + printf "$chosen" | xclip -sel c + notify-send "'$chosen' copied to clipboard." & +fi + diff --git a/.scripts/emojiselw b/.scripts/emojiselw new file mode 100755 index 0000000..9e6f055 --- /dev/null +++ b/.scripts/emojiselw @@ -0,0 +1,19 @@ +#!/bin/sh + +# The famous "get a menu of emojis to copy" script. + +# Get user selection via dmenu from emoji file. +windowsid=$(xdotool getactivewindow) +chosen=$(cut -d ';' -f1 ~/.local/share/emoji | dmenu -i -l 30 -w $windowsid | sed "s/ .*//") +# Exit if none chosen. +[ -z "$chosen" ] && exit + +# If you run this command with an argument, it will automatically insert the +# character. Otherwise, show a message that the emoji has been copied. +if [ -n "$1" ]; then + xdotool type "$chosen" +else + printf "$chosen" | xclip -sel c + notify-send "'$chosen' copied to clipboard." & +fi + diff --git a/.scripts/fmenu b/.scripts/fmenu new file mode 100755 index 0000000..d0c6fce --- /dev/null +++ b/.scripts/fmenu @@ -0,0 +1,77 @@ +#!/bin/bash + +usage() +{ + cat << EOF +usage: $0 options + +Index and search files using dmenu + +OPTIONS: + -h Show this message + -o Store index [default: /tmp/fmenu_index] + -i Search folders [default: $HOME] + -x Exclude files [default: ".*\/..*" (i.e. dot-files)] + -d dmenu parameters [default: -i -l 20] + -f force reloading index [default: false] + -t time [default: 5min] + -u Just update the index +EOF +} + +FORCE=false +INDEX="/tmp/fmenu_index" +DMENU="-i -l 20" +TIME="+5" +INPUT=$HOME +EXCLUDE='.*/\..*' +DRY=false +while getopts "ht:fd:o:i:x:u" OPTION +do + case $OPTION in + h) + usage + exit 1 + ;; + f) + FORCE=true + ;; + d) + DMENU=$OPTARG + ;; + t) + TIME=$OPTARG + ;; + o) + INDEX=$OPTARG + ;; + i) + INPUT=$OPTARG + ;; + x) + EXCLUDE=$OPTARG + ;; + u) + FORCE=true + DRY=true + ;; + ?) + usage + exit + ;; + esac +done + +function index_files { + find "$INPUT" \( ! -regex "$EXCLUDE" \) | sed 's/ /\\ /g' | sort -f > "$INDEX" +} + +if [[ ! -a "$INDEX" ]] || ( test `find $INDEX -mmin $TIME` ) || ($FORCE) +then + index_files +fi + +if ( ! $DRY ) +then + cat "$INDEX" | `dmenu $DMENU > /tmp/dmenu_find_output.txt` && cat /tmp/dmenu_find_output.txt | xargs xdg-open +fi diff --git a/.scripts/hotrebootdwm b/.scripts/hotrebootdwm new file mode 100755 index 0000000..9768709 --- /dev/null +++ b/.scripts/hotrebootdwm @@ -0,0 +1,4 @@ +#!/bin/sh +##pid=$(ps -a | grep dwm | awk '{print $1}') +pid=$(pidof dwm) +kill -HUP $pid diff --git a/.scripts/internet b/.scripts/internet new file mode 100755 index 0000000..94b7da2 --- /dev/null +++ b/.scripts/internet @@ -0,0 +1,26 @@ +#!/bin/sh + +# Show wifi πŸ“Ά and percent strength or πŸ“‘ if none. +# Show 🌐 if connected to ethernet or ❎ if none. +# Show πŸ”’ if a vpn connection is active + +case $BLOCK_BUTTON in + 1) "$TERMINAL" -e nmtui; pkill -RTMIN+4 dwmblocks ;; + 3) notify-send "🌐 Internet module" "\- Click to connect +❌: wifi disabled +πŸ“‘: no wifi connection +πŸ“Ά: wifi connection with quality +❎: no ethernet +🌐: ethernet working +πŸ”’: vpn is active +" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +if grep -xq 'up' /sys/class/net/w*/operstate 2>/dev/null ; then + wifiicon="$(awk '/^\s*w/ { print "πŸ“Ά", int($3 * 100 / 70) "% " }' /proc/net/wireless)" +elif grep -xq 'down' /sys/class/net/w*/operstate 2>/dev/null ; then + grep -xq '0x1003' /sys/class/net/w*/flags && wifiicon="πŸ“‘ " || wifiicon="❌ " +fi + +printf "%s%s%s\n" "$wifiicon" "$(sed "s/down/❎/;s/up/🌐/" /sys/class/net/e*/operstate 2>/dev/null)" "$(sed "s/.*/πŸ”’/" /sys/class/net/tun*/operstate 2>/dev/null)" diff --git a/.scripts/iplocate b/.scripts/iplocate new file mode 100755 index 0000000..1fcb696 --- /dev/null +++ b/.scripts/iplocate @@ -0,0 +1,9 @@ +#!/bin/sh + +# Gets your public ip address checks which country you are in and +# displays that information in the statusbar +# +# https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/ + +addr="$(curl ifconfig.me 2>/dev/null)" || exit +grep "flag: " "${XDG_DATA_HOME:-$HOME/.local/share}/emoji" | grep "$(geoiplookup "$addr" | sed 's/.*, //')" | sed "s/flag: //;s/;.*//" diff --git a/.scripts/linkhandler b/.scripts/linkhandler new file mode 100644 index 0000000..fa74caf --- /dev/null +++ b/.scripts/linkhandler @@ -0,0 +1,23 @@ +#!/bin/sh + +# Feed script a url or file location. +# If an image, it will view in sxiv, +# if a video or gif, it will view in mpv +# if a music file or pdf, it will download, +# otherwise it opens link in browser. + +# If no url given. Opens browser. For using script as $BROWSER. +[ -z "$1" ] && { "$BROWSER"; exit; } + +case "$1" in + *mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*hooktube.com*|*bitchute.com*|*videos.lukesmith.xyz*|*odysee.com*) + setsid -f mpv -quiet "$1" >/dev/null 2>&1 ;; + *png|*jpg|*jpe|*jpeg|*gif) + curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;; + *pdf|*cbz|*cbr) + curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" && zathura "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;; + *mp3|*flac|*opus|*mp3?source*) + qndl "$1" 'curl -LO' >/dev/null 2>&1 ;; + *) + [ -f "$1" ] && setsid -f "$TERMINAL" -e "$EDITOR" "$1" >/dev/null 2>&1 || setsid -f "$BROWSER" "$1" >/dev/null 2>&1 +esac diff --git a/.scripts/memory b/.scripts/memory new file mode 100755 index 0000000..56a236c --- /dev/null +++ b/.scripts/memory @@ -0,0 +1,12 @@ +#!/bin/sh + +case $BLOCK_BUTTON in + 1) notify-send "🧠 Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;; + 2) setsid -f "$TERMINAL" -e htop ;; + 3) notify-send "🧠 Memory module" "\- Shows Memory Used/Total. +- Click to show memory hogs. +- Middle click to open htop." ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +free --mebi | sed -n '2{p;q}' | awk '{printf ("🧠%2.1fGB/16GB\n", ( $3 / 1024), ($2 / 1024))}' diff --git a/.scripts/mntwindows b/.scripts/mntwindows new file mode 100755 index 0000000..5adb9c5 --- /dev/null +++ b/.scripts/mntwindows @@ -0,0 +1,7 @@ +#!/bin/sh + +sudo mount /dev/nvme0n1p3 /home/C +sudo mount /dev/nvme0n1p4 /home/D +sudo mount /dev/nvme0n1p5 /home/E +sudo mount /dev/nvme0n1p6 /home/F +sudo mount /dev/nvme0n1p7 /home/G diff --git a/.scripts/nettraf b/.scripts/nettraf new file mode 100755 index 0000000..eb7a73b --- /dev/null +++ b/.scripts/nettraf @@ -0,0 +1,29 @@ +#!/bin/sh + +# Module showing network traffic. Shows how much data has been received (RX) or +# transmitted (TX) since the previous time this script ran. So if run every +# second, gives network traffic per second. + +case $BLOCK_BUTTON in + 1) setsid -f "$TERMINAL" -e bmon ;; + 3) notify-send "🌐 Network traffic module" "πŸ”»: Traffic received +πŸ”Ί: Traffic transmitted" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +update() { + sum=0 + for arg; do + read -r i < "$arg" + sum=$(( sum + i )) + done + cache=${XDG_CACHE_HOME:-$HOME/.cache}/${1##*/} + [ -f "$cache" ] && read -r old < "$cache" || old=0 + printf %d\\n "$sum" > "$cache" + printf %d\\n $(( sum - old )) +} + +rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes) +tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes) + +printf "πŸ”»%4sB πŸ”Ί%4sB\\n" $(numfmt --to=iec $rx) $(numfmt --to=iec $tx) diff --git a/.scripts/not needed/doppler b/.scripts/not needed/doppler new file mode 100755 index 0000000..dc93db0 --- /dev/null +++ b/.scripts/not needed/doppler @@ -0,0 +1,206 @@ +#!/bin/sh + +# Show a Doppler RADAR of an American user's preferred location. + +secs=600 # Download a new doppler radar if one hasn't been downloaded in $secs seconds. +radarloc="${XDG_CACHE_HOME:-$HOME/.cache}/radar" +doppler="${XDG_CACHE_HOME:-$HOME/.cache}/doppler.gif" + +pickloc() { chosen="$(echo "Northeast +Southeast +PacNorthWest +PacSouthWest +UpperMissVly +SouthMissVly +SouthPlains +NorthRockies +SouthRockies +Alaska +Carib +Hawaii +CentGrLakes +Conus-Large +KABR: Aberdeen, SD +KBIS: Bismarck, ND +KFTG: Denver/Boulder, CO +KDMX: Des Moines, IA +KDTX: Detroit, MI +KDDC: Dodge City, KS +KDLH: Duluth, MN +KCYS: Cheyenne, WY +KLOT: Chicago, IL +KGLD: Goodland, KS +KUEX: Hastings, NE +KGJX: Grand Junction, CO +KGRR: Grand Rapids, MI +KMVX: Fargo/Grand Forks, ND +KGRB: Green Bay, WI +KIND: Indianapolis, IN +KJKL: Jackson, KY +KARX: La Crosse, WI +KILX: Lincoln/Central Illinois, IL +KLVX: Louisville, KY +KMQT: Marquette +KMKX: Milwaukee, WI +KMPX: Minneapolis, MN +KAPX: Gaylord/Alpena, MI +KLNX: North Platte, NE +KIWX: N. Webster/Northern, IN +KOAX: Omaha, NE +KPAH: Paducah, KY +KEAX: Pleasant Hill, MO +KPUX: Pueblo, CO +KDVN: Quad Cities, IA +KUDX: Rapid City, SD +KRIW: Riverton, WY +KSGF: Springfield, MO +KLSX: St. LOUIS, MO +KFSD: Sioux Falls, IA +KTWX: Topeka, KS +KICT: Wichita, KS +KVWX: Paducah, KY +ICAO: Responsible Wfo +KLTX: WILMINGTON, NC +KCCX: State College/Central, PA +KLWX: Sterling, VA +KFCX: Blacksburg/Roanoke, VA +KRAX: Raleigh/Durham, NC +KGYX: Portland, ME +KDIX: Mt Holly/Philadelphia, PA +KPBZ: Pittsburgh, PA +KAKQ: Wakefield, VA +KMHX: Morehead City, NC +KGSP: Greer/Greenville/Sprtbg, SC +KILN: Wilmington/Cincinnati, OH +KCLE: Cleveland, OH +KCAE: Columbia, SC +KBGM: Binghamton, NY +KENX: Albany, NY +KBUF: Buffalo, NY +KCXX: Burlington, VT +KCBW: Caribou, ME +KBOX: Boston /Taunton, MA +KOKX: New York City, NY +KCLX: Charleston, SC +KRLX: Charleston, WV +ICAO: Responsible WFO +KBRO: Brownsville, TX +KABX: Albuquerque, NM +KAMA: Amarillo, TX +KFFC: Peachtree City/Atlanta, GA +KEWX: Austin/Sanantonio, TX +KBMX: Birmingham, AL +KCRP: Corpus Christi, TX +KFWS: Dallas / Ft. Worth, TX +KEPZ: El Paso, TX +KHGX: Houston/ Galveston, TX +KJAX: Jacksonville, FL +KBYX: Key West, FL +KMRX: Morristown/knoxville, TN +KLBB: Lubbock, TX +KLZK: Little Rock, AR +KLCH: Lake Charles, LA +KOHX: Nashville, TN +KMLB: Melbourne, FL +KNQA: Memphis, TN +KAMX: Miami, FL +KMAF: Midland/odessa, TX +KTLX: Norman, OK +KHTX: Huntsville, AL +KMOB: Mobile, AL +KTLH: Tallahassee, FL +KTBW: Tampa Bay Area, FL +KSJT: San Angelo, TX +KINX: Tulsa, OK +KSRX: Tulsa, OK +KLIX: New Orleans/slidell, LA +KDGX: Jackson, MS +KSHV: Shreveport, LA +ICAO: Responsible WFO +KLGX: Seattle / Tacoma, WA +KOTX: Spokane, WA +KEMX: Tucson, AZ +KYUX: Phoenix, AZ +KNKX: San Diego, CA +KMUX: Monterey/san Francisco, CA +KHNX: San Joaquin/hanford, CA +KSOX: San Diego, CA +KATX: Seattle / Tacoma, WA +KIWA: Phoenix, AZ +KRTX: Portland, OR +KSFX: Pocatello, ID +KRGX: Reno, NV +KDAX: Sacramento, CA +KMTX: Salt Lake City, UT +KPDT: Pendleton, OR +KMSX: Missoula, MT +KESX: Las Vegas, NV +KVTX: Los Angeles, CA +KMAX: Medford, OR +KFSX: Flagstaff, AZ +KGGW: Glasgow, MT +KLRX: Elko, NV +KBHX: Eureka, CA +KTFX: Great Falls, MT +KCBX: Boise, ID +KBLX: Billings, MT +KICX: Salt Lake City, UT +ICAO: Responsible Wfo W/ MSCF +PABC: Anchorage, AK +PAPD: Fairbanks, AK +PHKM: Honolulu, HI +PAHG: Anchorage, AK +PAKC: Anchorage, AK +PAIH: Anchorage, AK +PHMO: Honolulu, HI +PAEC: Fairbanks, AK +TJUA: San Juan, PR +PACG: Juneau, AK +PHKI: Honolulu, HI +PHWA: Honolulu, HI +ICAO: Responsible Wfo W/ MSCF +KFDR: Norman, OK +PGUA: Guam +KBBX: Sacramento, CA +KFDX: Albuquerque, NM +KGWX: Jackson, MS +KDOX: Wakefield, VA +KDYX: San Angelo, TX +KEYX: Las Vegas, NV +KEVX: Mobile, AL +KHPX: Paducah, KY +KTYX: Burlington, VT +KGRK: Dallas / Ft. Worth, TX +KPOE: Lake Charles, LA +KEOX: Tallahassee, FL +KHDX: El Paso, TX +KDFX: San Antonio, TX +KMXX: Birmingham, AL +KMBX: Bismarck, ND +KVAX: Jacksonville, FL +KJGX: Peachtree City/atlanta, GA +KVNX: Norman, OK +KVBX: Vandenberg Afb: Orcutt, CA" | dmenu -r -i -l 50 -p "Select a National Weather Service radar to use as default:" | sed "s/:.*//" | tr "[:lower:]" "[:upper:]")" + +# Sanity check of selection and ensure user did not escape. +echo "$chosen" | grep -q "^[A-Z]\+$" && echo "$chosen" > "$radarloc" ;} + +getdoppler() { + loc="$(cat "$radarloc")" + notify-send "🌦️ Doppler RADAR" "Pulling most recent Doppler RADAR for $loc." + curl -sL "https://radar.weather.gov/ridge/lite/${loc}_loop.gif" > "$doppler" ;} + +showdoppler() { setsid -f mpv --no-osc --loop=inf --no-terminal "$doppler" ;} + +case $BLOCK_BUTTON in + 1) [ ! -f "$radarloc" ] && pickloc && getdoppler + [ $(($(date '+%s') - $(stat -c %Y "$doppler"))) -gt "$secs" ] && getdoppler + showdoppler ;; + 2) pickloc && getdoppler && showdoppler ;; + 3) notify-send "πŸ—ΊοΈ Doppler RADAR module" "\- Left click for local Doppler RADAR. +- Middle click to update change RADAR location. +After $secs seconds, new clicks will also automatically update the doppler RADAR." ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +echo πŸ—ΊοΈ diff --git a/.scripts/not needed/forecast b/.scripts/not needed/forecast new file mode 100755 index 0000000..7b8416e --- /dev/null +++ b/.scripts/not needed/forecast @@ -0,0 +1,35 @@ +#!/bin/sh + +# Displays todays precipication chance (β˜”) and daily low (πŸ₯Ά) and high (🌞). +# Usually intended for the statusbar. + +# If we have internet, get a weather report from wttr.in and store it locally. +# You could set up a shell alias to view the full file in a pager in the +# terminal if desired. This function will only be run once a day when needed. +weatherreport="${XDG_DATA_HOME:-$HOME/.local/share}/weatherreport" +getforecast() { curl -sf "wttr.in/$LOCATION" > "$weatherreport" || exit 1 ;} + +# Some very particular and terse stream manipulation. We get the maximum +# precipitation chance and the daily high and low from the downloaded file and +# display them with coresponding emojis. +showweather() { printf "%s" "$(sed '16q;d' "$weatherreport" | + grep -wo "[0-9]*%" | sort -rn | sed "s/^/β˜”/g;1q" | tr -d '\n')" +sed '13q;d' "$weatherreport" | grep -o "m\\([-+]\\)*[0-9]\\+" | sed 's/+//g' | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " πŸ₯Ά" $1 "Β°","🌞" $2 "Β°"}' ;} + +case $BLOCK_BUTTON in + 1) setsid -f "$TERMINAL" -e less -Srf "$weatherreport" ;; + 2) getforecast && showweather ;; + 3) notify-send "🌈 Weather module" "\- Left click for full forecast. +- Middle click to update forecast. +β˜”: Chance of rain/snow +πŸ₯Ά: Daily low +🌞: Daily high" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +# The test if our forcecast is updated to the day. If it isn't download a new +# weather report from wttr.in with the above function. +[ "$(stat -c %y "$weatherreport" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] || + getforecast + +showweather diff --git a/.scripts/not needed/help-icon b/.scripts/not needed/help-icon new file mode 100755 index 0000000..8fa4a52 --- /dev/null +++ b/.scripts/not needed/help-icon @@ -0,0 +1,17 @@ +#!/bin/sh + +# The clickable help menu. Middle click to restart wm. + +# If dwm is running, use dwm's readme and restart. +pidof dwm >/dev/null && + READMEFILE=/usr/local/share/dwm/larbs.mom + restartwm() { pkill -HUP dwm ;} || + restartwm() { i3 restart ;} + +case $BLOCK_BUTTON in + 1) groff -mom "${READMEFILE:-${XDG_DATA_HOME:-$HOME/.local/share}/larbs/readme.mom}" -Tpdf | zathura - ;; + 2) restartwm ;; + 3) notify-send "❓ Help module" "\- Left click to open LARBS guide. +- Middle click to refresh window manager." ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac; echo "❓" diff --git a/.scripts/not needed/kbselect b/.scripts/not needed/kbselect new file mode 100755 index 0000000..f0c923f --- /dev/null +++ b/.scripts/not needed/kbselect @@ -0,0 +1,16 @@ +#!/bin/sh +# works on any init system +# requirements: dmenu, xorg-setxkbmap +kb="$(setxkbmap -query | grep -oP 'layout:\s*\K\w+')" || exit 1 + +case $BLOCK_BUTTON in + 1) kb_choice="$(awk '/! layout/{flag=1; next} /! variant/{flag=0} flag {print $2, "- " $1}' /usr/share/X11/xkb/rules/base.lst | dmenu -l 15)" + kb="$(echo "$kb_choice" | awk '{print $3}')" + setxkbmap "$kb" + pkill -RTMIN+30 "${STATUSBAR:-dwmblocks}";; + 3) notify-send "⌨ Keyboard/language module" "$(printf "%s" "\- Current layout: $(setxkbmap -query | grep -oP 'layout:\s*\K\w+')") +- Left click to change keyboard.";; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +echo "$kb" diff --git a/.scripts/not needed/mailbox b/.scripts/not needed/mailbox new file mode 100755 index 0000000..2132184 --- /dev/null +++ b/.scripts/not needed/mailbox @@ -0,0 +1,20 @@ +#!/bin/sh + +# Displays number of unread mail and an loading icon if updating. +# When clicked, brings up `neomutt`. + +case $BLOCK_BUTTON in + 1) setsid -f "$TERMINAL" -e neomutt ;; + 2) setsid -f mw -Y >/dev/null ;; + 3) notify-send "πŸ“¬ Mail module" "\- Shows unread mail +- Shows πŸ”ƒ if syncing mail +- Left click opens neomutt +- Middle click syncs mail" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +unread="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/*/[Ii][Nn][Bb][Oo][Xx]/new/* -type f | wc -l 2>/dev/null)" + +pidof mbsync >/dev/null 2>&1 && icon="πŸ”ƒ" + +[ "$unread" = "0" ] && [ "$icon" = "" ] || echo "πŸ“¬$unread$icon" diff --git a/.scripts/not needed/moonphase b/.scripts/not needed/moonphase new file mode 100755 index 0000000..fab8b4d --- /dev/null +++ b/.scripts/not needed/moonphase @@ -0,0 +1,37 @@ +#!/bin/sh + +# Shows the current moon phase. + +moonfile="${XDG_DATA_HOME:-$HOME/.local/share}/moonphase" + +[ "$(stat -c %y "$moonfile" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] || + { curl -sf "wttr.in/?format=%m" > "$moonfile" || exit 1 ;} + +icon="$(cat "$moonfile")" + +case "$icon" in + πŸŒ‘) name="New" ;; + πŸŒ’) name="Waxing Crescent" ;; + πŸŒ“) name="First Quarter" ;; + πŸŒ”) name="Waxing Gibbous" ;; + πŸŒ•) name="Full" ;; + πŸŒ–) name="Waning Gibbous" ;; + πŸŒ—) name="Last Quarter" ;; + 🌘) name="Waning Crescent" ;; + *) exit 1 ;; +esac + +echo "${icon-?}" + +case $BLOCK_BUTTON in + 3) notify-send "🌜 Moon phase module" "Displays current moon phase. +- πŸŒ‘: New +- πŸŒ’: Waxing Crescent +- πŸŒ“: First Quarter +- πŸŒ”: Waxing Gibbous +- πŸŒ•: Full +- πŸŒ–: Waning Gibbous +- πŸŒ—: Last Quarter +- 🌘: Waning Crescent" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac diff --git a/.scripts/not needed/mpdup b/.scripts/not needed/mpdup new file mode 100755 index 0000000..af81a7d --- /dev/null +++ b/.scripts/not needed/mpdup @@ -0,0 +1,8 @@ +#!/bin/sh + +# This loop will update the mpd statusbar module whenever a command changes the +# music player's status. mpd must be running on X's start for this to work. + +while : ; do + mpc idle >/dev/null && kill -45 "$(pidof "${STATUSBAR:-dwmblocks}")" || break +done diff --git a/.scripts/not needed/music b/.scripts/not needed/music new file mode 100755 index 0000000..7ea7032 --- /dev/null +++ b/.scripts/not needed/music @@ -0,0 +1,19 @@ +#!/bin/sh + +filter() { mpc | sed "/^volume:/d;s/\\&/&/g;s/\\[paused\\].*/⏸/g;/\\[playing\\].*/d;/^ERROR/Q" | paste -sd ' ' -;} + +pidof -x sb-mpdup >/dev/null 2>&1 || sb-mpdup >/dev/null 2>&1 & + +case $BLOCK_BUTTON in + 1) mpc status | filter ; setsid -f "$TERMINAL" -e ncmpcpp ;; # right click, pause/unpause + 2) mpc toggle | filter ;; # right click, pause/unpause + 3) mpc status | filter ; notify-send "🎡 Music module" "\- Shows mpd song playing. +- ⏸ when paused. +- Left click opens ncmpcpp. +- Middle click pauses. +- Scroll changes track.";; # right click, pause/unpause + 4) mpc prev | filter ;; # scroll up, previous + 5) mpc next | filter ;; # scroll down, next + 6) mpc status | filter ; "$TERMINAL" -e "$EDITOR" "$0" ;; + *) mpc status | filter ;; +esac diff --git a/.scripts/not needed/news b/.scripts/not needed/news new file mode 100755 index 0000000..fe701db --- /dev/null +++ b/.scripts/not needed/news @@ -0,0 +1,17 @@ +#!/bin/sh + +# Displays number of unread news items and an loading icon if updating. +# When clicked, brings up `newsboat`. + +case $BLOCK_BUTTON in + 1) setsid "$TERMINAL" -e newsboat ;; + 2) setsid -f newsup >/dev/null exit ;; + 3) notify-send "πŸ“° News module" "\- Shows unread news items +- Shows πŸ”ƒ if updating with \`newsup\` +- Left click opens newsboat +- Middle click syncs RSS feeds +Note: Only one instance of newsboat (including updates) may be running at a time." ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + + cat /tmp/newsupdate 2>/dev/null || echo "$(newsboat -x print-unread | awk '{ if($1>0) print "πŸ“°" $1}')$(cat "${XDG_CONFIG_HOME:-$HOME/.config}"/newsboat/.update 2>/dev/null)" diff --git a/.scripts/not needed/pacpackages b/.scripts/not needed/pacpackages new file mode 100755 index 0000000..37ebed3 --- /dev/null +++ b/.scripts/not needed/pacpackages @@ -0,0 +1,29 @@ +#!/bin/sh + +# Displays number of upgradeable packages. +# For this to work, have a `pacman -Sy` command run in the background as a +# cronjob every so often as root. This script will then read those packages. +# When clicked, it will run an upgrade via pacman. +# +# Add the following text as a file in /usr/share/libalpm/hooks/statusbar.hook: +# +# [Trigger] +# Operation = Upgrade +# Type = Package +# Target = * +# +# [Action] +# Description = Updating statusbar... +# When = PostTransaction +# Exec = /usr/bin/pkill -RTMIN+8 dwmblocks # Or i3blocks if using i3. + +case $BLOCK_BUTTON in + 1) setsid -f "$TERMINAL" -e sb-popupgrade ;; + 2) notify-send "$(/usr/bin/pacman -Qu)" ;; + 3) notify-send "🎁 Upgrade module" "πŸ“¦: number of upgradable packages +- Left click to upgrade packages +- Middle click to show upgradable packages" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +pacman -Qu | grep -Fcv "[ignored]" | sed "s/^/πŸ“¦/;s/^πŸ“¦0$//g" diff --git a/.scripts/not needed/popupgrade b/.scripts/not needed/popupgrade new file mode 100755 index 0000000..29d6230 --- /dev/null +++ b/.scripts/not needed/popupgrade @@ -0,0 +1,9 @@ +#!/bin/sh + +printf "Beginning upgrade.\\n" + +yay -Syu +pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}" + +printf "\\nUpgrade complete.\\nPress to exit window.\\n\\n" +read -r _ diff --git a/.scripts/not needed/tasks b/.scripts/not needed/tasks new file mode 100755 index 0000000..586300e --- /dev/null +++ b/.scripts/not needed/tasks @@ -0,0 +1,20 @@ +#!/bin/sh + +# Originally by Andr3as07 +# Some changes by Luke +# Rebuild by Tenyun + +# This block displays the number running background tasks. Requires tsp. + +num=$(tsp -l | awk -v numr=0 -v numq=0 '{if (/running/)numr++; if (/queued/)numq++} END{print numr+numq"("numq")"}') + +# Handle mouse clicks +case $BLOCK_BUTTON in + 1) setsid -f "$TERMINAL" -e tsp -l ;; + 3) notify-send "Tasks module" "πŸ€–: number of running/queued background tasks +- Left click opens tsp" ;; # Right click + 2) $EDITOR "$0" ;; # Middle click +esac + +[ "$num" != "0(0)" ] && + echo "πŸ€–$num" diff --git a/.scripts/not needed/torrent b/.scripts/not needed/torrent new file mode 100755 index 0000000..6527005 --- /dev/null +++ b/.scripts/not needed/torrent @@ -0,0 +1,27 @@ +#!/bin/sh + +transmission-remote -l | grep % | + sed " # The letters are for sorting and will not appear. + s/.*Stopped.*/A πŸ›‘/; + s/.*Seeding.*/Z 🌱/; + s/.*100%.*/N βœ…/; + s/.*Idle.*/B πŸ•°οΈ/; + s/.*Uploading.*/L ⬆️/; + s/.*%.*/M ⬇️/" | + sort -h | uniq -c | awk '{print $3 $1}' | paste -sd ' ' - + +case $BLOCK_BUTTON in + 1) setsid -f "$TERMINAL" -e tremc ;; + 2) td-toggle ;; + 3) notify-send "🌱 Torrent module" "\- Left click to open tremc. +- Middle click to toggle transmission. +- Shift click to edit script. +Module shows number of torrents: +πŸ›‘: paused +πŸ•°: idle (seeds needed) +πŸ”Ό: uploading (unfinished) +πŸ”½: downloading +βœ…: done +🌱: done and seeding" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac diff --git a/.scripts/null b/.scripts/null new file mode 100755 index 0000000..ac8b1ed --- /dev/null +++ b/.scripts/null @@ -0,0 +1 @@ +curl -F"file=@$(find $HOME -type f | dmenu -p "Choose file to be uploaded to null server 0x0.st:" -l 15)" https://0x0.st | xclip -sel c diff --git a/.scripts/otp b/.scripts/otp new file mode 100644 index 0000000..1726b1a --- /dev/null +++ b/.scripts/otp @@ -0,0 +1,53 @@ +#!/bin/sh + +# Get a one-time password, or add a OTP secret to your pass-otp store. + +# The assumption of this script is that all otp passwords are stored with the +# suffix `-otp`. This script automatically appends newly added otps as such. + +# For OTP passwords to be generated properly, it is important for the local +# computer to have its time properly synced. This can be done with the command +# below which requires the package `ntp`. + +ifinstalled pass pass-otp + +dir="${PASSWORD_STORE_DIR}" + +choice="$({ echo "πŸ†•add" ; echo "πŸ•™sync-time" ; ls ${dir}/*-otp.gpg ;} | sed "s/.*\///;s/-otp.gpg//" | dmenu -p "Pick a 2FA:")" + +case $choice in + πŸ†•add ) + ifinstalled maim zbar xclip || exit 1 + + temp="$dir/temp.png" + otp="otp-test-script" + trap 'shred -fu $temp; pass rm $otp' HUP INT QUIT TERM PWR EXIT + + notify-send "Scan the image." "Scan the OTP QR code." + + maim -s "$temp" || exit 1 + info="$(zbarimg -q "$temp")" + info="${info#QR-Code:}" + issuer="$(echo "$info" | grep -o "issuer=[A-z0-9]\+")" + name="${issuer#issuer=}" + + if echo "$info" | pass otp insert "$otp"; then + while true ; do + export name="$(dmenu -p "Give this One Time Password a one-word name:")" + echo "$name" | grep -q -- "^[A-z0-9-]\+$" && break + done + pass mv "$otp" "$name-otp" + notify-send "Successfully added." "$name-otp has been created." + else + notify-send "No OTP data found." "Try to scan the image again more precisely." + fi + + ;; + πŸ•™sync-time ) + ifinstalled ntp || exit 1 + notify-send -u low "πŸ•™ Synchronizing Time..." "Synching time with remote NTP servers..." + updatedata="$(sudo ntpdate pool.ntp.org)" && + notify-send -u low "πŸ•™ Synchronizing Time..." "Done. Time changed by ${updatedata#*offset }" + ;; + *) pass otp -c ${choice}-otp ;; +esac diff --git a/.scripts/pdfconv b/.scripts/pdfconv new file mode 100755 index 0000000..5a723d7 --- /dev/null +++ b/.scripts/pdfconv @@ -0,0 +1,3 @@ +#!/bin/sh +find . -type f -iname "*.*" -exec soffice --headless --convert-to pdf {} + && +pdfunite *.pdf output.pdf diff --git a/.scripts/pidkill b/.scripts/pidkill new file mode 100755 index 0000000..e75687f --- /dev/null +++ b/.scripts/pidkill @@ -0,0 +1,9 @@ +#!/bin/sh + +prok=$(ps -u $USER -o pid,%mem,%cpu,comm | sort -b -k2 -r | sed -n '1!p' | dmenu -i -l 15 ) +pid=$(echo $prok | awk '{print $1}') +pname=$(echo $prok | awk '{print $4}') + +kill -15 $pid 2>/dev/null +[ -z $pname ] || dunstify "Terminated process Successfully" "$pname was killed" + diff --git a/.scripts/price b/.scripts/price new file mode 100755 index 0000000..42c84c1 --- /dev/null +++ b/.scripts/price @@ -0,0 +1,50 @@ +#!/bin/sh + +# Usage: +# price +# price bat "Basic Attention Token" 🦁 +# When the name of the currency is multi-word, put it in quotes. + +[ -z "$3" ] && exit 1 + +# use $4 as currency, if not passed in use "usd" as default +currency="${4:-usd}" +interval="@14d" # History contained in chart preceded by '@' (7d = 7 days) +dir="${XDG_DATA_HOME:-$HOME/.local/share}/crypto-prices" +pricefile="$dir/$1-$currency" +chartfile="$dir/$1-$currency-chart" + +updateprice() { temp="$(mktemp)" + curl -s "$currency.rate.sx/1$1" > "$temp" && + mv -f "$temp" "$pricefile" && + curl -s "$currency.rate.sx/$1$interval" > "$temp" && + mv -f "$temp" "$chartfile" ;} + +[ -d "$dir" ] || mkdir -p "$dir" + +[ "$(stat -c %x "$pricefile" 2>/dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] && + updateprice "$1" + +case $BLOCK_BUTTON in + 1) setsid "$TERMINAL" -e less -Srf "$chartfile" ;; + 2) notify-send -u low "$3 Updating..." "Updating $2 price..." + updateprice "$1" && notify-send "$3 Update complete." "$2 price is now +\$$(cat "$pricefile")" ;; + 3) uptime="$(date -d "$(stat -c %x "$pricefile")" '+%D at %T' | sed "s|$(date '+%D')|Today|")" + notify-send "$3 $2 module" "\- Exact price: \$$(cat "$pricefile") +- Left click for chart of changes. +- Middle click to update. +- Shows πŸ”ƒ if updating prices. +- Last updated: + $uptime" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +case "$currency" in + usd) symb="$" ;; + gbp) symb="Β£" ;; + eur) symb="€" ;; + btc) symb="β‚Ώ" ;; +esac + +printf "$3$symb%0.2f$after" "$(cat "$pricefile")" diff --git a/.scripts/redeat b/.scripts/redeat new file mode 100755 index 0000000..e282131 --- /dev/null +++ b/.scripts/redeat @@ -0,0 +1,108 @@ +#!/bin/sh + +# Check if necessary programs are installed +for prog in dmenu jq sxiv; do + [ ! "$(which "$prog")" ] && echo "Please install $prog!" && exit 1 +done +# If notify-send is not installed, use echo as notifier +[ ! "$(which notify-send)" ] && notifier="echo" || notifier="notify-send" + +# args +while [ $# -gt 0 ]; do + case $1 in + -l|--limit) + shift + LIMIT=$1 + case $LIMIT in + ''|*[!0-9]*) + echo 'limit is NaN' + exit 1 + esac + shift + ;; + -f|--filter) + FILTER=1 + shift + ;; + -k|--keep) + KEEP=0 + shift + ;; + -v|--verbose) + VERBOSE=1 + shift + ;; + *) + subreddit=$1 + shift + ;; + esac +done + +# Default config directory +configdir="${XDG_CONFIG_HOME:-$HOME/.config}/redyt" + +# Create .config/redyt if it does not exist to prevent +# the program from not functioning properly +[ ! -d "$configdir" ] && echo "Directory $configdir does not exist, creating..." && mkdir -p "$configdir" + +# Default subreddit that will be inserted in "subreddit.txt" +# if it does not exist +defaultsub="linuxmemes" + +# If subreddit.txt does not exist, create it to prevent +# the program from not functioning properly +[ ! -f "$configdir/subreddit.txt" ] && echo "$defaultsub" >> "$configdir/subreddit.txt" + +# If no argument is passed +if [ -z "$subreddit" ]; then + # Ask the user to enter a subreddit + subreddit=$(dmenu -p "Select Subreddit r/" -i -l 10 < "$configdir/subreddit.txt" | awk -F "|" '{print $1}') + + # If no subreddit was chosen, exit + [ -z "$subreddit" ] && echo "no sub chosen" && exit 1 +fi + +# Default directory used to store the feed file and fetched images +cachedir="/tmp/redyt" + +# If cachedir does not exist, create it +if [ ! -d "$cachedir" ]; then + echo "$cachedir does not exist, creating..." + mkdir -p "$cachedir" +fi + +# Send a notification +[ $VERBOSE = 1 ] && $notifier "Redyt" "πŸ“© Downloading your πŸ–ΌοΈ Memes" + +# Download the subreddit feed, containing only the +# first 100 entries (limit), and store it inside +# cachedir/tmp.json +curl -H "User-agent: 'your bot 0.1'" "https://www.reddit.com/r/$subreddit/hot.json?limit=${LIMIT:-100}" > "$cachedir/tmp.json" + +# Create a list of images +imgs=$(jq '.' < "$cachedir/tmp.json" | grep url_overridden_by_dest | grep -Eo "http(s|)://.*(jpg|png)\b" | sort -u) + +# If there are no images, exit +[ -z "$imgs" ] && $notifier "Redyt" "sadly, there are no images for subreddit $subreddit, please try again later!" && exit 1 + +# Download images to $cachedir +for img in $imgs; do + if [ ! -e "$cachedir/${img##*/}" ]; then + wget -P "$cachedir" $img + fi +done + +# Send a notification +[ $VERBOSE -eq 1 ] && $notifier "Redyt" "πŸ‘ Download Finished, Enjoy! 😊" +rm "$cachedir/tmp.json" + +# Display the images +if [ $FILTER = 1 ]; then + sxiv -a -o "$cachedir" +else + sxiv -a "$cachedir" +fi + +# Once finished, remove all of the cached images +[ ! $KEEP = 1 ] && rm "${cachedir:?}"/* diff --git a/.scripts/reload_dunst b/.scripts/reload_dunst new file mode 100755 index 0000000..525e52a --- /dev/null +++ b/.scripts/reload_dunst @@ -0,0 +1,21 @@ +#!/bin/sh +# +# Script to set colors generated by 'wal' +# https://github.com/dylanaraps/wal + # Source generated colors. + . "${HOME}/.cache/wal/colors.sh" + + reload_dunst() { + pkill dunst + dunst \ + -frame_width 0 \ + -lb "${color0}" \ + -nb "${color0}" \ + -cb "${color0}" \ + -lf "${color7}" \ + -bf "${color7}" \ + -cf "${color7}" \ + -nf "${color7}" & +} + +reload_dunst diff --git a/.scripts/rsyncfon b/.scripts/rsyncfon new file mode 100755 index 0000000..aa6a643 --- /dev/null +++ b/.scripts/rsyncfon @@ -0,0 +1,24 @@ +#!/bin/bash + +echo "Welcome to rsyncfon a fon to pc and vice-versa file-syncing script using the rsync algorithm!" +echo -e "What would you like to do?\r\n1)sync from phone to pc 2)sync from pc to phone " +read option +case "$option" in + "1") + echo -e "Enter public IP on mobile device (starting with 192.): \r\n!Make sure the device and the desktop are connected to the same network!" + read IP + echo "Enter file/folder to be rsync'd (Leave empty if entire sdcard) (/sdcard/*)" + read file + echo "Enter desination path on PC \r\n!!!Make sure to check whether it had sufficient space or not!!!" + read dest + rsync --update --progress -e 'ssh -p 2222' -azv $IP:/sdcard/$file $dest;; + "2") + echo "Enter file/folder from pc to be rsync'd" + read file + echo "Enter public IP" + read IP + echo "Enter destination location( /sdcard/*)" + read dest +rsync --update --progress -e 'ssh -p 2222' -azv $file root@$IP:$dest +esac + diff --git a/.scripts/serch b/.scripts/serch new file mode 100755 index 0000000..0e2acfe --- /dev/null +++ b/.scripts/serch @@ -0,0 +1,5 @@ +#!/bin/sh +sudo -A find / -type f -o -type d -path '/proc/*' -prune| +dmenu -i -p 'Directories/Files to search:' -l 15 | +sed "s/.*/'&'/" | +xclip -sel c diff --git a/.scripts/setbg b/.scripts/setbg new file mode 100755 index 0000000..f267a3a --- /dev/null +++ b/.scripts/setbg @@ -0,0 +1,23 @@ +#!/bin/sh + +if [ -z "$1" ]; then + echo "Chosing a random wallpaper..." + wall=$(find $HOME/Pictures/Wallpaper/w/wow -type f | shuf -n 1) + echo "Setting up the wallpaper: $(echo $wall|cut -d '/' -f 8)" +else + wall="$1" +fi + +echo "Setting up the wallpaper: $(echo $wall)" +xwallpaper --zoom $wall && +echo "Generating pywal color schemes..." +wal -n -i $wall >/dev/null && +echo "dwm reading Xresources color values at runtime" +xdotool key super+F5 +pywal-discord +$HOME/.local/usr/wal-telegram/wal-telegram +ln -sf ~/.cache/wal/dunstrc ~/.config/dunst/dunstrc +pkill dunst +dunst & +#(cd $HOME/.local/src/dwm && sudo make clean install>/dev/null) +echo "^_^ Enjoy your new look!!!" diff --git a/.scripts/setdef b/.scripts/setdef new file mode 100755 index 0000000..ed02376 --- /dev/null +++ b/.scripts/setdef @@ -0,0 +1,7 @@ +#!/bin/sh +#To retuen dwm and st to their default vanilla state +xwallpaper --clear +xrdb -remove +xdotool key alt+shift+q +sleep 5 +picom --experimental-backends diff --git a/.scripts/st-copyout b/.scripts/st-copyout new file mode 120000 index 0000000..e822e4a --- /dev/null +++ b/.scripts/st-copyout @@ -0,0 +1 @@ +/home/saumit/.local/src/st/external-pipe_scripts/st-copyout \ No newline at end of file diff --git a/.scripts/st-urlhandler b/.scripts/st-urlhandler new file mode 120000 index 0000000..0d8625f --- /dev/null +++ b/.scripts/st-urlhandler @@ -0,0 +1 @@ +/home/saumit/.local/src/st/external-pipe_scripts/st-urlhandler \ No newline at end of file diff --git a/.scripts/sxivf b/.scripts/sxivf new file mode 100755 index 0000000..a555a73 --- /dev/null +++ b/.scripts/sxivf @@ -0,0 +1,8 @@ +#!/bin/sh + +if command -v sxiv >/dev/null 2>&1; then + if [ -d "${@: -1}" ] || [ -h "${@: -1}" ]; then + sxiv -t "$@" + else + sxiv "$@" +fi diff --git a/.scripts/todo b/.scripts/todo new file mode 100755 index 0000000..17d7415 --- /dev/null +++ b/.scripts/todo @@ -0,0 +1,28 @@ +#!/bin/sh +# +# Write/remove a task to do later. +# +# Select an existing entry to remove it from the file, or type a new entry to +# add it. +# + +file="$HOME/.todo" +touch "$file" +height=$(wc -l "$file" | awk '{print $1}') +prompt="Add/delete a task: " + +cmd=$(dmenu -l "$height" -p "$prompt" "$@" < "$file") +while [ -n "$cmd" ]; do + if grep -q "^$cmd\$" "$file"; then + grep -v "^$cmd\$" "$file" > "$file.$$" + mv "$file.$$" "$file" + height=$(( height - 1 )) + else + echo "$cmd" >> "$file" + height=$(( height + 1 )) + fi + + cmd=$(dmenu -l "$height" -p "$prompt" "$@" < "$file") +done + +exit 0 diff --git a/.scripts/trashy b/.scripts/trashy new file mode 100755 index 0000000..3318e41 --- /dev/null +++ b/.scripts/trashy @@ -0,0 +1,5 @@ +#!/bin/sh + +trashfiledir=$(find $HOME -type f -o -type d | dmenu -i -p "File to be deleted:" -l 15| awk '{printf('\"%s\"\n', $0);}') + +trash-put $trashfiledir diff --git a/.scripts/upmenu b/.scripts/upmenu new file mode 100755 index 0000000..f600e3a --- /dev/null +++ b/.scripts/upmenu @@ -0,0 +1,46 @@ +#!/bin/sh + +# hello guys its mokuken!! + +function upmenu { + options="Upload a File\nRecent Uploads\nCancel" + selected=$(echo -e $options | dmenu -l 3 ) + if [[ "$selected" == "Upload a File" ]]; then + + target="$1" + [ -z "$target" ] && target="$(realpath .)" + + while :; do + sel="$(ls -1a "$target" | grep -v '^\.$' | dmenu -l 25 )" || exit + if [ "$(echo "$sel" | cut -b1)" = "/" ]; then + newt="$sel" + else + newt="$(realpath "$target/$sel")" + fi + if [ -e "$newt" ]; then + target="$newt" + if [ ! -d "$target" ]; then + echo "Location: $target" + command="curl -s -F'file=@$target' https://0x0.st" + echo "Executing: $command" + + url=$(eval $command) + echo "URL: $url" + + printf "$url" | xclip -sel clip + notify-send "File Uploaded" "URL: $url \ncopied to clipboard" -t 5000 -i "$HOME/.program/icon.png" + + entry="$(date '+%d-%m-%y-%H:%M:%S') $url $(echo $target | awk -F'/' '{print $(NF)}')" + echo $entry >> $HOME/.0x0_list + echo "Uploaded"; break + fi + fi + done + elif [[ "$selected" == "Recent Uploads" ]]; then + cat ~/.0x0_list | dmenu -l 10 + elif [[ "$selected" == "Cancel" ]]; then + return + fi +} + +upmenu diff --git a/.scripts/urbandictserch b/.scripts/urbandictserch new file mode 100755 index 0000000..c007d60 --- /dev/null +++ b/.scripts/urbandictserch @@ -0,0 +1,15 @@ +#!/bin/sh + +search=$(echo "" | dmenu -p 'Urban Dictionary:'|sed 's/ /%20/g') + +curl -s "https://api.urbandictionary.com/v0/define?term={$search}" | jq '.' | grep --color=always definition | awk 'BEGIN {RS="definition"; ORS=""} {print $0""++i}' > /tmp/urban-dic + +n=$(wc -l < /tmp/urban-dic) +touch /tmp/urban-dic.txt && > /tmp/urban-dic.txt + +for i in $(eval echo {1..$n}p) +do + sed -n $i /tmp/urban-dic|sed -r "s/\x1B\[[0-9;]*[a-zA-Z]//g" >> /tmp/urban-dic.txt +done +cat /tmp/urban-dic.txt | dmenu -l $n -p "$1"i + diff --git a/.scripts/volume b/.scripts/volume new file mode 100755 index 0000000..3cfdc45 --- /dev/null +++ b/.scripts/volume @@ -0,0 +1,30 @@ +#!/bin/sh + +# Prints the current volume or πŸ”‡ if muted. + +case $BLOCK_BUTTON in + 1) setsid -f "$TERMINAL" -e pulsemixer ;; + 2) pamixer -t ;; + 4) pamixer --allow-boost -i 1 ;; + 5) pamixer --allow-boost -d 1 ;; + 3) notify-send "πŸ“’ Volume module" "\- Shows volume πŸ”Š, πŸ”‡ if muted. +- Middle click to mute. +- Scroll to change." ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +[ $(pamixer --get-mute) = true ] && echo πŸ”‡ && exit + +vol="$(pamixer --get-volume)" + +if [ "$vol" -gt "70" ]; then + icon="πŸ”Š" +elif [ "$vol" -gt "30" ]; then + icon="πŸ”‰" +elif [ "$vol" -gt "0" ]; then + icon="πŸ”ˆ" +else + echo πŸ”‡ && exit +fi + +echo "$icon$vol%" diff --git a/.scripts/vpn-menu b/.scripts/vpn-menu new file mode 100755 index 0000000..87d429b --- /dev/null +++ b/.scripts/vpn-menu @@ -0,0 +1,5 @@ +#!/bin/sh + +vpnid=$(nmcli con | grep "vpn" | cut -d " " -f 1 | dmenu -p "Select VPN to activate/deactivate") +actdeact=$(echo -e "up\ndown" | dmenu -p "Activate or Deactivate? (up or down)") +nmcli con $actdeact id $vpnid diff --git a/.scripts/wifi-menu b/.scripts/wifi-menu new file mode 100755 index 0000000..dd5b9b3 --- /dev/null +++ b/.scripts/wifi-menu @@ -0,0 +1,13 @@ +#!/bin/sh + +choice=$(echo -e "up\ndown\nconnect" | dmenu -p "Do you wish to connect to a wi-fi or disconnect?:") + +case $choice in + "up"|"down") + ssid=$(nmcli -t -f ssid dev wifi| cut -d\' -f2 | dmenu -p "Select Wifi  " -l 20) + nmcli c $choice "$ssid" ;; + "connect") + bssid=$(nmcli device wifi list | sed -n '1!p' | cut -b 9- | dmenu -p "Select Wi-Fi  :" -l 20 | cut -d' ' -f1) + pass=$(echo "" | dmenu -P -p "Enter Password ο … : ") + nmcli device wifi connect $bssid password $pass ;; +esac diff --git a/.scripts/wifi-menu-custom b/.scripts/wifi-menu-custom new file mode 100755 index 0000000..db2fced --- /dev/null +++ b/.scripts/wifi-menu-custom @@ -0,0 +1,22 @@ +#!/bin/sh + +choice=$(echo -e "up\ndown\nconnect" | dmenu -p "Do you wish to connect to a wi-fi or disconnect?:") + +case $choice in + "connect") + bssid=$(nmcli device wifi list | sed -n '1!p' | cut -b 9- | dmenu -p "Select Wifi  " -l 20 | cut -d' ' -f1) + pass=$(echo "" | dmenu -p "Enter Pswd ο … ") + nmcli device wifi $choice $bssid password $pass;; + "up" | "down") + ssid=$(nmcli device wifi list | sed -n '1!p' | cut -b 9- | dmenu -p "Select Wifi  " -l 20 | cut -d' ' -f3) + nmcli c $choice $ssid;; +esac +wifistatus=$(nmcli d | grep wlan0 | cut -d ' ' -f10) +case $wifistatus in + "connected") + nmcli con down eth0 "Wired connection 1";; + "disconnected") + nmcli con up eth0 "Wired connection 1";; +esac +ethstatus=$(nmcli d | grep eth0 | cut -d ' ' -f7) +notify-send "Ethernet connection is $ethstatus" -- cgit v1.2.3