From a3bad57a59b857febb72d6ae68b46e51e2165c0d Mon Sep 17 00:00:00 2001 From: krolyxon Date: Fri, 3 Feb 2023 12:57:22 +0530 Subject: mounter, unmounter, profile, sbar --- .local/bin/dmenumount | 41 ----------------------------------------- .local/bin/dmenuumount | 22 ---------------------- .local/bin/mounter | 41 +++++++++++++++++++++++++++++++++++++++++ .local/bin/sbar | 2 +- .local/bin/unicode_emoji | 2 +- .local/bin/unmounter | 22 ++++++++++++++++++++++ .local/share/vocab/words.txt | 3 +++ 7 files changed, 68 insertions(+), 65 deletions(-) delete mode 100755 .local/bin/dmenumount delete mode 100755 .local/bin/dmenuumount create mode 100755 .local/bin/mounter create mode 100755 .local/bin/unmounter (limited to '.local') diff --git a/.local/bin/dmenumount b/.local/bin/dmenumount deleted file mode 100755 index 241e6fd..0000000 --- a/.local/bin/dmenumount +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh - -# Gives a dmenu prompt to mount unmounted drives. 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 && notify-send "💻 USB mounting" "$chosen mounted." && 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 - notify-send "💻 USB mounting" "$chosen mounted to $mp." - } - -usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | grep 'part\|rom' | awk '$4==""{printf "%s (%s)\n",$1,$3}')" - -if [ -z "$usbdrives" ]; then - echo "No USB drive detected" && exit -else - echo "USB drive(s) detected." - mountusb -fi diff --git a/.local/bin/dmenuumount b/.local/bin/dmenuumount deleted file mode 100755 index d9be444..0000000 --- a/.local/bin/dmenuumount +++ /dev/null @@ -1,22 +0,0 @@ -#!/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." - } - -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 [ -z "$drives" ]; then - echo "No drives to unmount." && exit -else - echo "Unmountable USB drive detected." - unmountusb -fi diff --git a/.local/bin/mounter b/.local/bin/mounter new file mode 100755 index 0000000..241e6fd --- /dev/null +++ b/.local/bin/mounter @@ -0,0 +1,41 @@ +#!/bin/sh + +# Gives a dmenu prompt to mount unmounted drives. 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 && notify-send "💻 USB mounting" "$chosen mounted." && 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 + notify-send "💻 USB mounting" "$chosen mounted to $mp." + } + +usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | grep 'part\|rom' | awk '$4==""{printf "%s (%s)\n",$1,$3}')" + +if [ -z "$usbdrives" ]; then + echo "No USB drive detected" && exit +else + echo "USB drive(s) detected." + mountusb +fi diff --git a/.local/bin/sbar b/.local/bin/sbar index 67a0ca4..cd32308 100755 --- a/.local/bin/sbar +++ b/.local/bin/sbar @@ -22,7 +22,7 @@ update_music () { if [ -z "$(sb-music)" ]; then music="" else - music="[ $(sb-music) ]" + music="[ $(sb-music) ] " fi } diff --git a/.local/bin/unicode_emoji b/.local/bin/unicode_emoji index 415a268..91ff6fe 100755 --- a/.local/bin/unicode_emoji +++ b/.local/bin/unicode_emoji @@ -10,4 +10,4 @@ chosen=$(cut -d ';' -f1 ~/.local/share/emoji | dmenu -i -l 30 | sed "s/ .*//") xdotool type "$chosen" printf "$chosen" | xclip -selection clipboard -notify-send "'$chosen' copied to clipboard." & \ No newline at end of file +notify-send "'$chosen' copied to clipboard." & diff --git a/.local/bin/unmounter b/.local/bin/unmounter new file mode 100755 index 0000000..d9be444 --- /dev/null +++ b/.local/bin/unmounter @@ -0,0 +1,22 @@ +#!/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." + } + +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 [ -z "$drives" ]; then + echo "No drives to unmount." && exit +else + echo "Unmountable USB drive detected." + unmountusb +fi diff --git a/.local/share/vocab/words.txt b/.local/share/vocab/words.txt index e4fc9d9..1f613d7 100644 --- a/.local/share/vocab/words.txt +++ b/.local/share/vocab/words.txt @@ -88,3 +88,6 @@ trait -> a distinguishing quality or characteristic, typically one belonging to pedantic -> excessively concerned with minor details or rules; overscrupulous. avid -> having or showing a keen interest in or enthusiasm for something eerie -> strange and frightening +prepend -> add (something) to the beginning of something else +notion -> a conception of or belief about something +robust -> strong and healthy -- cgit v1.2.3