aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano.tronto@gmail.com>2021-06-10 18:58:52 +0200
committerSebastiano Tronto <sebastiano.tronto@gmail.com>2021-06-10 18:58:52 +0200
commitb98e05ba63f2e108df634b4d9f9e5530769c6b80 (patch)
treea1d3a7f20e826d264f2a6b2141b7b1bfa7debb6f
parented61c5f085cebb86d3d3a34ce01ec22069c1fc70 (diff)
downloadscripts-b98e05ba63f2e108df634b4d9f9e5530769c6b80.tar.gz
scripts-b98e05ba63f2e108df634b4d9f9e5530769c6b80.zip
Added scripts and readme
Diffstat (limited to '')
-rw-r--r--README.md11
-rwxr-xr-xaddressgrep8
-rwxr-xr-xbackup-config29
-rwxr-xr-xbattery-checknow21
-rwxr-xr-xbattery-status17
-rwxr-xr-xbrightness7
-rwxr-xr-xdmenu-dwm-sessionmanager24
-rwxr-xr-xdmenu-filepicker29
-rwxr-xr-xdmenu-mail-aliases11
-rwxr-xr-xdmenu-screenshot23
-rwxr-xr-xdmenu-unmount26
-rwxr-xr-xdmenu-urlselect10
-rwxr-xr-xdmenu-websearch8
-rwxr-xr-xdunst-toggle14
-rwxr-xr-xmail-checknow17
-rwxr-xr-xmail-compose8
-rwxr-xr-xnotify-battery4
-rwxr-xr-xnotify-time9
-rwxr-xr-xopen-file77
-rwxr-xr-xopen-stdin11
-rwxr-xr-xopen-url31
-rwxr-xr-xpopup-cal124
-rwxr-xr-xpopup-cal34
-rwxr-xr-xpopup-terminal5
-rwxr-xr-xsfeed-browser62
-rwxr-xr-xspawn5
-rwxr-xr-xtempless8
-rwxr-xr-xtogglemute14
-rwxr-xr-xurlgrep8
-rwxr-xr-xvolume10
-rwxr-xr-xwebsearch10
-rwxr-xr-xxedit-filter11
-rwxr-xr-xxkboptions6
-rwxr-xr-xxplumb66
-rwxr-xr-xxwallpaper-random-notify13
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 @@
1These scripts are made to each do one thing well and be combined with each
2other. Many are linked to a keybinding in my X session.
3
4Feel free to copy them all or in part, read them, study them, take them apart,
5copy-paste lines from them and publicly ridicule them as you like.
6
7Send any suggestion for improvement at
8`sebastiano [dot] tronto [at] gmail [dot] com.`
9
10I might add some examples here at some point, for now just look at the
11source 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
5reg='[a-z0-9\._\+\-%]+@[a-z0-9\._\+\-%]+\.[a-zA-Z]+'
6
7grep -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
5destdir=$HOME/Dropbox/configbackups
6srcdir=$HOME/.local/src
7
8# Uncomment to clean old backups
9#rm -rf $destdir/config $destdir/scripts $destdir/src
10mkdir -p $destdir/config $destdir/src
11
12# First copy everything from .config and .bashrc and similar
13cp -r $XDG_CONFIG_HOME/* $destdir/config/
14cp $HOME/.bash* $destdir/
15
16# Then copy files from src (only source, config, makefile and READMEs)
17srcsubdirs=$(ls $srcdir)
18for 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
28done
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
6file="$XDG_DATA_HOME/batterystatus"
7low=20
8crit=15
9
10new=$(battery-status)
11level=$(echo "$new" | sed 's/%.*//')
12status=$(echo "$new" | awk '{print $2}')
13
14[ "$status" = "Discharging" ] && [ $level -le $low ] && status="Low"
15[ "$status" = "Discharging" ] && [ $level -le $crit ] && status="Critical"
16
17if [ "$status" != "$(cat $file)" ] || [ "$status" = "Critical" ]; then
18 notify-battery
19fi
20
21echo "$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
6battery="/sys/class/power_supply/BAT0"
7message=""
8
9if [ -d $battery ]; then
10 capacity=$(cat $battery/capacity)
11 status=$(cat $battery/status)
12 message="$capacity% $status"
13else
14 message="No battery"
15fi
16
17echo "$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
7xbacklight -$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
6menu=${MENU:-dmenu}
7menuopts="-i -p"
8menuprompt="Do you want to quit?"
9wmname="dwm"
10
11shutdown_cmd="sudo shutdown -h now"
12reboot_cmd="sudo reboot"
13closewm_cmd="pkill $wmname"
14
15value=$(echo "Shutdown\nReboot\nQuit dwm" | $menu $menuopts "$menuprompt")
16
17if [ "$value" = "Shutdown" ]; then
18 $shutdown_cmd
19elif [ "$value" = "Reboot" ]; then
20 $reboot_cmd
21elif [ "$value" = "Quit $wmname" ]; then
22 $closewm_cmd
23fi
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
7menu=${MENU:-dmenu}
8menuopts="-i -l 15"
9
10basedir="$(pwd)"
11
12next="${@:-$(pwd)}"
13
14while 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
27done
28
29cd "$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
7menu=${MENU:-dmenu}
8menuopts="-l 20"
9aliasfile="$XDG_CONFIG_HOME/mblaze/aliases"
10
11xargs 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
6menu=${MENU:-dmenu}
7menuopts="-i -p"
8menuprompt="Select type of screenshot:"
9
10folder="$HOME/Pictures/screenshots"
11filename="screenshot_$(date +%Y-%m-%d-%H%M%S).png"
12filepath="${folder}/${filename}"
13
14t=$(echo "Full\nSelection" | $menu $menuopts "$menuprompt")
15#op="" TODO: remove if not needed
16if [ "$t" = "Full" ]; then
17 op="-window root"
18else
19 pkill xbanish # otherwise I can't use mouse to select area
20fi
21
22[ -n "$t" ] && sleep 0.1 && import $op $filepath
23spawn 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
6menu=${MENU:-dmenu}
7writeout="notify-send" # Change this to whatever you want, e.g. echo
8
9listdev=$(grep "media" /proc/mounts | sed 's/\/media.*\///g' | \
10 awk '{print $1" ("$2")"}')
11
12if [ -z "$listdev" ]; then
13 $writeout "Nothing to unmount"
14else
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
25fi
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
7menu=${MENU:-dmenu}
8menuopts="-l 20"
9
10urlgrep | $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
6menu=${MENU:-dmenu}
7
8websearch $(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
6if [ "$(dunstctl is-paused)" = "false" ]; then
7 notify-send -t 3000 "Notifications: OFF" "Notifications will be hidden"
8 sleep 3
9 dunstctl set-paused true
10else
11 dunstctl set-paused false
12 notify-send -t 3000 "Notifications: ON" "Notifications reactivated"
13fi
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
6file="$XDG_DATA_HOME/newmail"
7notify="notify-send"
8
9l=$(cat "$file")
10n=$(mpop -s | awk '/new*./{print $2}')
11
12if [ -n "$n" ]; then
13 echo "$n" > "$file"
14 if [ "$n" != "no" ] && [ "$l" != "$n" ]; then
15 $notify "New email ($n)"
16 fi
17fi
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
6terminal=${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
4notify-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
6t=$(date +"%H:%M:%S")
7d=$(date +"%d\ %B\ %Y,\ %A")
8
9notify-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
9menu=${MENU:-dmenu}
10
11while getopts "s:t:" opt; do
12 case "$opt" in
13 s)
14 launcher="$OPTARG"
15 ;;
16 t)
17 mimetype="$OPTARG"
18 ;;
19 esac
20done
21
22shift `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
30case "$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 ;;
77esac
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
7folder=$HOME/Downloads/open-stdin
8
9tempfile=$(mktemp -p "$folder")
10
11cat > "$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
6browser=${BROWSER:-firefox}
7imageviewer=${IMAGEVIEWER:-imv}
8
9[ -z "$1" ] && exit 0
10
11# Optional: copy url to clipboard
12echo "$@" | xsel -ib
13
14case "$@" 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 ;;
30esac
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
16filepicker="dmenu-filepicker" # Try "nnn -p -"
17menu=${MENU:-dmenu}
18menuopts="-l 35 -i"
19urlopener=open-url
20sfd="$XDG_CONFIG_HOME/sfeed"
21showlast=10
22
23# Might add more stuff later
24fixurl() {
25 sed 's/old\.reddit\.com/reddit\.com/'
26}
27
28dirtofeedpaths() {
29 while read line; do
30 find "$line" | while read fname; do
31 [ -f "$fname" ] && echo "$fname"
32 done
33 done
34}
35
36pathstosfeedrc() {
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
46feedmenu() {
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
53openfeeds() {
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"
61pathstosfeedrc < "$sfd/last" > "$sfd/sfeedrc"
62sfeed_update "$sfd/sfeedrc" && feedmenu < "$sfd/last" | openfeeds
diff --git a/spawn b/spawn
new file mode 100755
index 0000000..fdb2614
--- /dev/null
+++ b/spawn
@@ -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
5pager=${PAGER:-less}
6tempfile=$(mktemp)
7
8cat > "$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
6ismute=$(pulsemixer --toggle-mute --get-mute)
7
8if [ "$ismute" = "1" ]; then
9 m="muted"
10else
11 m="unmuted"
12fi
13
14notify-send "Audio $m"
diff --git a/urlgrep b/urlgrep
new file mode 100755
index 0000000..ba81765
--- /dev/null
+++ b/urlgrep
@@ -0,0 +1,8 @@
1#!/bin/sh
2
3# Find all url in stdin, print them newline-separated to stdout
4
5reg='(((http|https|ftp)|mailto)[.:][^ >"\t]*|www\.[-a-z0-9.]+)[^ .,;\t>">\):]'
6
7grep -Po "$reg"
8
diff --git a/volume b/volume
new file mode 100755
index 0000000..6852577
--- /dev/null
+++ b/volume
@@ -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
9newvol=$(pulsemixer --change-volume "$1" --get-volume | awk '{print $1}')
10notify-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
5browser=${BROWSER:-firefox}
6searchengine="https://duckduckgo.com/?q="
7# For google: https://www.google.com/search?q=
8
9arg=$(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
3asfd
4# Open stdin in a text editor and sends modified selection to stdout
5
6xeditor=${XEDITOR:-gedit}
7
8f=$(mktemp)
9cat > "$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
5setxkbmap -option compose:ralt
6setxkbmap -option caps:swapescape
diff --git a/xplumb b/xplumb
new file mode 100755
index 0000000..977d2d5
--- /dev/null
+++ b/xplumb
@@ -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
15browser=${BROWSER:-firefox}
16terminal=${TERMINAL:-xterm}
17xeditor=${XEDITOR:-gedit}
18menu=${MENU:-dmenu}
19menuopts="-l 10"
20
21text=$(xsel | sed 's/\n/ /g')
22if [ $(echo "$text" | wc -c) -ge 11 ]; then
23 shorttext=$(echo "$text" | cut -b 1-10)...
24else
25 shorttext="$text"
26fi
27
28choice() {
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
41trymail() {
42 addr=$(echo "$1" | addressgrep)
43 ( [ -n "$addr" ] && mail-compose $addr ) || return 1
44}
45
46tryman() {
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
57tryurl() {
58 url=$(echo "$1" | urlgrep)
59 ( [ -n "$url" ] && $browser $url ) || return 1
60}
61
62open-file "$text" || \
63tryurl "$text" || \
64trymail "$text" || \
65tryman "$text" || \
66choice
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
6folder=~/Pictures/wallpapers
7pic=$(ls $folder | sort -R | head -1)
8
9# Alternative: use feh
10#feh --bg-fill --no-fehbg $folder/$pic
11xwallpaper --zoom $folder/$pic
12
13notify-send "Background of the day" $pic

Generated with cgit - Back to sebastiano.tronto.net