diff options
Diffstat (limited to '')
| -rw-r--r-- | README.md | 11 | ||||
| -rwxr-xr-x | addressgrep | 8 | ||||
| -rwxr-xr-x | backup-config | 29 | ||||
| -rwxr-xr-x | battery-checknow | 21 | ||||
| -rwxr-xr-x | battery-status | 17 | ||||
| -rwxr-xr-x | brightness | 7 | ||||
| -rwxr-xr-x | dmenu-dwm-sessionmanager | 24 | ||||
| -rwxr-xr-x | dmenu-filepicker | 29 | ||||
| -rwxr-xr-x | dmenu-mail-aliases | 11 | ||||
| -rwxr-xr-x | dmenu-screenshot | 23 | ||||
| -rwxr-xr-x | dmenu-unmount | 26 | ||||
| -rwxr-xr-x | dmenu-urlselect | 10 | ||||
| -rwxr-xr-x | dmenu-websearch | 8 | ||||
| -rwxr-xr-x | dunst-toggle | 14 | ||||
| -rwxr-xr-x | mail-checknow | 17 | ||||
| -rwxr-xr-x | mail-compose | 8 | ||||
| -rwxr-xr-x | notify-battery | 4 | ||||
| -rwxr-xr-x | notify-time | 9 | ||||
| -rwxr-xr-x | open-file | 77 | ||||
| -rwxr-xr-x | open-stdin | 11 | ||||
| -rwxr-xr-x | open-url | 31 | ||||
| -rwxr-xr-x | popup-cal12 | 4 | ||||
| -rwxr-xr-x | popup-cal3 | 4 | ||||
| -rwxr-xr-x | popup-terminal | 5 | ||||
| -rwxr-xr-x | sfeed-browser | 62 | ||||
| -rwxr-xr-x | spawn | 5 | ||||
| -rwxr-xr-x | templess | 8 | ||||
| -rwxr-xr-x | togglemute | 14 | ||||
| -rwxr-xr-x | urlgrep | 8 | ||||
| -rwxr-xr-x | volume | 10 | ||||
| -rwxr-xr-x | websearch | 10 | ||||
| -rwxr-xr-x | xedit-filter | 11 | ||||
| -rwxr-xr-x | xkboptions | 6 | ||||
| -rwxr-xr-x | xplumb | 66 | ||||
| -rwxr-xr-x | xwallpaper-random-notify | 13 |
35 files changed, 621 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..9c70c1d --- /dev/null +++ b/README.md | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | These scripts are made to each do one thing well and be combined with each | ||
| 2 | other. Many are linked to a keybinding in my X session. | ||
| 3 | |||
| 4 | Feel free to copy them all or in part, read them, study them, take them apart, | ||
| 5 | copy-paste lines from them and publicly ridicule them as you like. | ||
| 6 | |||
| 7 | Send any suggestion for improvement at | ||
| 8 | `sebastiano [dot] tronto [at] gmail [dot] com.` | ||
| 9 | |||
| 10 | I might add some examples here at some point, for now just look at the | ||
| 11 | source code. | ||
diff --git a/addressgrep b/addressgrep new file mode 100755 index 0000000..36b4899 --- /dev/null +++ b/addressgrep | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Find all email addresses in stdin, print them newline-separated to stdout | ||
| 4 | |||
| 5 | reg='[a-z0-9\._\+\-%]+@[a-z0-9\._\+\-%]+\.[a-zA-Z]+' | ||
| 6 | |||
| 7 | grep -Pio "$reg" | ||
| 8 | |||
diff --git a/backup-config b/backup-config new file mode 100755 index 0000000..c292bf4 --- /dev/null +++ b/backup-config | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Backup local configuration files | ||
| 4 | |||
| 5 | destdir=$HOME/Dropbox/configbackups | ||
| 6 | srcdir=$HOME/.local/src | ||
| 7 | |||
| 8 | # Uncomment to clean old backups | ||
| 9 | #rm -rf $destdir/config $destdir/scripts $destdir/src | ||
| 10 | mkdir -p $destdir/config $destdir/src | ||
| 11 | |||
| 12 | # First copy everything from .config and .bashrc and similar | ||
| 13 | cp -r $XDG_CONFIG_HOME/* $destdir/config/ | ||
| 14 | cp $HOME/.bash* $destdir/ | ||
| 15 | |||
| 16 | # Then copy files from src (only source, config, makefile and READMEs) | ||
| 17 | srcsubdirs=$(ls $srcdir) | ||
| 18 | for i in $srcsubdirs; do | ||
| 19 | si="$srcdir/$i" | ||
| 20 | if [ -d "$si" ]; then | ||
| 21 | mkdir -p $destdir/src/$i | ||
| 22 | for f in "$si/*.c" "$si/*.h" "$si/config.*" "$si/Makefile" "$si/README*"; do | ||
| 23 | for ff in $f; do | ||
| 24 | [ -e $ff ] && cp $f $destdir/src/$i/ | ||
| 25 | done | ||
| 26 | done | ||
| 27 | fi | ||
| 28 | done | ||
| 29 | |||
diff --git a/battery-checknow b/battery-checknow new file mode 100755 index 0000000..0ab4001 --- /dev/null +++ b/battery-checknow | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Check battery state, save result to a file. Pop up notification if changed. | ||
| 4 | # Requires: battery-status, notify-battery | ||
| 5 | |||
| 6 | file="$XDG_DATA_HOME/batterystatus" | ||
| 7 | low=20 | ||
| 8 | crit=15 | ||
| 9 | |||
| 10 | new=$(battery-status) | ||
| 11 | level=$(echo "$new" | sed 's/%.*//') | ||
| 12 | status=$(echo "$new" | awk '{print $2}') | ||
| 13 | |||
| 14 | [ "$status" = "Discharging" ] && [ $level -le $low ] && status="Low" | ||
| 15 | [ "$status" = "Discharging" ] && [ $level -le $crit ] && status="Critical" | ||
| 16 | |||
| 17 | if [ "$status" != "$(cat $file)" ] || [ "$status" = "Critical" ]; then | ||
| 18 | notify-battery | ||
| 19 | fi | ||
| 20 | |||
| 21 | echo "$status" > "$file" | ||
diff --git a/battery-status b/battery-status new file mode 100755 index 0000000..c30b2c5 --- /dev/null +++ b/battery-status | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Send battery information to stdout | ||
| 4 | |||
| 5 | # Get battery status | ||
| 6 | battery="/sys/class/power_supply/BAT0" | ||
| 7 | message="" | ||
| 8 | |||
| 9 | if [ -d $battery ]; then | ||
| 10 | capacity=$(cat $battery/capacity) | ||
| 11 | status=$(cat $battery/status) | ||
| 12 | message="$capacity% $status" | ||
| 13 | else | ||
| 14 | message="No battery" | ||
| 15 | fi | ||
| 16 | |||
| 17 | echo "$message" | ||
diff --git a/brightness b/brightness new file mode 100755 index 0000000..46fd0a8 --- /dev/null +++ b/brightness | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Increase / decrease brightness, and pops up a notification | ||
| 4 | # Requires: xbacklight, notify-send | ||
| 5 | # Usage: brightness {inc|dec} n | ||
| 6 | |||
| 7 | xbacklight -$1 $2 && notify-send "Brightness: $(xbacklight | sed 's/\..*$//')%" | ||
diff --git a/dmenu-dwm-sessionmanager b/dmenu-dwm-sessionmanager new file mode 100755 index 0000000..74ddcf0 --- /dev/null +++ b/dmenu-dwm-sessionmanager | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Prompts menu to shutdown/reboot/close dwm | ||
| 4 | # Requires: dmenu (or equivalent), dwm (optional) | ||
| 5 | |||
| 6 | menu=${MENU:-dmenu} | ||
| 7 | menuopts="-i -p" | ||
| 8 | menuprompt="Do you want to quit?" | ||
| 9 | wmname="dwm" | ||
| 10 | |||
| 11 | shutdown_cmd="sudo shutdown -h now" | ||
| 12 | reboot_cmd="sudo reboot" | ||
| 13 | closewm_cmd="pkill $wmname" | ||
| 14 | |||
| 15 | value=$(echo "Shutdown\nReboot\nQuit dwm" | $menu $menuopts "$menuprompt") | ||
| 16 | |||
| 17 | if [ "$value" = "Shutdown" ]; then | ||
| 18 | $shutdown_cmd | ||
| 19 | elif [ "$value" = "Reboot" ]; then | ||
| 20 | $reboot_cmd | ||
| 21 | elif [ "$value" = "Quit $wmname" ]; then | ||
| 22 | $closewm_cmd | ||
| 23 | fi | ||
| 24 | |||
diff --git a/dmenu-filepicker b/dmenu-filepicker new file mode 100755 index 0000000..a14bd53 --- /dev/null +++ b/dmenu-filepicker | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # A dmenu-based file picker (prints selected file to stdout) | ||
| 4 | # Requires: dmenu (or similar) | ||
| 5 | # Usage: dmenu-filepicker [path] | ||
| 6 | |||
| 7 | menu=${MENU:-dmenu} | ||
| 8 | menuopts="-i -l 15" | ||
| 9 | |||
| 10 | basedir="$(pwd)" | ||
| 11 | |||
| 12 | next="${@:-$(pwd)}" | ||
| 13 | |||
| 14 | while true; do | ||
| 15 | if [ -z "$next" ]; then | ||
| 16 | break | ||
| 17 | elif [ "$next" = "." ]; then | ||
| 18 | pwd | ||
| 19 | break | ||
| 20 | elif [ -d "$next" ]; then | ||
| 21 | cd "$next" | ||
| 22 | next=$(ls -a | $menu $menuopts) | ||
| 23 | else | ||
| 24 | echo "$(pwd)/$next" | ||
| 25 | break | ||
| 26 | fi | ||
| 27 | done | ||
| 28 | |||
| 29 | cd "$basedir" | ||
diff --git a/dmenu-mail-aliases b/dmenu-mail-aliases new file mode 100755 index 0000000..f75af14 --- /dev/null +++ b/dmenu-mail-aliases | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Select mail alias via dmenu | ||
| 4 | # The email address must be the second word in a line of $aliasfile | ||
| 5 | # Requires: dmenu (or similar) | ||
| 6 | |||
| 7 | menu=${MENU:-dmenu} | ||
| 8 | menuopts="-l 20" | ||
| 9 | aliasfile="$XDG_CONFIG_HOME/mblaze/aliases" | ||
| 10 | |||
| 11 | xargs printf "%-40s %s\n" <"$aliasfile" | $menu $menuopts | awk '{print $2}' | ||
diff --git a/dmenu-screenshot b/dmenu-screenshot new file mode 100755 index 0000000..1aab461 --- /dev/null +++ b/dmenu-screenshot | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Screenshot utility | ||
| 4 | # Requires: dmenu (or similar), imagemagick | ||
| 5 | |||
| 6 | menu=${MENU:-dmenu} | ||
| 7 | menuopts="-i -p" | ||
| 8 | menuprompt="Select type of screenshot:" | ||
| 9 | |||
| 10 | folder="$HOME/Pictures/screenshots" | ||
| 11 | filename="screenshot_$(date +%Y-%m-%d-%H%M%S).png" | ||
| 12 | filepath="${folder}/${filename}" | ||
| 13 | |||
| 14 | t=$(echo "Full\nSelection" | $menu $menuopts "$menuprompt") | ||
| 15 | #op="" TODO: remove if not needed | ||
| 16 | if [ "$t" = "Full" ]; then | ||
| 17 | op="-window root" | ||
| 18 | else | ||
| 19 | pkill xbanish # otherwise I can't use mouse to select area | ||
| 20 | fi | ||
| 21 | |||
| 22 | [ -n "$t" ] && sleep 0.1 && import $op $filepath | ||
| 23 | spawn xbanish # This can be removed if you don't use xbanish | ||
diff --git a/dmenu-unmount b/dmenu-unmount new file mode 100755 index 0000000..c0b387a --- /dev/null +++ b/dmenu-unmount | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Prompts selection for mounted devices and unmounts the selected one | ||
| 4 | # Requires: udevil, dmenu (or similar), notify-send (optional) | ||
| 5 | |||
| 6 | menu=${MENU:-dmenu} | ||
| 7 | writeout="notify-send" # Change this to whatever you want, e.g. echo | ||
| 8 | |||
| 9 | listdev=$(grep "media" /proc/mounts | sed 's/\/media.*\///g' | \ | ||
| 10 | awk '{print $1" ("$2")"}') | ||
| 11 | |||
| 12 | if [ -z "$listdev" ]; then | ||
| 13 | $writeout "Nothing to unmount" | ||
| 14 | else | ||
| 15 | seldev=$(echo "$listdev" | $menu | awk '{print $1}') | ||
| 16 | if [ -n "$seldev" ]; then | ||
| 17 | udevil unmount "$seldev" | ||
| 18 | failed=$(udevil info "$seldev" | grep mounted | awk '{print $3}') | ||
| 19 | if [ $failed -eq 1 ]; then | ||
| 20 | $writeout "Unmount FAILED" "Device is still mounted!" | ||
| 21 | else | ||
| 22 | $writeout "Device unmounted" | ||
| 23 | fi | ||
| 24 | fi | ||
| 25 | fi | ||
| 26 | # notify-send "$(udisksctl unmount -b $seldev)" | ||
diff --git a/dmenu-urlselect b/dmenu-urlselect new file mode 100755 index 0000000..e19ec7b --- /dev/null +++ b/dmenu-urlselect | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Finds all URLs in stdin and prompts a dmenu choice, then writes the selected | ||
| 4 | # url to stdout. | ||
| 5 | # Requires: dmenu (or similar), urlgrep | ||
| 6 | |||
| 7 | menu=${MENU:-dmenu} | ||
| 8 | menuopts="-l 20" | ||
| 9 | |||
| 10 | urlgrep | $menu $menuopts | ||
diff --git a/dmenu-websearch b/dmenu-websearch new file mode 100755 index 0000000..04df2fc --- /dev/null +++ b/dmenu-websearch | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Popup $TERMINAL prompting for websearch | ||
| 4 | # Requires: dmenu (or similar), websearch | ||
| 5 | |||
| 6 | menu=${MENU:-dmenu} | ||
| 7 | |||
| 8 | websearch $(echo "" | $menu -p "websearch:") | ||
diff --git a/dunst-toggle b/dunst-toggle new file mode 100755 index 0000000..2de2343 --- /dev/null +++ b/dunst-toggle | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Toggle "do not disturbe" mode with dunst | ||
| 4 | # Requires: dunst, notify-send | ||
| 5 | |||
| 6 | if [ "$(dunstctl is-paused)" = "false" ]; then | ||
| 7 | notify-send -t 3000 "Notifications: OFF" "Notifications will be hidden" | ||
| 8 | sleep 3 | ||
| 9 | dunstctl set-paused true | ||
| 10 | else | ||
| 11 | dunstctl set-paused false | ||
| 12 | notify-send -t 3000 "Notifications: ON" "Notifications reactivated" | ||
| 13 | fi | ||
| 14 | |||
diff --git a/mail-checknow b/mail-checknow new file mode 100755 index 0000000..3363173 --- /dev/null +++ b/mail-checknow | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Check for new email, save result to file. | ||
| 4 | # Requires: mpop, notify-send | ||
| 5 | |||
| 6 | file="$XDG_DATA_HOME/newmail" | ||
| 7 | notify="notify-send" | ||
| 8 | |||
| 9 | l=$(cat "$file") | ||
| 10 | n=$(mpop -s | awk '/new*./{print $2}') | ||
| 11 | |||
| 12 | if [ -n "$n" ]; then | ||
| 13 | echo "$n" > "$file" | ||
| 14 | if [ "$n" != "no" ] && [ "$l" != "$n" ]; then | ||
| 15 | $notify "New email ($n)" | ||
| 16 | fi | ||
| 17 | fi | ||
diff --git a/mail-compose b/mail-compose new file mode 100755 index 0000000..1c293f0 --- /dev/null +++ b/mail-compose | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Open a mail composer. | ||
| 4 | # Requires: mblaze | ||
| 5 | |||
| 6 | terminal=${TERMINAL:-xterm} | ||
| 7 | |||
| 8 | $terminal -e mcom $@ | ||
diff --git a/notify-battery b/notify-battery new file mode 100755 index 0000000..0d26ef4 --- /dev/null +++ b/notify-battery | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Popup battery notification, based on the script battery-status | ||
| 4 | notify-send "Battery" "$(battery-status)" | ||
diff --git a/notify-time b/notify-time new file mode 100755 index 0000000..1173bf0 --- /dev/null +++ b/notify-time | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Little notification to show time and date | ||
| 4 | # Requirements: notify-send | ||
| 5 | |||
| 6 | t=$(date +"%H:%M:%S") | ||
| 7 | d=$(date +"%d\ %B\ %Y,\ %A") | ||
| 8 | |||
| 9 | notify-send "$t" "$d" | ||
diff --git a/open-file b/open-file new file mode 100755 index 0000000..34df2d7 --- /dev/null +++ b/open-file | |||
| @@ -0,0 +1,77 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Inspired by https://github.com/salman-abedin/launch.sh | ||
| 4 | # Launches files based on their mimetypes | ||
| 5 | # Use option -s devour to swallow or -s " " to open normally from terminal | ||
| 6 | # Use -t to specify mimetype | ||
| 7 | # Requires: dmenu_path or similar (fallback) | ||
| 8 | |||
| 9 | menu=${MENU:-dmenu} | ||
| 10 | |||
| 11 | while getopts "s:t:" opt; do | ||
| 12 | case "$opt" in | ||
| 13 | s) | ||
| 14 | launcher="$OPTARG" | ||
| 15 | ;; | ||
| 16 | t) | ||
| 17 | mimetype="$OPTARG" | ||
| 18 | ;; | ||
| 19 | esac | ||
| 20 | done | ||
| 21 | |||
| 22 | shift `expr $OPTIND - 1` | ||
| 23 | |||
| 24 | [ -z "$launcher" ] && launcher="spawn" | ||
| 25 | [ -z "$mimetype" ] && mimetype="$(file --mime-type "$1" -bL)" | ||
| 26 | |||
| 27 | [ -d "$1" ] && $launcher $XFILEMANAGER "$1" && exit 0 | ||
| 28 | [ ! -f "$1" ] && echo "$1: bad argument" && exit 1 | ||
| 29 | |||
| 30 | case "$mimetype" in | ||
| 31 | video/*) | ||
| 32 | $launcher $VIDEOPLAYER "$1" | ||
| 33 | ;; | ||
| 34 | audio/*) | ||
| 35 | $launcher $MUSICPLAYER "$1" | ||
| 36 | ;; | ||
| 37 | application/pdf | application/postscript | image/vnd.djvu) | ||
| 38 | $launcher $VIEWER "$1" | ||
| 39 | ;; | ||
| 40 | image/*) | ||
| 41 | $launcher $IMAGEVIEWER "$1" | ||
| 42 | ;; | ||
| 43 | application/msword | \ | ||
| 44 | application/vnd.oasis.opendocument.text | text/rtf | \ | ||
| 45 | application/vnd.openxmlformats-officedocument.wordprocessingml.*) | ||
| 46 | $launcher $TEXTDOCUMENT "$1" | ||
| 47 | ;; | ||
| 48 | application/ms-excel | application/vnd.oasis.opendocument.spreadsheet | \ | ||
| 49 | text/rtf | application/vnd.openxmlformats-officedocument.spreadsheetml.*) | ||
| 50 | $launcher $SPREADSHEET "$1" | ||
| 51 | ;; | ||
| 52 | text/html | text/enriched) | ||
| 53 | $launcher $BROWSER --new-window "$1" | ||
| 54 | ;; | ||
| 55 | text/*) | ||
| 56 | $launcher $XEDITOR "$1" | ||
| 57 | ;; | ||
| 58 | application/zip) | ||
| 59 | unzip "$1" | ||
| 60 | ;; | ||
| 61 | application/x-rar-compressed) | ||
| 62 | unrar "$1" | ||
| 63 | ;; | ||
| 64 | application/x-archive | application/x-tar | \ | ||
| 65 | application/x-bzip2 | application/gzip | application/x-lzip | \ | ||
| 66 | application/x-lzma | application/x-xz | application/x-gtar) | ||
| 67 | tar -tavf "$1" | ||
| 68 | ;; | ||
| 69 | *) | ||
| 70 | prog=$(dmenu_path | $menu -p "How to open $1 ?") | ||
| 71 | if [ -n "$prog" ]; then | ||
| 72 | $launcher $prog "$1" | ||
| 73 | else | ||
| 74 | exit 1 | ||
| 75 | fi | ||
| 76 | ;; | ||
| 77 | esac | ||
diff --git a/open-stdin b/open-stdin new file mode 100755 index 0000000..1cc54a5 --- /dev/null +++ b/open-stdin | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Saves standard input in a download folder and opens it with myopen | ||
| 4 | # Usage: open-stdin | ||
| 5 | # Requires: open-file | ||
| 6 | |||
| 7 | folder=$HOME/Downloads/open-stdin | ||
| 8 | |||
| 9 | tempfile=$(mktemp -p "$folder") | ||
| 10 | |||
| 11 | cat > "$tempfile" && open-file -t "$1" "$tempfile" | ||
diff --git a/open-url b/open-url new file mode 100755 index 0000000..700589e --- /dev/null +++ b/open-url | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Open link in preferred application | ||
| 4 | # Requires: mail-compose, xsel (optional) | ||
| 5 | |||
| 6 | browser=${BROWSER:-firefox} | ||
| 7 | imageviewer=${IMAGEVIEWER:-imv} | ||
| 8 | |||
| 9 | [ -z "$1" ] && exit 0 | ||
| 10 | |||
| 11 | # Optional: copy url to clipboard | ||
| 12 | echo "$@" | xsel -ib | ||
| 13 | |||
| 14 | case "$@" in | ||
| 15 | mailto:*) | ||
| 16 | mail-compose $@ | ||
| 17 | ;; | ||
| 18 | *.jpg | *.jpeg | *.png) | ||
| 19 | spawn $imageviewer "$@" | ||
| 20 | ;; | ||
| 21 | *.gif) | ||
| 22 | spawn $imageviewer "$@" | ||
| 23 | ;; | ||
| 24 | # https://www.youtube.com/watch\?v=*) | ||
| 25 | # spawn $VIDEOPLAYER "$1" | ||
| 26 | # ;; | ||
| 27 | *) | ||
| 28 | spawn $browser "$@" | ||
| 29 | ;; | ||
| 30 | esac | ||
| 31 | |||
diff --git a/popup-cal12 b/popup-cal12 new file mode 100755 index 0000000..bc8897e --- /dev/null +++ b/popup-cal12 | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Popup $TERMINAL displaying cal -3 | ||
| 4 | $TERMINAL -T "stfloat" -g 66x33+620+250 -e sh -c 'cal $(date +%Y); read x' | ||
diff --git a/popup-cal3 b/popup-cal3 new file mode 100755 index 0000000..0ed0830 --- /dev/null +++ b/popup-cal3 | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Popup $TERMINAL displaying cal -3 | ||
| 4 | $TERMINAL -T "stfloat" -g 64x9+620+450 -e sh -c 'cal -3; read x' | ||
diff --git a/popup-terminal b/popup-terminal new file mode 100755 index 0000000..f6a9caa --- /dev/null +++ b/popup-terminal | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # TODO this replaces $FLOATINGTERMINAL | ||
| 4 | |||
| 5 | $TERMINAL -T 'stfloat' -g 85x25+550+300 $@ | ||
diff --git a/sfeed-browser b/sfeed-browser new file mode 100755 index 0000000..be56d74 --- /dev/null +++ b/sfeed-browser | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # This script is based on sfeed (https://codemadness.org/sfeed.html), but | ||
| 4 | # it allows you organize your feeds in directories and subdirectories. | ||
| 5 | # In your $sfd directory (see below) you should have two folders: | ||
| 6 | # urls: it can contain more subfolders and files. Each file should contain | ||
| 7 | # only one line with the url to the feed. The name of the file is the | ||
| 8 | # name of the feed (it can contains spaces and such). | ||
| 9 | # files: this one can be empty, it will be filled with the feed files | ||
| 10 | # An older version of this script also marked viewed items and removed | ||
| 11 | # them before displaying the choice of feeds. Contact me if you are interested | ||
| 12 | # in using it. | ||
| 13 | |||
| 14 | # Requires: sfeed, dmenu-file-picker (or similar), open-url (or similar) | ||
| 15 | |||
| 16 | filepicker="dmenu-filepicker" # Try "nnn -p -" | ||
| 17 | menu=${MENU:-dmenu} | ||
| 18 | menuopts="-l 35 -i" | ||
| 19 | urlopener=open-url | ||
| 20 | sfd="$XDG_CONFIG_HOME/sfeed" | ||
| 21 | showlast=10 | ||
| 22 | |||
| 23 | # Might add more stuff later | ||
| 24 | fixurl() { | ||
| 25 | sed 's/old\.reddit\.com/reddit\.com/' | ||
| 26 | } | ||
| 27 | |||
| 28 | dirtofeedpaths() { | ||
| 29 | while read line; do | ||
| 30 | find "$line" | while read fname; do | ||
| 31 | [ -f "$fname" ] && echo "$fname" | ||
| 32 | done | ||
| 33 | done | ||
| 34 | } | ||
| 35 | |||
| 36 | pathstosfeedrc() { | ||
| 37 | printf "sfeedpath=\"$sfd/files\"\n\nfeeds() {\n" | ||
| 38 | while read line; do | ||
| 39 | feedname=$(echo "$line" | sed 's/.*\///') | ||
| 40 | read feedurl <"$line" | ||
| 41 | printf "\tfeed \"$feedname\" \"$feedurl\"\n" | ||
| 42 | done | ||
| 43 | printf "}\n" | ||
| 44 | } | ||
| 45 | |||
| 46 | feedmenu() { | ||
| 47 | while read line; do | ||
| 48 | feedname=$(echo "$line" | sed 's/.*\///') | ||
| 49 | sfeed_plain "$sfd/files/$feedname" | head -$showlast | ||
| 50 | done | $menu $menuopts | ||
| 51 | } | ||
| 52 | |||
| 53 | openfeeds() { | ||
| 54 | while read line; do | ||
| 55 | url=$(echo "$line" | sed 's/.*[\t ]//' | fixurl) | ||
| 56 | [ -n "$url" ] && echo $url | ||
| 57 | done | xargs $urlopener | ||
| 58 | } | ||
| 59 | |||
| 60 | $filepicker "$sfd/urls" | dirtofeedpaths > "$sfd/last" | ||
| 61 | pathstosfeedrc < "$sfd/last" > "$sfd/sfeedrc" | ||
| 62 | sfeed_update "$sfd/sfeedrc" && feedmenu < "$sfd/last" | openfeeds | ||
| @@ -0,0 +1,5 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Simple command to spawn and detach an application | ||
| 4 | |||
| 5 | "$@" >/dev/null 2>&1 & | ||
diff --git a/templess b/templess new file mode 100755 index 0000000..ec3b999 --- /dev/null +++ b/templess | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Write standard in to a temporary file and sends it to a pager. | ||
| 4 | |||
| 5 | pager=${PAGER:-less} | ||
| 6 | tempfile=$(mktemp) | ||
| 7 | |||
| 8 | cat > "$tempfile" && $pager "$tempfile" | ||
diff --git a/togglemute b/togglemute new file mode 100755 index 0000000..d952676 --- /dev/null +++ b/togglemute | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Toggle mute state and notify | ||
| 4 | # Requires: pulsemixer, notify-send | ||
| 5 | |||
| 6 | ismute=$(pulsemixer --toggle-mute --get-mute) | ||
| 7 | |||
| 8 | if [ "$ismute" = "1" ]; then | ||
| 9 | m="muted" | ||
| 10 | else | ||
| 11 | m="unmuted" | ||
| 12 | fi | ||
| 13 | |||
| 14 | notify-send "Audio $m" | ||
| @@ -0,0 +1,8 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Find all url in stdin, print them newline-separated to stdout | ||
| 4 | |||
| 5 | reg='(((http|https|ftp)|mailto)[.:][^ >"\t]*|www\.[-a-z0-9.]+)[^ .,;\t>">\):]' | ||
| 6 | |||
| 7 | grep -Po "$reg" | ||
| 8 | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Change volume and notify | ||
| 4 | # Usage: volume {+n|-n} | ||
| 5 | # Requires: pulsemixer, notify-send | ||
| 6 | |||
| 7 | #TODO: use this to replace myvolumeup/myvolumedown | ||
| 8 | |||
| 9 | newvol=$(pulsemixer --change-volume "$1" --get-volume | awk '{print $1}') | ||
| 10 | notify-send "Volume" "$newvol%" | ||
diff --git a/websearch b/websearch new file mode 100755 index 0000000..12bf2f5 --- /dev/null +++ b/websearch | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Perform a web search | ||
| 4 | |||
| 5 | browser=${BROWSER:-firefox} | ||
| 6 | searchengine="https://duckduckgo.com/?q=" | ||
| 7 | # For google: https://www.google.com/search?q= | ||
| 8 | |||
| 9 | arg=$(echo "$@" | sed 's/ /\+/g') | ||
| 10 | [ -n "$arg" ] && spawn "$browser" "${searchengine}$arg" | ||
diff --git a/xedit-filter b/xedit-filter new file mode 100755 index 0000000..b89a7a7 --- /dev/null +++ b/xedit-filter | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | #/!bin/sh | ||
| 2 | |||
| 3 | asfd | ||
| 4 | # Open stdin in a text editor and sends modified selection to stdout | ||
| 5 | |||
| 6 | xeditor=${XEDITOR:-gedit} | ||
| 7 | |||
| 8 | f=$(mktemp) | ||
| 9 | cat > "$f" | ||
| 10 | $xeditor "$f" && cat "$f" | ||
| 11 | |||
diff --git a/xkboptions b/xkboptions new file mode 100755 index 0000000..e63456d --- /dev/null +++ b/xkboptions | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Loads my xkboptions | ||
| 4 | |||
| 5 | setxkbmap -option compose:ralt | ||
| 6 | setxkbmap -option caps:swapescape | ||
| @@ -0,0 +1,66 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # My interpretation of a plumber (plan9 style). | ||
| 4 | # It scans the selected text (xsel) and decides what to do with it among | ||
| 5 | # some possibilities (open file, open url, man page...). If none is matched, | ||
| 6 | # a choice is prompted. | ||
| 7 | |||
| 8 | # Requires: dmenu (or similar), mail-compose, open-file, websearch, xsel | ||
| 9 | |||
| 10 | # TODO: | ||
| 11 | # send mail to email address; | ||
| 12 | # calendar if it is a date | ||
| 13 | # choice: pipe to another program | ||
| 14 | |||
| 15 | browser=${BROWSER:-firefox} | ||
| 16 | terminal=${TERMINAL:-xterm} | ||
| 17 | xeditor=${XEDITOR:-gedit} | ||
| 18 | menu=${MENU:-dmenu} | ||
| 19 | menuopts="-l 10" | ||
| 20 | |||
| 21 | text=$(xsel | sed 's/\n/ /g') | ||
| 22 | if [ $(echo "$text" | wc -c) -ge 11 ]; then | ||
| 23 | shorttext=$(echo "$text" | cut -b 1-10)... | ||
| 24 | else | ||
| 25 | shorttext="$text" | ||
| 26 | fi | ||
| 27 | |||
| 28 | choice() { | ||
| 29 | chosen=$(printf "websearch\nedit" | \ | ||
| 30 | $menu $menuopts -p "What to do with \"$shorttext\"?") | ||
| 31 | |||
| 32 | if [ "$chosen" = "websearch" ]; then | ||
| 33 | websearch $text | ||
| 34 | elif [ "$chosen" = "edit" ]; then | ||
| 35 | f=$(mktemp) | ||
| 36 | xsel > "$f" | ||
| 37 | $xeditor "$f" | ||
| 38 | fi | ||
| 39 | } | ||
| 40 | |||
| 41 | trymail() { | ||
| 42 | addr=$(echo "$1" | addressgrep) | ||
| 43 | ( [ -n "$addr" ] && mail-compose $addr ) || return 1 | ||
| 44 | } | ||
| 45 | |||
| 46 | tryman() { | ||
| 47 | number=$(echo "$1" | sed 's/[^1-8]//g') | ||
| 48 | name=$(echo "$1" | sed 's/([1-8])//g' | sed 's/ //g') | ||
| 49 | if [ $(man -w "$number" "$name" | wc -l) = 1 ]; then | ||
| 50 | $terminal -e man "$number" "$name" | ||
| 51 | return 0 | ||
| 52 | else | ||
| 53 | return 1 | ||
| 54 | fi | ||
| 55 | } | ||
| 56 | |||
| 57 | tryurl() { | ||
| 58 | url=$(echo "$1" | urlgrep) | ||
| 59 | ( [ -n "$url" ] && $browser $url ) || return 1 | ||
| 60 | } | ||
| 61 | |||
| 62 | open-file "$text" || \ | ||
| 63 | tryurl "$text" || \ | ||
| 64 | trymail "$text" || \ | ||
| 65 | tryman "$text" || \ | ||
| 66 | choice | ||
diff --git a/xwallpaper-random-notify b/xwallpaper-random-notify new file mode 100755 index 0000000..d0d1fbe --- /dev/null +++ b/xwallpaper-random-notify | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Set a random background from the wallpapers folder and notify about it | ||
| 4 | # Requires: xwallpaper (or feh), notify-send (optional) | ||
| 5 | |||
| 6 | folder=~/Pictures/wallpapers | ||
| 7 | pic=$(ls $folder | sort -R | head -1) | ||
| 8 | |||
| 9 | # Alternative: use feh | ||
| 10 | #feh --bg-fill --no-fehbg $folder/$pic | ||
| 11 | xwallpaper --zoom $folder/$pic | ||
| 12 | |||
| 13 | notify-send "Background of the day" $pic | ||
