summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
author--global <ik.boikov.public@protonmail.com>2021-08-08 19:39:46 +0200
committer--global <ik.boikov.public@protonmail.com>2021-08-08 19:39:46 +0200
commita4aff15001464ac8e7a948e4ed98aa5af19663ad (patch)
tree816e00fc9ff99a18444086d20317e8e8f4f51fc6 /scripts
parent7fa1acb751b2f3ade2baec109b1aef712f663ac9 (diff)
more dmenu scripts, consistent dmenu coloring in scripts
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/.local/bin/cdmenu3
-rwxr-xr-xscripts/.local/bin/dkill24
-rwxr-xr-xscripts/.local/bin/dmnt25
3 files changed, 41 insertions, 11 deletions
diff --git a/scripts/.local/bin/cdmenu b/scripts/.local/bin/cdmenu
new file mode 100755
index 0000000..67d9b7a
--- /dev/null
+++ b/scripts/.local/bin/cdmenu
@@ -0,0 +1,3 @@
+#! /bin/bash
+# colored dmenu for use in scripts
+dmenu -nb '#020e1d' -nf '#00b1ff' -sb '#00b1ff' -sf '#020e1d' "$@"
diff --git a/scripts/.local/bin/dkill b/scripts/.local/bin/dkill
new file mode 100755
index 0000000..3e0b7ea
--- /dev/null
+++ b/scripts/.local/bin/dkill
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+
+# dmenu theming
+dmenu="cdmenu"
+lines="-l 30"
+
+selected="$(ps -a -u $USER | \
+ "$dmenu" -i -p "Select process to kill" \
+ $lines | \
+ awk '{print $1" "$4}')";
+
+if [[ ! -z $selected ]]; then
+
+ answer="$(echo -e "Yes\nNo" | \
+ "$dmenu" -i -p "$selected will be killed, are you sure?" \
+ $lines )"
+
+ if [[ $answer == "Yes" ]]; then
+ selpid="$(awk '{print $1}' <<< $selected)";
+ kill -9 $selpid
+ fi
+fi
+
+exit 0
diff --git a/scripts/.local/bin/dmnt b/scripts/.local/bin/dmnt
index 2d8ecd6..b840507 100755
--- a/scripts/.local/bin/dmnt
+++ b/scripts/.local/bin/dmnt
@@ -1,12 +1,15 @@
-#!/bin/sh
+#!/bin/zsh
+
+#shopt -s expand_aliases
+dmenu="cdmenu"
getmount() { \
[ -z "$chosen" ] && exit 1
# shellcheck disable=SC2086
- mp="$(find $1 2>/dev/null | dmenu -l 30 -i -p "Type in mount point.")" || exit 1
+ mp="$(find $1 2>/dev/null | "$dmenu" -l 30 -i -p "Type in mount point.")" || exit 1
[ "$mp" = "" ] && exit 1
if [ ! -d "$mp" ]; then
- mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?") || exit 1
+ 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
}
@@ -27,7 +30,7 @@ mountusb() { \
mountandroid() { \
getmount "/mnt -maxdepth 1 -type d"
jmtpfs -device="$1" "$mp"
- #echo "OK" | dmenu -i -p "Tap Allow on your phone if it asks for permission and then press enter" || exit 1
+ #echo "OK" | "$dmenu" -i -p "Tap Allow on your phone if it asks for permission and then press enter" || exit 1
#jmtpfs -device="$1" "$mp"
notify-send "Android mounting" "Android device mounted to $mp."
}
@@ -42,10 +45,10 @@ unmountdev() {
}
selectusb() { \
- chosen=$(lsblk -lpo "vendor,model,name,label,size,mountpoint" | dmenu -l 30 | xargs | cut -d' ' -f 1)
+ chosen=$(lsblk -lpo "vendor,model,name,label,size,mountpoint" | "$dmenu" -l 30 | xargs | cut -d' ' -f 1)
# if mounted
if [ ! -z "$(grep $chosen "/etc/mtab")" ] ; then
- choice=$(echo "No\nYes" | dmenu -l 2 -p "Partition is mounted. Unmount?")
+ choice=$(echo "No\nYes" | "$dmenu" -l 2 -p "Partition is mounted. Unmount?")
case $choice in
Yes) unmountdev $chosen ;;
No) exit ;;
@@ -68,15 +71,15 @@ selectandroid() { \
list="$list$unmounted"
fi
- chosen=$(echo "$list" "$mounted" | dmenu -i -l 30)
+ chosen=$(echo "$list" "$mounted" | "$dmenu" -i -l 30)
echo "CHOSEN" $chosen
- case $chosen in
- *jmtpfs*) unmountdev $(echo $chosen | cut -d' ' -f 2) ;;
- *) mountandroid $(echo $chosen | awk '{print $1 $2}' | cut -d, -f1-2) ;;
+ case $chosen in
+ *jmtpfs*) unmountdev $(echo $chosen | cut -d' ' -f 2) ;;
+ *) mountandroid $(echo $chosen | awk '{print $1 $2}' | cut -d, -f1-2) ;;
esac
}
-choice="$(printf "USB\\nAndroid" | dmenu -i -p "(Un-)mount a USB drive or Android device?")" || exit 1
+choice="$(printf "USB\\nAndroid" | "$dmenu" -i -p "(Un-)mount a USB drive or Android device?")" || exit 1
case $choice in
USB) selectusb ;;
Android) selectandroid ;;