aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2022-07-31 12:39:36 +0200
committerInigoGutierrez <inigogf.95@gmail.com>2022-07-31 12:39:36 +0200
commitd53ce5574b0bfd6f78394f9469a043c04866ecdc (patch)
treeb31d0bb729fb2d93a2e8ad0d0db14ad589c4c7a4
parent80aa1954df73bbe0b238cd2fd254cb179dbe3b0e (diff)
downloadscripts-d53ce5574b0bfd6f78394f9469a043c04866ecdc.tar.gz
scripts-d53ce5574b0bfd6f78394f9469a043c04866ecdc.zip
Created dmenu wrapper and made all (hopefully) scripts compatible with vanilla dmenu.
-rwxr-xr-xbluetooth/btConnect.sh2
-rwxr-xr-xclipboardUtils.sh8
-rwxr-xr-xdmenu5
-rwxr-xr-xdmenuDic.sh10
-rwxr-xr-xdmenuMount.sh4
-rwxr-xr-xdmenuTerm.sh2
-rwxr-xr-xdmenuUmount.sh4
-rwxr-xr-xdocs.sh2
-rwxr-xr-xemoji/emoji.sh2
-rwxr-xr-xquicktext.sh4
-rwxr-xr-xselectAudioSink.sh2
-rwxr-xr-xsurfraw.sh2
-rwxr-xr-xsystemControl.sh4
-rwxr-xr-xwebview.sh12
14 files changed, 38 insertions, 25 deletions
diff --git a/bluetooth/btConnect.sh b/bluetooth/btConnect.sh
index 801fbf3..0fccbba 100755
--- a/bluetooth/btConnect.sh
+++ b/bluetooth/btConnect.sh
@@ -26,7 +26,7 @@ if bluetoothctl show | grep -Fq 'Powered: no'; then
fi
lines=$(bluetoothctl paired-devices | wc -l)
-selected=$(bluetoothctl paired-devices | dmenu -c -bw 3 -i -l $lines -p "💓") || exit 1
+selected=$(bluetoothctl paired-devices | dmenu -l $lines -p "💓") || exit 1
mac=$(echo $selected | cut -d' ' -f2)
name=$(echo $selected | cut -d' ' -f3-)
diff --git a/clipboardUtils.sh b/clipboardUtils.sh
index 49f39d0..1789905 100755
--- a/clipboardUtils.sh
+++ b/clipboardUtils.sh
@@ -6,7 +6,7 @@
options="Show selections\nReplicate selections\nWrite to selection\n"
selections="Clipboard\nPrimary\nSecondary\n"
-target="$(printf "$options" | dmenu -l 3 -i -p "~ Clipboard utils ~")"
+target="$(printf "$options" | dmenu -l 3 -p "~ Clipboard utils ~")"
[ "$target" = "" ] && exit 0
case "$target" in
@@ -16,14 +16,14 @@ Primary: [$(xsel -po)]
Secondary: [$(xsel -so)]" ;;
"Replicate selections")
- fromSelection="$(printf "$selections" | dmenu -l 3 -i -p "From selection:")"
+ fromSelection="$(printf "$selections" | dmenu -l 3 -p "From selection:")"
[ "$fromSelection" = "" ] && exit 0
case "$fromSelection" in
"Clipboard") fromOption=b ;;
"Primary") fromOption=p ;;
"Secondary") fromOption=s ;;
esac
- toSelection="$(printf "$selections" | dmenu -l 3 -i -p "To selection:")"
+ toSelection="$(printf "$selections" | dmenu -l 3 -p "To selection:")"
[ "$toSelection" = "" ] && exit 0
case "$toSelection" in
"Clipboard") toOption=b ;;
@@ -33,7 +33,7 @@ Secondary: [$(xsel -so)]" ;;
xsel -"$fromOption"o | xsel -"$toOption"i && notify-send "Copied [$(xsel -"$toOption"o)] from $fromSelection to $toSelection." ;;
"Write to selection")
- selectedSelection="$(printf "$selections" | dmenu -l 3 -i -p "Write to which selection?")"
+ selectedSelection="$(printf "$selections" | dmenu -l 3 -p "Write to which selection?")"
textToWrite="$(dmenu -p "Text to write to $selectedSelection:")"
[ "$textToWrite" = "" ] && exit 0
case "$selectedSelection" in
diff --git a/dmenu b/dmenu
new file mode 100755
index 0000000..3f26359
--- /dev/null
+++ b/dmenu
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+# Wrapper for dmenu
+
+/usr/local/bin/dmenu -c -bw 3 -i "$@"
diff --git a/dmenuDic.sh b/dmenuDic.sh
index 7c67fe6..56c9301 100755
--- a/dmenuDic.sh
+++ b/dmenuDic.sh
@@ -5,19 +5,19 @@
dicES="$CONFIG_DIC_ES"
dicEN="$CONFIG_DIC_EN"
dicPL="$CONFIG_DIC_PL"
-lines=10
-dict="$(printf "EN\nES\nPL" | dmenu -i -p "Choose a dictionary:")"
+lines=25
+dict="$(printf "EN\nES\nPL" | dmenu -l "$lines" -p "Choose a dictionary:")"
if [ "$dict" = "ES" ]; then
[ ! -f "$dicES" ] && dunstify "ES dic file ($dicES) does not exist." && exit 0
- word="$(dmenu -i -l $lines -p "Elige una palabra:" < "$dicES" )"
+ word="$(dmenu -l "$lines" -p "Elige una palabra:" < "$dicES" )"
fi
if [ "$dict" = "EN" ]; then
[ ! -f "$dicEN" ] && dunstify "EN dic file ($dicEN) does not exist." && exit 0
- word="$(dmenu -i -l $lines -p "Choose a word:" < "$dicEN")"
+ word="$(dmenu -l "$lines" -p "Choose a word:" < "$dicEN")"
fi
if [ "$dict" = "PL" ]; then
[ ! -f "$dicPL" ] && dunstify "PL dic file ($dicPL) does not exist." && exit 0
- word="$(dmenu -i -l $lines -p "Wybierz słowo:" < "$dicPL")"
+ word="$(dmenu -l "$lines" -p "Wybierz słowo:" < "$dicPL")"
fi
[ "$word" ] || exit 0
echo "$word" | tr -d '\n' | xsel -bi
diff --git a/dmenuMount.sh b/dmenuMount.sh
index f453078..d91888a 100755
--- a/dmenuMount.sh
+++ b/dmenuMount.sh
@@ -33,7 +33,7 @@ do
done <<< "$(lsblk -lp | grep "part $" )"
[[ "$mountable" = "" ]] && exit 1
lines=$(echo "$mountable" | wc -l)
-chosen=$(echo "$mountable" | dmenu -i -l "$lines" -p "Mount which drive?" | awk '{print $2}')
+chosen=$(echo "$mountable" | dmenu -l "$lines" -p "Mount which drive?" | awk '{print $2}')
[ "$chosen" == "" ] && exit 1
sudo mount "$chosen" && pgrep -x dunst && notify-send "$chosen mounted." && exit 0
@@ -46,7 +46,7 @@ do
directories="$directories$i. $line"$'\n'
done <<< "$(find /mnt "$HOME/mounts" -type d -maxdepth 3 -empty 2>/dev/null)"
lines=$(echo "$directories" | wc -l)
-mountpoint=$(echo "$directories" | dmenu -i -l "$lines" -p "Type in mount point." | awk '{print $2}')
+mountpoint=$(echo "$directories" | dmenu -l "$lines" -p "Type in mount point." | awk '{print $2}')
[ "$mountpoint" == "" ] && exit 1
if [[ ! -d "$mountpoint" ]]; then
prompt.sh "$mountpoint does not exist. Create it?" "sudo mkdir -p $mountpoint"
diff --git a/dmenuTerm.sh b/dmenuTerm.sh
index 7f4e1f8..5f984b7 100755
--- a/dmenuTerm.sh
+++ b/dmenuTerm.sh
@@ -5,7 +5,7 @@ options="neofetch\ncmus\ncmus (float)\nweather\nReset NetworkManager\nwifiUp\nwi
count="$(printf "$options" | wc -l)"
-chosen="$(printf "$options" | dmenu -i -l "$count" -p "~$ urxvt -e")"
+chosen="$(printf "$options" | dmenu -l "$count" -p "~$ urxvt -e")"
case "$chosen" in
# floating windows
diff --git a/dmenuUmount.sh b/dmenuUmount.sh
index d2c8fb3..3464591 100755
--- a/dmenuUmount.sh
+++ b/dmenuUmount.sh
@@ -10,7 +10,7 @@
# | |_| | | | | | | (_) | |_| | | | | |_\__ \
# \__,_|_| |_| |_|\___/ \__,_|_| |_|\__|___/
#
-# Gives a dmenu prompt to umount mounted drives.
+# Gives a dmenu prompt to unmount mounted drives.
# Shows mounted partitions; select one to unmount.
exclusionregex="\(/boot/efi\|/home\|/\)$"
@@ -30,6 +30,6 @@ do
done <<< "$list"
[ "$drives" = "" ] && exit
lines=$(echo "$drives" | wc -l)
-chosen=$(echo "$drives" | dmenu -i -l "$lines" -p "Unmount which drive?" | awk '{print $2}')
+chosen=$(echo "$drives" | dmenu -l "$lines" -p "Unmount which drive?" | awk '{print $2}')
[ "$chosen" = "" ] && exit
sudo umount "$chosen" && pgrep -x dunst && notify-send "$chosen unmounted."
diff --git a/docs.sh b/docs.sh
index 90a655d..fefb2b8 100755
--- a/docs.sh
+++ b/docs.sh
@@ -15,7 +15,7 @@
referencesFile="$HOME/.config/zathura/refs"
lines="$(wc -l "$referencesFile")"
if reference="$(sed '/^#/d' "$referencesFile" | sed '/^\s*$/d' | cut -d# -f1 |
- dmenu -c -bw 3 -i -l "$lines" -p "Reference: ")"; then
+ dmenu -l "$lines" -p "Reference: ")"; then
line="$(grep "$reference" "$referencesFile" | sed q)"
file="$(echo "$line" | cut -d# -f2)"
page="$(echo "$line" | cut -d# -f3)"
diff --git a/emoji/emoji.sh b/emoji/emoji.sh
index 09eec51..6bbe041 100755
--- a/emoji/emoji.sh
+++ b/emoji/emoji.sh
@@ -44,7 +44,7 @@ usedEmojis="$(echo "$emojiList" | grep '^[0-9]' | sort -nr)"
# Choose an emoji with dmenu
lineNoNumber="$(echo "$emojiList" |
sed 's/^[ 0-9]*//' |
- "$dmenuPath" -i -l 40 $dmenuGridOptions -p "Emoji:")"
+ "$dmenuPath" -l 40 $dmenuGridOptions -p "Emoji:")"
if [ -z "$lineNoNumber" ] || echo "$lineNoNumber" | grep -q '^-'; then
exit 0
diff --git a/quicktext.sh b/quicktext.sh
index a399fd3..d71e659 100755
--- a/quicktext.sh
+++ b/quicktext.sh
@@ -2,4 +2,6 @@
# Selects a string from a file of frequently used strings
-dmenu -i -p "Choose a string: " <"$HOME/.config/quicktext" | xsel -bi
+file="$HOME/.config/quicktext"
+
+dmenu -l "$(wc -l "$file")" -p "🗒️" <"$file" | xsel -bi
diff --git a/selectAudioSink.sh b/selectAudioSink.sh
index 58bf9f6..e5b0c68 100755
--- a/selectAudioSink.sh
+++ b/selectAudioSink.sh
@@ -7,6 +7,6 @@
port="$(pactl list sinks |
sed -n '/Ports/,/Active Port/p' |
sed '/Ports/d;/Active/d;s/:.*$//;s/^\s*//' |
- dmenu -c -bw 3 -i -l 10)"
+ dmenu -l 10)"
pactl set-sink-port alsa_output.pci-0000_00_1f.3.analog-stereo "$port"
diff --git a/surfraw.sh b/surfraw.sh
index 86b4512..cdec610 100755
--- a/surfraw.sh
+++ b/surfraw.sh
@@ -10,7 +10,7 @@ target="$(ddgr --json "$search" |
sed '/"title": / N;s/\n//g' |
awk '-F ["]' '{print $3 "[" $5 "]" }' |
sed 's/"//g;s/,\s*\[/ \[/' |
- dmenu -i -l 10 -p "Target:" |
+ dmenu -l 10 -p "Target:" |
awk '-F [[]' '{print $2}' |
sed 's/]\s*$//')"
dunstify "Trying to play result of $target"
diff --git a/systemControl.sh b/systemControl.sh
index 0426363..0e64495 100755
--- a/systemControl.sh
+++ b/systemControl.sh
@@ -1,9 +1,9 @@
#!/bin/bash
# A dmenu prompt script to control system functions.
-options="lock\nreboot\nshutdown\nsuspend\nhibernate\nexit bspwm\nexit i3"
+options="lock\nreboot\nshutdown\nsuspend\nhibernate\nexit bspwm\nexit i3\n"
-chosen=$(printf "$options" | dmenu -c -bw 3 -l "$(printf "${options}\n" | wc -l)" -p ">_")
+chosen=$(printf "$options" | dmenu -l "$(printf "${options}" | wc -l)" -p ">_")
case "$chosen" in
"lock") i3lock.sh ;;
diff --git a/webview.sh b/webview.sh
index ae3915a..c7ff6d3 100755
--- a/webview.sh
+++ b/webview.sh
@@ -14,7 +14,9 @@ imgViewer="showURLimage.sh"
# Check youtube link
if echo "$1" | grep "youtube" >/dev/null; then
- chosen=$(printf "mpv\nmpv (loop)\nmpv (float)\nmpv (terminal)\ndownload (y-dl)\nqutebrowser\nw3m\n" | dmenu -i)
+ options="mpv\nmpv (loop)\nmpv (float)\nmpv (terminal)\ndownload (y-dl)\nqutebrowser\nw3m\n"
+ count="$(printf "$options" | wc -l)"
+ chosen=$(printf "$options" | dmenu -l "$count")
case "$chosen" in
"mpv") nohup mpv "$1" >/dev/null & ;;
"mpv (loop)") nohup mpv --loop "$1" >/dev/null & ;;
@@ -28,7 +30,9 @@ if echo "$1" | grep "youtube" >/dev/null; then
elif echo "$imageFiles" | grep -w "$ext" >/dev/null; then
"$imgViewer" "$1" >/dev/null &
elif echo "$mpvFiles" | grep -w "$ext" >/dev/null; then
- chosen=$(printf "mpv\nmpv (loop)\nmpv (float)\nmpv (terminal)\nqutebrowser\n" | dmenu -i)
+ options="mpv\nmpv (loop)\nmpv (float)\nmpv (terminal)\nqutebrowser\n"
+ count="$(printf "$options" | wc -l)"
+ chosen=$(printf "$options" | dmenu -l "$count")
case "$chosen" in
mpv) nohup mpv "$1" >/dev/null & ;;
"mpv (loop)") nohup mpv --loop "$1" >/dev/null & ;;
@@ -39,7 +43,9 @@ elif echo "$mpvFiles" | grep -w "$ext" >/dev/null; then
elif echo "$wgetFiles" | grep -w "$ext" >/dev/null; then
nohup wget "$1" >~/log-wget.txt &
else
- chosen=$(printf "mpv\nmpv (loop)\nmpv (float)\nmpv (terminal)\nsxiv\ndownload (y-dl)\nqutebrowser\nw3m\n" | dmenu -i)
+ options="mpv\nmpv (loop)\nmpv (float)\nmpv (terminal)\nsxiv\ndownload (y-dl)\nqutebrowser\nw3m\n"
+ count="$(printf "$options" | wc -l)"
+ chosen=$(printf "$options" | dmenu -l "$count")
case "$chosen" in
mpv) nohup mpv "$1" >/dev/null & ;;
"mpv (loop)") nohup mpv --loop "$1" >/dev/null & ;;