aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano.tronto@gmail.com>2022-05-15 12:02:59 +0200
committerSebastiano Tronto <sebastiano.tronto@gmail.com>2022-05-15 12:02:59 +0200
commit115ff9a06870d51702918cd926199e2271bf4f92 (patch)
tree4c2abf616b9eec3ba485f49bcefaf0a98882fa33
parent5ca3ebbf7c3cef6db6b8270af4fcf0be087c29c1 (diff)
downloadscripts-115ff9a06870d51702918cd926199e2271bf4f92.tar.gz
scripts-115ff9a06870d51702918cd926199e2271bf4f92.zip
Added option to specify alternative menu. Some general cleanup.
Diffstat (limited to '')
-rw-r--r--Makefile1
-rw-r--r--TODO9
-rwxr-xr-xclip18
-rwxr-xr-xdmenu-bookmarks7
-rwxr-xr-xdmenu-dwm-sessionmanager18
-rwxr-xr-xdmenu-filepicker16
-rwxr-xr-xdmenu-mail-aliases13
-rwxr-xr-xdmenu-screenshot17
-rwxr-xr-xdmenu-unmount18
-rwxr-xr-xdmenu-urlselect15
-rwxr-xr-xold/xkboptions (renamed from xkboptions)0
-rwxr-xr-xopen-file15
12 files changed, 104 insertions, 43 deletions
diff --git a/Makefile b/Makefile
index 0822e70..99cc5f1 100644
--- a/Makefile
+++ b/Makefile
@@ -41,7 +41,6 @@ SCRIPTS = addressgrep \
41 websearch \ 41 websearch \
42 xedit \ 42 xedit \
43 xedit-filter \ 43 xedit-filter \
44 xkboptions \
45 xplumb \ 44 xplumb \
46 xprop-active-window-id \ 45 xprop-active-window-id \
47 xwallpaper-random-notify 46 xwallpaper-random-notify
diff --git a/TODO b/TODO
index bf26303..317a569 100644
--- a/TODO
+++ b/TODO
@@ -1,11 +1,6 @@
1* Modify all dmenu-* scripts to optionally use another menu, like vis-menu (slmenu) 1* dmenu-bookmarks: add option for different directory
2 Do this by taking an optional $1 which is the name of the program to use
3 (optional $dir argument is removed: fix dmenu-bookmarks simply using cd)
4* Big problem: slmenu does not allow multiple selections; this is a problem
5 for my workflow for sel and for sfeed-menu (and sometimes for open-file)
6* Solution: leave dmenu default option, use slmenu for a selected few aliases in .profile
7 2
8* mblaze-extras: remove mmv, just use complete_mrefile=mail/... 3* mblaze-extras: maybe remove script and just use aliases?
9 4
10* sfeed-browser: optionally just write link to stdout (or to xsel -i) 5* sfeed-browser: optionally just write link to stdout (or to xsel -i)
11 6
diff --git a/clip b/clip
index 4f1ae25..dbd3f33 100755
--- a/clip
+++ b/clip
@@ -7,12 +7,20 @@
7# Bugs (wontfix): the program fails if it can't create the temporary 7# Bugs (wontfix): the program fails if it can't create the temporary
8# directory with the designated name. 8# directory with the designated name.
9 9
10# Requires: xsel, dmenu 10# Usage: clip [-m menu]
11 11
12# TODO: improve formatting in dmenu 12# Requires: xsel, dmenu (or similar)
13 13
14menu="dmenu" 14menu="dmenu -i -l 25"
15menuopts="-l 25" 15
16while getopts "m:" opt; do
17 case "$opt" in
18 m)
19 menu="$OPTARG"
20 ;;
21 esac
22done
23shift `expr $OPTIND - 1`
16 24
17dir="/tmp/clipdir" 25dir="/tmp/clipdir"
18mkdir -p "$dir" 26mkdir -p "$dir"
@@ -38,7 +46,7 @@ for f in $dir/*; do
38 printf "$fclean ($nlines) | $(head -n 1 $f)\n" >> "$lines" 46 printf "$fclean ($nlines) | $(head -n 1 $f)\n" >> "$lines"
39done 47done
40 48
41selected=$(sort -r $lines | $menu $menuopts | awk '{print $1}') 49selected=$(sort -r $lines | $menu | awk '{print $1}')
42if [ -n "$selected" ]; then 50if [ -n "$selected" ]; then
43 xsel -ib < "$dir/$selected" 51 xsel -ib < "$dir/$selected"
44fi 52fi
diff --git a/dmenu-bookmarks b/dmenu-bookmarks
index 2088e11..2566e43 100755
--- a/dmenu-bookmarks
+++ b/dmenu-bookmarks
@@ -2,10 +2,13 @@
2 2
3# A bookmark browser based on dmenu 3# A bookmark browser based on dmenu
4 4
5# Requires: dmenu-filepicker, open-url 5# Usage: dmenu-bookmarks [picker options...]
6
7# Requires: dmenu-filepicker (or similar), open-url
6 8
7dir=$HOME/box/bookmarks 9dir=$HOME/box/bookmarks
10picker="dmenu-filepicker"
8 11
9echo "$(dmenu-filepicker $dir)" | while read line; do 12echo "$($picker "$@" $dir)" | while read line; do
10 cat "$line" 13 cat "$line"
11done | xargs open-url 14done | xargs open-url
diff --git a/dmenu-dwm-sessionmanager b/dmenu-dwm-sessionmanager
index 74ddcf0..f423a09 100755
--- a/dmenu-dwm-sessionmanager
+++ b/dmenu-dwm-sessionmanager
@@ -1,18 +1,26 @@
1#!/bin/sh 1#!/bin/sh
2 2
3# Prompts menu to shutdown/reboot/close dwm 3# Prompts menu to shutdown/reboot/close dwm
4# Usage: dmenu-dwm-sessionmanager [-m menu]
4# Requires: dmenu (or equivalent), dwm (optional) 5# Requires: dmenu (or equivalent), dwm (optional)
5 6
6menu=${MENU:-dmenu} 7menu="dmenu -i"
7menuopts="-i -p" 8prompt="Do you want to quit?"
8menuprompt="Do you want to quit?" 9while getopts "m:" opt; do
9wmname="dwm" 10 case "$opt" in
11 m)
12 menu="$OPTARG"
13 ;;
14 esac
15done
16shift `expr $OPTIND - 1`
10 17
18wmname="dwm"
11shutdown_cmd="sudo shutdown -h now" 19shutdown_cmd="sudo shutdown -h now"
12reboot_cmd="sudo reboot" 20reboot_cmd="sudo reboot"
13closewm_cmd="pkill $wmname" 21closewm_cmd="pkill $wmname"
14 22
15value=$(echo "Shutdown\nReboot\nQuit dwm" | $menu $menuopts "$menuprompt") 23value=$(echo "Shutdown\nReboot\nQuit dwm" | $menu -p "$prompt")
16 24
17if [ "$value" = "Shutdown" ]; then 25if [ "$value" = "Shutdown" ]; then
18 $shutdown_cmd 26 $shutdown_cmd
diff --git a/dmenu-filepicker b/dmenu-filepicker
index 7a3da9f..e2642b2 100755
--- a/dmenu-filepicker
+++ b/dmenu-filepicker
@@ -2,10 +2,18 @@
2 2
3# A dmenu-based file picker (prints selected file to stdout) 3# A dmenu-based file picker (prints selected file to stdout)
4# Requires: dmenu (or similar) 4# Requires: dmenu (or similar)
5# Usage: dmenu-filepicker [path] 5# Usage: dmenu-filepicker [-m menu] [path]
6 6
7menu=dmenu 7menu="dmenu -i -l 15"
8menuopts="-i -l 15" 8
9while getopts "m:" opt; do
10 case "$opt" in
11 m)
12 menu="$OPTARG"
13 ;;
14 esac
15done
16shift `expr $OPTIND - 1`
9 17
10fullpath=$(realpath ${@:-"$(pwd)"}) 18fullpath=$(realpath ${@:-"$(pwd)"})
11 19
@@ -15,7 +23,7 @@ while true; do
15 break 23 break
16 elif [ -d "$fullpath" ] || [ -z "$fullpath" ]; then 24 elif [ -d "$fullpath" ] || [ -z "$fullpath" ]; then
17 if [ -z "$fullpath" ]; then fp="/"; else fp="$fullpath"; fi 25 if [ -z "$fullpath" ]; then fp="/"; else fp="$fullpath"; fi
18 sel=$(ls -a "$fp" | sed 's|.*/||' | $menu $menuopts) 26 sel=$(ls -a "$fp" | sed 's|.*/||' | $menu)
19 if [ "$sel" = ".." ]; then 27 if [ "$sel" = ".." ]; then
20 fullpath=$(echo "$fullpath" | sed "s|/[^/]*$||") 28 fullpath=$(echo "$fullpath" | sed "s|/[^/]*$||")
21 else 29 else
diff --git a/dmenu-mail-aliases b/dmenu-mail-aliases
index 483dffc..582f8e3 100755
--- a/dmenu-mail-aliases
+++ b/dmenu-mail-aliases
@@ -2,10 +2,19 @@
2 2
3# Select mail alias via dmenu 3# Select mail alias via dmenu
4# The email address must be the second word in a line of $aliasfile 4# The email address must be the second word in a line of $aliasfile
5# Usage: dmenu-mail-aliases [-m menu]
5# Requires: dmenu (or similar) 6# Requires: dmenu (or similar)
6 7
7menu=${MENU:-dmenu} 8menu="dmenu -l 20"
8menuopts="-l 20"
9aliasfile="$HOME/.mblaze/aliases" 9aliasfile="$HOME/.mblaze/aliases"
10 10
11while getopts "m:" opt; do
12 case "$opt" in
13 m)
14 menu="$OPTARG"
15 ;;
16 esac
17done
18shift `expr $OPTIND - 1`
19
11$menu $menuopts <"$aliasfile" | awk '{print $NF}' 20$menu $menuopts <"$aliasfile" | awk '{print $NF}'
diff --git a/dmenu-screenshot b/dmenu-screenshot
index 1aab461..fb918fd 100755
--- a/dmenu-screenshot
+++ b/dmenu-screenshot
@@ -1,17 +1,26 @@
1#!/bin/sh 1#!/bin/sh
2 2
3# Screenshot utility 3# Screenshot utility
4# Usage: dmenu-screenshot [-m menu]
4# Requires: dmenu (or similar), imagemagick 5# Requires: dmenu (or similar), imagemagick
5 6
6menu=${MENU:-dmenu} 7menu="dmenu -i"
7menuopts="-i -p" 8prompt="Select type of screenshot:"
8menuprompt="Select type of screenshot:" 9
10while getopts "m:" opt; do
11 case "$opt" in
12 m)
13 menu="$OPTARG"
14 ;;
15 esac
16done
17shift `expr $OPTIND - 1`
9 18
10folder="$HOME/Pictures/screenshots" 19folder="$HOME/Pictures/screenshots"
11filename="screenshot_$(date +%Y-%m-%d-%H%M%S).png" 20filename="screenshot_$(date +%Y-%m-%d-%H%M%S).png"
12filepath="${folder}/${filename}" 21filepath="${folder}/${filename}"
13 22
14t=$(echo "Full\nSelection" | $menu $menuopts "$menuprompt") 23t=$(echo "Full\nSelection" | $menu -p "$prompt")
15#op="" TODO: remove if not needed 24#op="" TODO: remove if not needed
16if [ "$t" = "Full" ]; then 25if [ "$t" = "Full" ]; then
17 op="-window root" 26 op="-window root"
diff --git a/dmenu-unmount b/dmenu-unmount
index 2c59ec4..57f0c41 100755
--- a/dmenu-unmount
+++ b/dmenu-unmount
@@ -1,10 +1,24 @@
1#!/bin/sh 1#!/bin/sh
2 2
3# Prompts selection for mounted devices and unmounts the selected one 3# Prompts selection for mounted devices and unmounts the selected one
4# Usage: dmenu-unmount [-m menu] [-w writer]
5# Example: dmenu-unmount -m slmenu -w echo
4# Requires: udevil, dmenu (or similar), notify-send or similar (optional) 6# Requires: udevil, dmenu (or similar), notify-send or similar (optional)
5 7
6menu=${MENU:-dmenu} 8menu=dmenu
7writeout=herbe # Change this to whatever you want, e.g. echo or notify-send 9writeout=herbe
10
11while getopts "m:w:" opt; do
12 case "$opt" in
13 m)
14 menu="$OPTARG"
15 ;;
16 w)
17 writeout="$OPTARG"
18 ;;
19 esac
20done
21shift `expr $OPTIND - 1`
8 22
9listdev=$(grep "media" /proc/mounts | sed 's/\/media.*\///g' | \ 23listdev=$(grep "media" /proc/mounts | sed 's/\/media.*\///g' | \
10 awk '{print $1" ("$2")"}') 24 awk '{print $1" ("$2")"}')
diff --git a/dmenu-urlselect b/dmenu-urlselect
index e19ec7b..d4e1f59 100755
--- a/dmenu-urlselect
+++ b/dmenu-urlselect
@@ -2,9 +2,18 @@
2 2
3# Finds all URLs in stdin and prompts a dmenu choice, then writes the selected 3# Finds all URLs in stdin and prompts a dmenu choice, then writes the selected
4# url to stdout. 4# url to stdout.
5# Usage: dmenu-urlselect [-m menu]
5# Requires: dmenu (or similar), urlgrep 6# Requires: dmenu (or similar), urlgrep
6 7
7menu=${MENU:-dmenu} 8menu="dmenu -i -l 20"
8menuopts="-l 20"
9 9
10urlgrep | $menu $menuopts 10while getopts "m:" opt; do
11 case "$opt" in
12 m)
13 menu="$OPTARG"
14 ;;
15 esac
16done
17shift `expr $OPTIND - 1`
18
19urlgrep | $menu
diff --git a/xkboptions b/old/xkboptions
index e63456d..e63456d 100755
--- a/xkboptions
+++ b/old/xkboptions
diff --git a/open-file b/open-file
index a7cc551..322ffd9 100755
--- a/open-file
+++ b/open-file
@@ -2,9 +2,10 @@
2 2
3# Inspired by https://github.com/salman-abedin/launch.sh 3# Inspired by https://github.com/salman-abedin/launch.sh
4# Launches files based on their mimetypes 4# Launches files based on their mimetypes
5# Usage: open-file [-m menu] [-s launcher] [-t mimetype] [files...]
5# Requires: dmenu_path or similar (fallback), dmenu-filepicker 6# Requires: dmenu_path or similar (fallback), dmenu-filepicker
6 7
7menu=${MENU:-dmenu} 8menu="dmenu -i -l 15"
8 9
9# Change default apps here 10# Change default apps here
10video="mpv" 11video="mpv"
@@ -78,8 +79,11 @@ openfile() {
78 fi 79 fi
79} 80}
80 81
81while getopts "s:t:" opt; do 82while getopts "m:s:t:" opt; do
82 case "$opt" in 83 case "$opt" in
84 m)
85 menu="$OPTARG"
86 ;;
83 s) 87 s)
84 launcher="$OPTARG" 88 launcher="$OPTARG"
85 ;; 89 ;;
@@ -89,11 +93,6 @@ while getopts "s:t:" opt; do
89 esac 93 esac
90done 94done
91 95
92# If launcher = "", assume running in terminal, so some programs change
93#if [ -z "$launcher" ]; then
94# xedit=${EDITOR:-vi}
95#fi
96
97shift `expr $OPTIND - 1` 96shift `expr $OPTIND - 1`
98toopen=$@ 97toopen=$@
99 98
@@ -103,7 +102,7 @@ if [ -n "$1" ]; then
103 shift 102 shift
104 done 103 done
105else 104else
106 dmenu-filepicker | while read line; do 105 dmenu-filepicker -m "$menu" | while read line; do
107 openfile "$line" & 106 openfile "$line" &
108 done 107 done
109fi 108fi

Generated with cgit - Back to sebastiano.tronto.net