├── .gitignore
├── ARCHIVE
├── backup-meta-apt
├── backup-meta-bin
├── backup-meta-init
├── bash-debug-set-x.bash
├── bash-mselect-freq
├── bash-toggle-options.bash
├── blscd.sh
├── bmucks.sh
├── build-readme-dotfiles.sh
├── bup-daily.sh
├── bup-weekly.sh
├── camera-snapshot
├── clipbored-pick.sh
├── clipbored-restart.sh
├── cpb.sh
├── cvlc.sh
├── debian-deploy-desktop
├── detox-iso8859-1.sh
├── disownw
├── dpkg-purge-conf.sh
├── fball
├── feedfaetcher
├── feh-browser.sh
├── find-file
├── find-string
├── firefox-backup-history.sh
├── firefox-backup-urls.sh
├── firefox-profiles-refresh.sh
├── firefox-steal-flash.sh
├── fzf-curr-pos
├── fzf-ls
├── gdate2din
├── get-goog
├── gistup-bin-post.sh
├── gistup-bin.sh
├── grep-man
├── imapfilter-localhost-action
├── imapfilter-localhost-delete
├── kuno
├── kuno2
├── kuno3
├── make-src.sh
├── man2pdf
├── man2text
├── mcalc
├── mediathekvieww
├── mlr-add.sh
├── mlr.sh
├── mr-update-own.sh
├── mr-update.sh
├── mutt--d630
├── mutt--d630-archive
├── mutt--gmail
├── mutt--gmail-archive
├── mutt--hotmail
├── mutt--hotmail-archive
├── mutt--posteo
├── mutt--posteo-archive
├── mutt--posteo1
├── mutt--posteo1-archive
├── mutt--spool
├── mutt-filter-uri
├── newsbeuter2um.sh
├── nottoomuchw
├── ob-rc.sh
├── ob-reload.sh
├── ob-update-xdg-menu.sh
├── obnam-weekly
├── ocean
├── otsort.sh
├── packen.sh
├── passivedns-archive.sh
├── passivedns.sh
├── pdf-purge-metadata-recur-with-BecCyPDFMetaEdit.sh
├── pdf-purge-metadata-with-BecCyPDFMetaEdit.sh
├── pdfxviewer.sh
├── pkg.sh
├── print-horiz.sh
├── proxychains-get-random-server.sh
├── pycalendar
├── pyrandgen
├── pyrandgen-xsel
├── ronn2man.sh
├── run-xstow-home
├── screenshot-multi
├── show-ports-opened
├── show-ports-opened2
├── show-who
├── spotify-stream-gist
├── squid-backup-urls.sh
├── stjerm-autostart.sh
├── stow-data-new
├── stow-local.sh
├── stow-new
├── sxiv-browser
├── task-dir
├── tcsh--filetest
├── tcsh--printenv
├── todo-read
├── urldiff-add
├── urlview2
├── vfh
├── wetter
├── wew.sh
├── xib
├── xombrero-open-url-run.sh
├── xombrero-open-url-tab-run.sh
├── xombrero-open-url-tab.sh
├── xombrero-open-url.sh
├── xorg-autolock-old
├── xorg-dpms-standby
├── xorg-export-xinfo
├── xorg-lock-old
├── xorg-rename-current-desktop
├── xorg-run-or-raise
├── xorg-set-desktop-name
├── xorg-switch-keyboard-layout
├── xorg-touchpad
├── xorg-uniconify-all-xwins.sh
├── xtermj1.sh
├── xwinreg-close-active-region.sh
├── xwinreg-cycle-anticlock.sh
├── xwinreg-cycle-clock.sh
├── xwinreg-cycle-reg-clock.sh
├── xwinreg-cycle-reverse.sh
├── xwinreg-focus-active-region.sh
├── xwinreg-focus-toggle-next.sh
├── xwinreg-focus-toggle-prev.sh
├── xwinreg-grid-horizontal.sh
├── xwinreg-grid-square-horizontal.sh
├── xwinreg-grid-square-vertical.sh
├── xwinreg-grid-vertical.sh
├── xwinreg-hide-active-region.sh
├── xwinreg-loop.sh
├── xwinreg-loop2.sh
├── xwinreg-master-east.sh
├── xwinreg-master-north.sh
├── xwinreg-master-south.sh
├── xwinreg-master-west.sh
├── xwinreg-maximize-all.sh
├── xwinreg-unhide-active-region.sh
└── zettelkasten
├── README.md
├── audio-player
├── backup-meta
├── bash-count-occurence
├── bash-dedup-history
├── binary2nibble
├── bitbucket-rest-api
├── bitbucket-rest-api-libexec
├── bspot
├── bspot-create-featured-lists
├── bspot-create-gpb-lists
├── bspot-create-label
├── bspot-create-not-playable
├── bspot-create-release-date
├── bspot-get-tracks
├── bspot-shuffle-list
├── bspwm-rules
├── cclean
├── checkout-all-wir-bare-repos
├── choose
├── chromium-history
├── clipbuffer
├── compose-my-confluence-how-to-article
├── confluence-rest-api
├── confluence-rest-api-libexec
├── countdown
├── create-my-confluence-how-to-article
├── daemonize
├── daylight
├── debian-build-sources-list
├── debian-dist-upgrade
├── debian-update-alternatives
├── debian-upgrade
├── detach
├── dnsmasq-backup-urls
├── download-rocketchat-entities
├── dudel
├── emacsd
├── event
├── event-editor
├── fb-image-viewer
├── fc-edit
├── feed2newsboat
├── feedfaetcher
├── fetch-all-wir-repo-refs
├── file-browser
├── furlview
├── fzf-bind.bash
├── gaisma
├── generate-bookmarks-file
├── generate-my-confluence-how-to-article
├── generate-workingdays-sheet
├── get-basic-edid-identification
├── get-battery-capacity
├── get-edid-as-sha256sums
├── get-input-device-names-as-md5sums
├── get-lifeday
├── get-nox
├── get-product-name-as-sha256sum
├── get-product-uuid-as-sha256sum
├── get-sundata
├── get-wan-ip
├── github-build-bin-readme
├── grabc2clipboard
├── grep-url
├── habit
├── habit-editor
├── hblock
├── hexdump-raw-edid
├── idea-file-info
├── image-viewer
├── iplog
├── issue
├── issue-editor
├── jira-rest-api
├── jira-rest-api-libexec
├── lan-down
├── lan-up
├── lesspipew
├── list-all-branches
├── list-all-can-merge-prs
├── list-all-confluence-blogposts
├── list-all-inactive-reviewers
├── list-all-my-confluence-how-to-articles
├── list-all-my-open-prs
├── list-all-my-open-reviews
├── list-all-other-rocketchat-channels
├── list-all-overdue-prs
├── list-all-tags
├── list-all-users-contact-data
├── list-all-users-ip-addresses
├── list-commits-totals
├── list-rocketchat-user-presences
├── lock
├── log
├── log-editor
├── lsdisk
├── lsort
├── mail-archive
├── mail-deliver
├── mail-get
├── mail-hook-post
├── mail-hook-pre
├── mail-inbox
├── mail-queue
├── mail-retrieve
├── mail-send
├── mail-update
├── mail-viewer
├── menu
├── mime-build-types
├── mirror-all-wir-repos
├── msmtpqw
├── mutt--d630
├── mutt--d630-archive
├── mutt--gmail
├── mutt--gmail-archive
├── mutt--hotmail
├── mutt--hotmail-archive
├── mutt--posteo
├── mutt--posteo-archive
├── mutt--posteo1
├── mutt--posteo1-archive
├── mutt--spool
├── mutt-save-attachments
├── news
├── open
├── pass2clipboard
├── pdf-purge-metadata
├── power
├── print-apt-conf
├── pwgen2clipboard
├── pycolor
├── pyfonts
├── readline-editor
├── reconfigure-audio
├── reconfigure-camera
├── reconfigure-keyboard
├── reconfigure-linux-console-color
├── reconfigure-monitor
├── reconfigure-network-device
├── reconfigure-pointer
├── reload-sxhkd
├── repeat
├── rest
├── rest-api
├── restart-dunst
├── restart-sxhkd
├── rocketchat-rest-api
├── rocketchat-rest-api-libexec
├── rocketchat-status
├── run
├── run-black
├── run-borg-weekly
├── run-chromium
├── run-chromium-incognito
├── run-feedfaetcher
├── run-firefox
├── run-flake8
├── run-generate-bookmarks-file
├── run-grabc
├── run-idea
├── run-imapfilter
├── run-isort
├── run-logger
├── run-mutt
├── run-mypy
├── run-notify-send
├── run-pidgin
├── run-pwgen
├── run-rtcwake
├── run-scrot
├── run-source-highlight
├── run-spotify
├── run-transmission-cli
├── run-vncserver
├── run-weechat
├── run-z
├── schlafe
├── sdmenu
├── skel-home
├── sort-ipv4
├── sound
├── spotify-mpris
├── ssudo
├── startx.sh
├── stat2assoc
├── stj1
├── swaptop
├── task-calc
├── task-colors
├── task-cv
├── task-local
├── taskum-add
├── template
├── test-ctty
├── test-daylight
├── test-inet
├── test-xorg
├── text-editor
├── text-visual
├── theme
├── todo
├── todo-editor
├── tput-colors.sh
├── update-all-wir-repo-mirrors
├── update-packages
├── volume
├── watch-all-confluence-spaces
├── watch-all-wir-repos
├── web-browser
├── webheader
├── wlan-down
├── wlan-up
├── wless
├── workingdays
├── wots
├── wradio
├── wvim
├── x-audio-player
├── x-file-browser
├── x-image-viewer
├── x-mail-viewer
├── x-pdf-viewer
├── x-terminal
├── x-terminal-tabbed
├── x-text-editor
├── x-video-player
├── x-web-browser
├── xorg-autolock
├── xorg-get-xclass
├── xorg-get-xids
├── xorg-lock
├── xorg-locker
├── xorg-raise-xwin
├── xorg-selection-clear
├── xorg-selection-clipboard-in
├── xorg-selection-clipboard-out
├── xorg-selection-primary-in
├── xorg-selection-primary-out
├── xorg-switch-to-desktop
├── youtube-dl-get-audio
├── zeit
└── zombies
/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 |
--------------------------------------------------------------------------------
/ARCHIVE/backup-meta-apt:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Backup infos about installed packages on Debian.
4 | # TODO
5 |
6 | backup_dir=${XDG_BACKUP_HOME:?}
7 |
8 | sudo rm -rv -- "$backup_dir/"pkgs
9 | mkdir -pv -- "$backup_dir/"pkgs
10 |
11 | cd -- "$backup_dir/"pkgs || exit 1
12 |
13 | COLUMNS=200 dpkg-query -l >./query.txt
14 | sudo sh -c '
15 | apt-cache policy > ./cache.txt;
16 | apt-mark showauto > ./auto.txt;
17 | apt-mark showmanual > ./manual.txt;
18 | # cp -v /etc/apt/trusted.gpg ./trusted.gpg;
19 | apt-clone clone .;
20 | '
21 |
22 | # dpkg --get-selections |
23 | # mawk '!/deinstall|purge|hold/ { print $1 }' > ./packages.txt;
24 |
25 | # sudo find /etc/apt/sources.list* \
26 | # -type f \
27 | # -name '*.list' \
28 | # -exec sh -c '
29 | # printf "%s\n## " "$1";
30 | # grep "^[[:space:]]*[^#[:space:]]" "$1";' \
31 | # _ {} \; > ./sources.list;
32 |
33 | # vim: set ft=sh :
34 |
--------------------------------------------------------------------------------
/ARCHIVE/backup-meta-bin:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Backup installed executables.
4 | # TODO
5 |
6 | backup_dir=${XDG_BACKUP_HOME:?}/
7 |
8 | find /var/lib/dpkg/info/ \
9 | -daystart \( -name \*.list -a -mtime -7 \) \
10 | -printf '%f\n' |
11 | sed s:.list\$:: |
12 | sort >"$backup_dir/"7_days.txt
13 |
14 | IFS=:
15 |
16 | whatis -w '*' $PATH /usr/bin/X11 2>&1 | sort -u >"$backup_dir/"whatis.txt
17 |
18 | # vim: set ft=sh :
19 |
--------------------------------------------------------------------------------
/ARCHIVE/backup-meta-init:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Backup inits.
4 | # TODO
5 |
6 | {
7 | find /etc/init.d/ -perm /111 -type f -printf %f\\n
8 | find /etc/init -type f -printf %f\\n
9 | } | sort -u >"${XDG_BACKUP_HOME:?}/"init.txt
10 |
11 | # vim: set ft=sh :
12 |
--------------------------------------------------------------------------------
/ARCHIVE/bash-debug-set-x.bash:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # A debugging function for bash.
4 | # Based on http://mywiki.wooledge.org/BashGuide/Practices#Activate_Bash.27s_Debug_Mode
5 |
6 | debug_set_x ()
7 | case $1 in
8 | ('')
9 | ! :;;
10 | (-)
11 | set -x;;
12 | (+)
13 | set +x;
14 | exec 4>&-;;
15 | (*)
16 | if
17 | [[ -d ${1%/*} ]];
18 | then
19 | exec 4>>"$1";
20 | BASH_XTRACEFD=4;
21 | set -x;
22 | fi;;
23 | esac;
24 |
25 | # vim: set ft=sh :
26 |
--------------------------------------------------------------------------------
/ARCHIVE/bash-mselect-freq:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Print most used commands of the bash history and run it from dmenu.
4 |
5 | bash-count-occurence |
6 | menu dmenu2 RUN |
7 | mawk '{ print $2 }'
8 |
9 | # vim: set ft=sh :
10 |
--------------------------------------------------------------------------------
/ARCHIVE/bash-toggle-options.bash:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Toggle bash options via fzf.
4 |
5 | __set ()
6 | while
7 | read -r b o n _;
8 | do
9 | case $b$o in
10 | (set+o) set -o $n;;
11 | (set-o) set +o $n;;
12 | (shopt-s) shopt -u $n;;
13 | (shopt-u) shopt -s $n;;
14 | esac;
15 | done;
16 |
17 | __these ()
18 | {
19 | BOLD=$(tput bold || tput md);
20 | RESET=$(tput sgr0 || tput me);
21 | GREEN=$(tput setaf 2 || tput AF 2);
22 | RED=$(tput setaf 1 || tput AF 1);
23 |
24 | sed "
25 | / -[so] / {
26 | s/$/ ${BOLD}${GREEN}enabled${RESET}/;
27 | b;
28 | };
29 | {
30 | s/$/ ${BOLD}${RED}disabled${RESET}/;
31 | };
32 | " |
33 | sort -k 3 |
34 | column -t |
35 | fzf --ansi --multi --with-nth=3.. --tiebreak=begin;
36 | };
37 |
38 | __options ()
39 | {
40 | shopt -p;
41 | shopt -op;
42 | };
43 |
44 | IFS=$' \t\n';
45 |
46 | __set < <(__these < <(__options));
47 |
48 | # vim: set ft=sh :
49 |
--------------------------------------------------------------------------------
/ARCHIVE/blscd.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Wrapper for blscd.
4 |
5 | source blscd
6 |
7 | BLSCD_SHOW_HIDDEN=0 Blscd Blscd::Main "$@"
8 |
9 | # vim: set ft=sh :
10 |
--------------------------------------------------------------------------------
/ARCHIVE/build-readme-dotfiles.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Build README.md in github.com/D630/dotfiles .
4 |
5 | cd -- "${HOME}/stow" || exit 1;
6 |
7 | IFS='.:' read -r _ _ p _ _ < <(
8 | git config --local --get remote.origin.url
9 | )
10 | P=https://github.com/${p}
11 |
12 | __find ()
13 | {
14 | # find . -mindepth 3 -regextype posix-egrep \
15 | # -path "./bin/local/bin/*" \
16 | # -prune \
17 | # -o \( -type f -a -regex "\./.*/local/bin/.*\.(awk|py|sh)" \) \
18 | # -exec grep -H -m 1 '^# ' {} +;
19 | git ls-files -z '*.awk' '*.py' '*.sh' \
20 | | grep -Zz -v -e '^bash/.bashrc.d/*' -e '^profile/.profile.d/*' \
21 | | xargs -0 grep -H -m 1 '^# ';
22 | }
23 |
24 | { printf '%s' "$(< /dev/fd/0)" > ./README.md ; } <<'HEADER'
25 | Public repo with some of my dotfiles (configs and [helper scripts](https://github.com/D630/dotfiles/blob/master/SCRIPT.md)) used on Debian GNU/Linux. All my dotfiles are managed with [xstow](http://xstow.sourceforge.net/). You can find a description of my home directory and a list of my preferred tools in the [doc-repo](https://github.com/D630/doc). See also [bin](https://github.com/D630/bin) for other scripts.
26 |
27 | Unless otherwise stated, these files are in the public domain.
28 | HEADER
29 |
30 | __find \
31 | | sort \
32 | | {
33 | printf '%s\n\n' "Scripts in */local/bin:";
34 | while
35 | IFS=: read -r p c
36 | do
37 | p=${p#./}
38 | printf '* [%s/%s](%s/blob/master/%s): %s\n' "${p%%/*}" "${p##*/}" "${P}" "${p}" "${c#\# }"
39 | done
40 | } \
41 | > ./SCRIPT.md;
42 |
43 | # vim: set ft=sh :
44 |
--------------------------------------------------------------------------------
/ARCHIVE/bup-daily.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Daily home backup with bup.
4 |
5 | typeset -x BUP_DIR=/media/truecrypt1/linux/bup
6 |
7 | while
8 | IFS= read -r -d ''
9 | do
10 | BUP_DIR=/media/truecrypt1/linux/bup/${REPLY}
11 | done < <(
12 | find "$BUP_DIR" -maxdepth 1 -type d -printf '%f\0' \
13 | | sort -zn \
14 | | sed -zn '$p';
15 | )
16 |
17 | bup index -ux /home
18 | bup save -n home /home
19 |
20 | # vim: set ft=sh :
21 |
--------------------------------------------------------------------------------
/ARCHIVE/bup-weekly.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Weekly home backup with bup.
4 |
5 | typeset -x \
6 | BUP_DIR=/media/truecrypt1/linux/bup \
7 | today;
8 |
9 | printf -v today '%(%Y-%m-%d)T' -1
10 |
11 | while
12 | IFS= read -r -d ''
13 | do
14 | if
15 | (( ${today//-/} - ${REPLY//-/} > 14 ))
16 | then
17 | tmp_dir=$(mktemp -d --tmpdir) && {
18 | rsync -var --delete "${tmp_dir}/" "${BUP_DIR}/${REPLY}/" && {
19 | trap 'rm -Rf "$tmp_dir" "${BUP_DIR}/${REPLY}"' EXIT
20 | printf '%s/%s has been deleted\n' "$BUP_DIR" "$REPLY" \
21 | 1>&2;
22 | }
23 | }
24 | fi
25 | done < <(
26 | find "$BUP_DIR" -maxdepth 1 -type d -printf '%f\0' \
27 | | sort -zn \
28 | | sed -zn '$!p';
29 | )
30 |
31 | BUP_DIR=/media/truecrypt1/linux/bup/${today}
32 |
33 | bup init
34 | bup index -ux /home
35 | bup save -n home /home
36 |
37 | # vim: set ft=sh :
38 |
--------------------------------------------------------------------------------
/ARCHIVE/camera-snapshot:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Take a quick camera snapshot.
4 |
5 | mkdir -p /tmp/camera-snapshots
6 |
7 | exec ffmpeg \
8 | -f video4linux2 \
9 | -s 640x480 \
10 | -i /dev/video0 \
11 | -ss 0:0:2 \
12 | -frames 1 \
13 | "/tmp/camshots/$(date +%s).jpg"
14 |
15 | # vim: set ft=sh :
16 |
--------------------------------------------------------------------------------
/ARCHIVE/clipbored-pick.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Simple clipboard manager for clipbored using dmenu or fzf.
4 |
5 | xsels=${HOME}/local/var/lib/clipbored/clips
6 |
7 | if
8 | test-tty.sh \
9 | 2>/dev/null;
10 | then
11 | menu=fzf
12 | else
13 | menu=dmenu2
14 | fi
15 |
16 | printf -v xsels '%s' "$(
17 | tac "$xsels" \
18 | | sed '/^$/d' \
19 | | menu.sh "$menu" ">";
20 | )"
21 |
22 | printf "$xsels" \
23 | | xclip -i -l 1 -selection clipboard;
24 |
25 | # vim: set ft=sh :
26 |
--------------------------------------------------------------------------------
/ARCHIVE/clipbored-restart.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Restart clipbored.
4 |
5 | if
6 | test -n "$DISPLAY"
7 | then
8 | export XDG_DATA_HOME="${HOME}/local/var/lib"
9 | clipbored -k
10 | pkill clipbored
11 | daemonize.sh clipbored
12 | fi
13 |
14 | # vim: set ft=sh :
15 |
--------------------------------------------------------------------------------
/ARCHIVE/cpb.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Create backup copy of a file.
4 |
5 | for file
6 | do
7 | if
8 | test -e "$1"
9 | then
10 | cp -v -- "$1" "${1}_$(date +%Y-%m-%d_%H-%M-%S)"
11 | else
12 | printf '%s not found\n' "$1" \
13 | 1>&2;
14 | fi
15 | done
16 |
17 | # vim: set ft=sh :
18 |
--------------------------------------------------------------------------------
/ARCHIVE/cvlc.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Run cvlc in terminal.
4 |
5 | daemonize.sh terminal.sh -c cvlc -t cvlc -T cvlc -e sh -c "cvlc ${1};exec ${SHELL}"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/detox-iso8859-1.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Run detox on all files in the current directory.
4 |
5 | detox -s iso8859_1 -r -v -n ./*
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/disownw:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Disown job.
4 |
5 | set -o monitor;
6 |
7 | "${1:?}" "${@:2}" &
8 | pid=$!;
9 |
10 | jn=$(
11 | jobs -lr |
12 | sed "/\[[0-9]*\]+ $pid/ s/\[\([0-9]*\)\].*/\1/";
13 | );
14 |
15 | ((jn)) &&
16 | builtin disown "%$jn";
17 |
18 | # vim: set ft=sh :
19 |
--------------------------------------------------------------------------------
/ARCHIVE/dpkg-purge-conf.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # dpkg --purge
4 |
5 | dpkg -l \
6 | | grep '^rc ' \
7 | | cut -d " " -f3 \
8 | | xargs dpkg --purge;
9 |
10 | # vim: set ft=sh :
11 |
--------------------------------------------------------------------------------
/ARCHIVE/fball:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Show some soccer results from http://www.sportschau.de.
4 |
5 | [[ ${1#-} =~ [0-3] ]] || {
6 | printf 'Richtigen Wettbewerb angeben\n' 1>&2;
7 | exit 1;
8 | };
9 |
10 | links[1]=https://www.sportschau.de/ergebnisse_tabellen/ergebnisse102~_eam-14d4fb6c588c7fcebc9c5fd4dfd21e2b_eap__liga-BL1_eap__sportart-fb.html?eap=8oI34N4hym4RDV6dhKK0OnLYM%2FNzIoiKmKv2HkJYKgPxCIifwJGZmigVNLw42zmko7u1BzkuenhteE%2FSifHaWb%2BD5g3qtsFGsnGotmb1PcZSS6XXfYWnKf1ELW46g2DdkfFtPY%2BHqJZgCaUEvpeNMw%3D%3D \
11 | links[2]=https://www.sportschau.de/ergebnisse_tabellen/ergebnisse102~_eam-14d4fb6c588c7fcebc9c5fd4dfd21e2b_eap__liga-BL2_eap__sportart-fb.html?eap=8oI34N4hym4RDV6dhKK0OnLYM%2FNzIoiKmKv2HkJYKgPxCIifwJGZmigVNLw42zmko7u1BzkuenhteE%2FSifHaWb%2BD5g3qtsFGsnGotmb1PcZSS6XXfYWnKf1ELW46g2DdkfFtPY%2BHqJZgCaUEvpeNMw%3D%3D \
12 | links[3]=https://www.sportschau.de/ergebnisse_tabellen/ergebnisse102~_eam-14d4fb6c588c7fcebc9c5fd4dfd21e2b_eap__liga-BL3_eap__sportart-fb.html?eap=8oI34N4hym4RDV6dhKK0OnLYM%2FNzIoiKmKv2HkJYKgPxCIifwJGZmigVNLw42zmko7u1BzkuenhteE%2FSifHaWb%2BD5g3qtsFGsnGotmb1PcZSS6XXfYWnKf1ELW46g2DdkfFtPY%2BHqJZgCaUEvpeNMw%3D%3D \
13 | links[0]=https://www.sportschau.de/ergebnisse_tabellen/ergebnisse102~_eam-14d4fb6c588c7fcebc9c5fd4dfd21e2b_eap__liga-uebers_eap__sportart-fb.html?eap=8oI34N4hym4RDV6dhKK0OnLYM%2FNzIoiKmKv2HkJYKgPxCIifwJGZmigVNLw42zmko7u1BzkuenhteE%2FSifHaWb%2BD5g3qtsFGsnGotmb1PcZSS6XXfYWnKf1ELW46g2DdkfFtPY%2BHqJZgCaUEvpeNMw%3D%3D;
14 |
15 | curl -s "${links[${1#-}]}" |
16 | scrape -be div.table |
17 | grep -v '' |
18 | w3m -dump -no-graph -cols 142 -T text/html |
19 | sed -n '
20 | 2,36{
21 | s/ Statistik.*//g;
22 | s/ zu //g;
23 | s/Historie//g;
24 | s/gegen:/vs./g;
25 | s/Endstand: //g;
26 | s/Halbzeitstand: //g;
27 | p
28 | }';
29 |
30 | # vim: set ft=sh :
31 |
--------------------------------------------------------------------------------
/ARCHIVE/feh-browser.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Open all files under the current directory with feh.
4 | # Source: archlinux wiki
5 |
6 | shopt -s nullglob
7 |
8 | if
9 | [[ ! -f $1 ]]
10 | then
11 | printf '%s: first argument is not a file\n' "$0" \
12 | 1>&2;
13 | exit 1
14 | fi
15 |
16 | typeset \
17 | file=$(basename -- "$1") \
18 | dir=$(dirname -- "$1");
19 | typeset -a arr=()
20 |
21 | shift 1
22 |
23 | if
24 | cd -- "$dir"
25 | then
26 | for i in *
27 | do
28 | [[ -f $i ]] || continue;
29 | arr+=( "$i" )
30 | [[ $i == $file ]] && c=$(( ${#arr[@]} - 1 ));
31 | done
32 | fi
33 |
34 | setsid.sh feh "$@" -- "${arr[@]:c}" "${arr[@]:0:c}"
35 |
36 | # vim: set ft=sh :
37 |
--------------------------------------------------------------------------------
/ARCHIVE/find-file:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Find file under the current directory with flag -ls.
4 |
5 | find . -type f -iname "*$*" -ls
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/find-string:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Grep string in all files under the current directory with find.
4 |
5 | find . ! -type d -iname "*$2" |
6 | xargs grep -i "$1"
7 |
8 | # vim: set ft=sh :
9 |
--------------------------------------------------------------------------------
/ARCHIVE/firefox-backup-history.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Back up latest firefox history with sqlite3.
4 | # Create logfile and a record in um.
5 |
6 | db_path=$(echo ${HOME}/.mozilla/firefox/*.default)/places.sqlite
7 | log_file=${HOME}/local/var/log
8 | log=${log_file}/urls.log
9 | uris=${log_file}/uris_new.log
10 |
11 | if
12 | sqlite3 "$db_path" '
13 | SELECT DISTINCT moz_places.url
14 | FROM moz_places, moz_historyvisits
15 | WHERE ((url LIKE "http%" OR url LIKE "ftp%" OR url LIKE "file%" OR url LIKE "mailto%" OR url LIKE "gopher%") AND moz_historyvisits.place_id = moz_places.id)
16 | ORDER BY url' \
17 | | sed 's/"//g' \
18 | | tee "$uris" \
19 | | cat "$log" - \
20 | | sort -u \
21 | > "${log}.$$";
22 | then
23 | mv "${log}.$$" "$log");
24 | fi
25 |
26 | if
27 | [[ -e $uris ]]
28 | then
29 | while
30 | read -r line
31 | do
32 | um add uri="$line"
33 | done < "$uris"
34 | rm -- "$uris"
35 | fi
36 |
37 | # vim: set ft=sh :
38 |
--------------------------------------------------------------------------------
/ARCHIVE/firefox-backup-urls.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Backup all uris in firefox with sqlite3.
4 | # Create logfile and a record in urimark.
5 |
6 | db_path=$(echo ${HOME}/.mozilla/firefox/*.default)/places.sqlite
7 | log_file=${HOME}/local/var/log
8 | log=${log_file}/urls.log
9 | uris=${log_file}/uris_new.log
10 |
11 | if
12 | sqlite3 "$db_path" '
13 | SELECT DISTINCT moz_places.url
14 | FROM moz_places
15 | WHERE (url LIKE "http%" OR url LIKE "ftp%" OR url LIKE "file%" OR url LIKE "mailto%" OR url LIKE "gopher%")
16 | UNION ALL
17 | SELECT DISTINCT moz_favicons.url
18 | FROM moz_favicons
19 | WHERE (url LIKE "http%" OR url LIKE "ftp%" OR url LIKE "file%" OR url LIKE "mailto%" OR url LIKE "gopher%")
20 | ORDER BY url' \
21 | | sed 's/"//g' \
22 | | tee "$uris" \
23 | | cat "$log" - \
24 | | sort -u \
25 | > "${log}.$$";
26 | then
27 | mv "${log}.$$" "$log"
28 | fi
29 |
30 | if
31 | [[ -e $uris ]]
32 | then
33 | while
34 | read -r line
35 | do
36 | um add uri="$line"
37 | done < "$uris"
38 | rm -- "$uris"
39 | fi
40 |
41 | # vim: set ft=sh :
42 |
--------------------------------------------------------------------------------
/ARCHIVE/firefox-profiles-refresh.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Refresh Firefox Profiles.
4 |
5 | shopt -s extglob
6 | tmp_dir=$(mktemp -d --tmpdir)
7 |
8 | for i in "${HOME}/.mozilla/firefox/"*.!(clean-template|ini)
9 | do
10 | rsync -var --delete "${tmp_dir}/" "${i}/"
11 | rsync -var ${HOME}/.mozilla/firefox/*.clean-template/ "${i}/"
12 | done
13 |
14 | # vim: set ft=sh :
15 |
--------------------------------------------------------------------------------
/ARCHIVE/firefox-steal-flash.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Grep and copy flash from firefox. Open selection in mpv.
4 |
5 | browser=firefox
6 | player=mpv
7 | files=()
8 |
9 | while
10 | IFS= read -r -d ''
11 | do
12 | random=$(od -vAn -N 1 -tu < /dev/urandom)
13 | rsync -a -v --progress --no-l -L "$REPLY" "/tmp/${random// /}.flash"
14 | done < <(
15 | find "/proc/$(pgrep ${browser})/fd" -type l -lname "/tmp/Flash*" -print0
16 | )
17 |
18 | mapfile -t files < <(
19 | find "/tmp/" -maxdepth 1 -type f -name "*.flash"
20 | )
21 |
22 | if
23 | (( ! ${#files[@]} ))
24 | then
25 | printf '%s\n' "There is no flash file" \
26 | 1>&2;
27 | exit 1
28 | elif
29 | (( ${#files[@]} == 1 ))
30 | then
31 | setsid.sh "$player" "/tmp/${random// /}.flash" \
32 | 2>/dev/null;
33 | else
34 | set -e
35 | ls -l "/tmp" \
36 | | grep -e ".*flash";
37 | read -re -p "File: " file
38 | setsid.sh "$player" "/tmp/${file}.flash" \
39 | 2>/dev/null;
40 | fi
41 |
42 | # vim: set ft=sh :
43 |
--------------------------------------------------------------------------------
/ARCHIVE/fzf-curr-pos:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Start fzf from current position.
4 | # Source: https://github.com/junegunn/fzf/issues/405
5 | #
6 | # The logic in the getpos function is stolen from
7 | # http://stackoverflow.com/a/2575525
8 | # Pass "row" or "col" as an argument to get their positions
9 |
10 | function getpos {
11 | exec < /dev/tty;
12 |
13 | typeset -n arg=$1;
14 | typeset \
15 | col \
16 | row \
17 | oldstty=$(stty -g);
18 |
19 | stty raw -echo min 0;
20 |
21 | printf %b '\033[6n' > /dev/tty;
22 | IFS='[;' read -d R _ row col < /dev/tty;
23 |
24 | stty "$oldstty";
25 |
26 | printf %d "$((arg - 1))";
27 |
28 | unset -n arg;
29 | };
30 |
31 | typeset -i \
32 | lines=$(tput lines) \
33 | row=$(getpos row);
34 | typeset -i \
35 | halfway=lines/2 \
36 | start_row=lines-row;
37 | typeset -x FZF_DEFAULT_OPTS=$FZF_DEFAULT_OPTS;
38 |
39 | # Start fzf from the current row
40 | if
41 | ((row < halfway));
42 | then
43 | FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS --reverse --margin $((row - 1)),0,0";
44 | else
45 | ((start_row == 1 && (start_row=0)));
46 | FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS --no-reverse --margin 0,0,$start_row";
47 | fi;
48 |
49 | fzf;
50 |
51 | # vim: set ft=sh :
52 |
--------------------------------------------------------------------------------
/ARCHIVE/fzf-ls:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Select files listed in a directory.
4 |
5 | arg=$(readlink -f "${1:-$PWD}")
6 |
7 | test -d "$arg" &&
8 | ls -A1 --color=always "$arg" |
9 | fzf -m --ansi --prompt=PRINT\
10 |
11 | # vim: set ft=sh :
12 |
--------------------------------------------------------------------------------
/ARCHIVE/gdate2din:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Grep and convert german dates with dateutils using dgrep & strptime.
4 | # DIN 1355-1 => ISO 8601 / DIN 5008
5 | # DIN 5008 mit zwei Leerzeichen und 4-stellige Jahreszahl => ISO 8601 / DIN 5008
6 |
7 | while
8 | IFS= read -r;
9 | do
10 | if
11 | [[ $REPLY =~ [[:digit:]]{2}[[:punct:]][[:space:]][[:alpha:]]{2,3}[[:space:]][[:digit:]]{4} ]];
12 | then
13 | printf '%s => %s\n' "$REPLY" "$(
14 | strptime -e -i %d.\ %b\ %Y -f %Y-%m-%d "$REPLY";
15 | )";
16 | elif
17 | [[ $REPLY =~ [[:digit:]]{2}[[:punct:]][[:space:]][[:alpha:]]{4,}[[:space:]][[:digit:]]{4} ]];
18 | then
19 | printf '%s => %s\n' "$REPLY" "$(
20 | strptime -e -i %d.\ %B\ %Y -f %Y-%m-%d "$REPLY";
21 | )";
22 | elif
23 | [[ $REPLY =~ [[:digit:]]{2}[[:punct:]][[:digit:]]{2}[[:punct:]][[:digit:]]{2} ]];
24 | then
25 | printf '%s => %s\n' "$REPLY" "$(
26 | strptime -e -i %d.%m.%Y -f %Y-%m-%d "$REPLY";
27 | )";
28 | fi;
29 | done < <(
30 | dgrep -z CEST --from-zone=CEST -e -o \
31 | -i %d.%m.%Y \
32 | -i %d.\ %b\ %Y \
33 | -i %d.\ %B\ %Y \
34 | --gt 1970-01-01 \
35 | < "$1";
36 | );
37 |
38 | # vim: set ft=sh :
39 |
--------------------------------------------------------------------------------
/ARCHIVE/get-goog:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Search google.
4 | # Source: http://chneukirchen.org/dotfiles/bin/goog
5 |
6 | Q=$*
7 |
8 | printf '%s\n' "$(
9 | curl -A Mozilla/4.0 -skLm 10 \
10 | "http://www.google.com/search?nfpr=\&q=${Q// /+}" \
11 | | grep -oP '\/url\?q=.+?&' \
12 | | sed 's/\/url?q=//;s/&//;s/\%/\\x/g';
13 | )"
14 |
15 | # vim: set ft=sh :
16 |
--------------------------------------------------------------------------------
/ARCHIVE/grep-man:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Grep pattern in manpage.
4 |
5 | man -- "$1" |
6 | grep -i -C 2 --color=always "$2" |
7 | less -R
8 |
9 | # vim: set ft=sh :
10 |
--------------------------------------------------------------------------------
/ARCHIVE/imapfilter-localhost-action:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: imapfilter with config localhost-action.lua.
4 | # TODO
5 |
6 | exec imapfilter -c "$HOME/".imapfilter/localhost-action.lua
7 |
8 | # vim: set ft=sh :
9 |
--------------------------------------------------------------------------------
/ARCHIVE/imapfilter-localhost-delete:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: imapfilter with config localhost-delete.lua.
4 | # TODO
5 |
6 | exec imapfilter \
7 | -c "$HOME/".imapfilter/localhost-delete.lua \
8 | -l "${XDG_VAR_HOME:?}/"log/imapfilter.log
9 |
10 | # vim: set ft=sh :
11 |
--------------------------------------------------------------------------------
/ARCHIVE/kuno:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Add interactively a note via terminal to use it later in org-mode.
4 | # Ask also for taskwarrior.
5 |
6 | typeset \
7 | file \
8 | kuno \
9 | selection \
10 | tags \
11 | time \
12 | title;
13 |
14 | file=${XDG_DATA_HOME:?}/documents/Notizen/outline/quicknotes.org;
15 |
16 | read -re -p 'Title: ' title;
17 | read -re -p 'Kurznotiz: ' kuno;
18 | read -re -p 'Tags: ' tags;
19 |
20 | printf -v time '%(%Y-%m-%d_%a_%H:%M)T' -1;
21 |
22 | cat >> "$file" << TEMPLATE
23 | * Kurznotiz: $title $tags
24 | :LOGBOOK:
25 | CLOCK: [$time]--[$time] => 0:00
26 | :END:
27 | <$time>
28 | :PROPERTIES:
29 | :TODO:
30 | :PRIORITY:
31 | :DEADLINE:
32 | :SCHEDULED:
33 | :CLOSED:
34 | :CLOCKSUM:
35 | :CLOCKSUM_T:
36 | :BLOCKED:
37 | :ITEM:
38 | :FILE:
39 | :COLUMNS:
40 | :CATEGORY:
41 | :ARCHIVE:
42 | :LOGGING:
43 | :END:
44 | $kuno
45 | TEMPLATE
46 |
47 | #emacsclient -t "$file"
48 |
49 | read -re -n 1 -p 'Add a task to taskwarrior? (y/n)' selection;
50 | [[ $selection == y ]] &&
51 | taskwarrior-add;
52 |
53 | # vim: set ft=sh :
54 |
--------------------------------------------------------------------------------
/ARCHIVE/kuno2:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Simple notetaker using ledit.
4 |
5 | store=${XDG_DATA_HOME:?}/kuno2
6 | date=$(date --utc --date now +%s)
7 |
8 | mkdir -p -- "$store"
9 | ledit -x -h "${store}/${date}"
10 |
11 | # vim: set ft=sh :
12 |
--------------------------------------------------------------------------------
/ARCHIVE/kuno3:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Simple notetaker using rlfe.
4 |
5 | store=${XDG_DATA_HOME:?}/kuno2
6 | date=$(date --utc --date now +%s)
7 |
8 | mkdir -p -- "$store"
9 | rlfe -h "${store}/${date}" cat
10 |
11 | # vim: set ft=sh :
12 |
--------------------------------------------------------------------------------
/ARCHIVE/man2pdf:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # man2pdf script.
4 |
5 | man -w "$@" 2>/dev/null
6 |
7 | man -t "$@" |
8 | ps2pdf - "$@.pdf"
9 |
10 | printf '%s.pdf\n' "$@"
11 |
12 | # vim: set ft=sh :
13 |
--------------------------------------------------------------------------------
/ARCHIVE/man2text:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # man2text script.
4 |
5 | for i in *.1; do
6 | man -l "./$i" |
7 | sed -r 's/\d027\[[0-9]+m//g' >"$i.txt"
8 | done
9 |
10 | # vim: set ft=sh :
11 |
--------------------------------------------------------------------------------
/ARCHIVE/mcalc:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Simple calculation with bc and dmenu.
4 |
5 | function __result {
6 | result=$(
7 | xsel -o |
8 | menu "$1" RESULT |
9 | xargs echo |
10 | bc 2>&1;
11 | );
12 |
13 | printf %s\\n "$result" |
14 | tee >(xclip -i);
15 | };
16 |
17 | if
18 | test-tty 2>/dev/null;
19 | then
20 | menu=slmenu;
21 | else
22 | menu=dmenu2;
23 | fi;
24 |
25 | __result "$menu";
26 |
27 | while
28 | [[ -n $result ]];
29 | do
30 | __result "$menu";
31 | done;
32 |
33 | # vim: set ft=sh :
34 |
--------------------------------------------------------------------------------
/ARCHIVE/mediathekvieww:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # MediathekView (german tv)
4 |
5 | case $1 in
6 | run)
7 | java -jar /opt/MediathekView.jar
8 | ;;
9 | load)
10 | java -jar /opt/bin/MediathekView.jar -auto -noGui
11 | ;;
12 | *)
13 | printf 'Usage: mediathekieww (run|load)\n' 1>&2
14 | exit 1
15 | ;;
16 | esac
17 |
18 | # vim: set ft=sh :
19 |
--------------------------------------------------------------------------------
/ARCHIVE/mlr-add.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Record repo as personal non-public repo.
4 |
5 | if
6 | [ -e "./.git" -o -e "./.hg" ]
7 | then
8 | if
9 | printf '%s\n' "$PWD" \
10 | >> "${HOME}/local/var/lib/mlr/repos.txt";
11 | then
12 | tail -n2 "${HOME}/local/var/lib/mlr/repos.txt"
13 | fi
14 | else
15 | printf '%s\n' "There is no repo in this dir." \
16 | 1>&2;
17 | fi
18 |
19 | # vim: set ft=sh :
20 |
--------------------------------------------------------------------------------
/ARCHIVE/mlr.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Update personal non-public repos.
4 |
5 | while
6 | read -r repo
7 | do
8 | if
9 | cd -- "$repo"
10 | then
11 | if
12 | test -e "./.git"
13 | then
14 | git ls-files --deleted -z \
15 | | xargs --null git rm \
16 | 1>/dev/null \
17 | 2>&1;
18 | git add -A . \
19 | 1>/dev/null \
20 | 2>&1;
21 | git commit -a -m "mlr $(date)"
22 | elif
23 | test -e "./.hg"
24 | then
25 | hg add \
26 | 1>/dev/null \
27 | 2>&1;
28 | hg commit -m "mlr $(date)"
29 | fi
30 | fi
31 | done < "${HOME}/local/var/lib/mlr/repos.txt"
32 |
33 | # vim: set ft=sh :
34 |
--------------------------------------------------------------------------------
/ARCHIVE/mr-update-own.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 | #
3 | # Wrapper: mr update (own repos).
4 |
5 | mr -c "~/.mrconfig-own" -j5 update
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/mr-update.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Wrapper: mr update.
4 |
5 | mr -j 4 update
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/mutt--d630:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: mutt d630.
4 |
5 | LOCAL_CONFIG=d630 exec mutt -n "$@"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/mutt--d630-archive:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: mutt d630.archive.
4 |
5 | LOCAL_CONFIG=d630.archive exec mutt -n "$@"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/mutt--gmail:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: mutt gmail.
4 |
5 | LOCAL_CONFIG=gmail exec mutt -n "$@"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/mutt--gmail-archive:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: mutt gmail.archive.
4 |
5 | LOCAL_CONFIG=gmail.archive exec mutt -n "$@"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/mutt--hotmail:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: mutt hotmail.
4 |
5 | LOCAL_CONFIG=hotmail exec mutt -n "$@"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/mutt--hotmail-archive:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: mutt hotmail.archive.
4 |
5 | LOCAL_CONFIG=hotmail.archive exec mutt -n "$@"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/mutt--posteo:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: mutt posteo.
4 |
5 | LOCAL_CONFIG=posteo exec mutt -n "$@"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/mutt--posteo-archive:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: mutt posteo.archive.
4 |
5 | LOCAL_CONFIG=posteo.archive exec mutt -n "$@"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/mutt--posteo1:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: mutt posteo1.
4 |
5 | LOCAL_CONFIG=posteo1 exec mutt -n "$@"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/mutt--posteo1-archive:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: mutt posteo1.archive.
4 |
5 | LOCAL_CONFIG=posteo1.archive exec mutt -n "$@"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/mutt--spool:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: mutt spool.
4 |
5 | LOCAL_CONFIG=spool exec mutt -n "$@"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/mutt-filter-uri:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Add a bookmark to urimark in mutt.
4 |
5 | grep -oP -e \
6 | '((http|https|gopher|ftp|ftps|webdav|webdavs|dav|davs):(//)?[^ <>"\t]*|(www|ftp)[0-9]?\.[-a-z0-9.]+)[^ .,;\t\n\r<">\):]?[^, <>"\t]*[^ .,;\t\n\r<">\):]' |
7 | while
8 | read -r r
9 | do
10 | taskum add uri":$r"
11 | done
12 |
13 | # vim: set ft=sh :
14 |
--------------------------------------------------------------------------------
/ARCHIVE/newsbeuter2um.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Add a bookmark to urimark in newsbeuter.
4 |
5 | um add uri="$1" name="$2" desc="$3"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/nottoomuchw:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Wrapper for nottoomuch-addresses using dmenu or slmenu.
4 |
5 | if
6 | test-tty 2>/dev/null;
7 | then
8 | function search {
9 | string=$(menu "slmenu" ">" <<< "");
10 | };
11 | else
12 | function search {
13 | string=$(menu "dmenu2" ">" <<< "");
14 | };
15 | fi;
16 |
17 | 'search';
18 | while
19 | [[ -n $string ]];
20 | do
21 | clear;
22 | column -t < <(
23 | nottoomuch-addresses.sh "$string" |
24 | sed -r 's#(.*)()(<.*)#\3\ \1#g' |
25 | sed -r 's/\"//g;s/(<)(.*)(>)/\2/g' |
26 | sort -k 3;
27 | );
28 | 'search';
29 | done;
30 |
31 | # vim: set ft=sh :
32 |
--------------------------------------------------------------------------------
/ARCHIVE/ob-rc.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Build openbox configuration file (poor man's method).
4 |
5 | case $1 in
6 | -c|--cat)
7 | command cat \
8 | <(builtin printf '%s\n' '' '') \
9 | "${XDG_CONFIG_HOME}"/openbox/rc-*.xml \
10 | <(builtin printf '%s\n' '') \
11 | > "${XDG_CONFIG_HOME}/openbox/rc.xml";
12 | ;;
13 | -s|--split)
14 | i=
15 | sections=(
16 | applications
17 | desktops
18 | dock
19 | focus
20 | keyboard
21 | margins
22 | menu
23 | mouse
24 | placement
25 | resistance
26 | resize
27 | theme
28 | )
29 | for i in "${sections[@]}"
30 | do
31 | command sed -n "/<${i}> /,/<\/${i}>/ p" "${XDG_CONFIG_HOME}/openbox/rc.xml" \
32 | > "${XDG_CONFIG_HOME}/openbox/rc-${i}.xml";
33 | done
34 | ;;
35 | *)
36 | printf '%s\n' "Usage: obrc (-c|--cat|-s|--split)" \
37 | 1>&2;
38 | exit 1
39 | esac
40 |
41 | # vim: set ft=sh :
42 |
--------------------------------------------------------------------------------
/ARCHIVE/ob-reload.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Reload openbox.
4 |
5 | openbox --reconfigure
6 | xdotool key Super_L+b
7 |
8 | # vim: set ft=sh :
9 |
--------------------------------------------------------------------------------
/ARCHIVE/ob-update-xdg-menu.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Update root menu of openbox3.
4 |
5 | mkdir -p "${XDG_CACHE_HOME}/openbox"
6 |
7 | echo "
8 |
9 |
10 |
17 |
18 | " \
19 | >> "${XDG_CACHE_HOME}/openbox/xdg-menu.xml";
20 |
21 | sed -i \
22 | -e 's/id=\"/&\/xdg\//' \
23 | -e 's/\/\/\//\//g' \
24 | "${XDG_CACHE_HOME}/openbox/xdg-menu.xml";
25 |
26 | # vim: set ft=sh :
27 |
--------------------------------------------------------------------------------
/ARCHIVE/obnam-weekly:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Weekly backup with obnam.
4 |
5 | exec sudo \
6 | HOME=$HOME \
7 | XDG_CACHE_HOME=$XDG_CACHE_HOME \
8 | obnam_conf=$HOME/.obnam.conf \
9 | sh -c '
10 | obnam backup --config"=$obnam_conf" --lru-size=8192 --upload-queue-size=8192 \
11 | --exclude=/home/latch/tmp \
12 | --exclude=/home/latch/var/mirror \
13 | --exclude=$XDG_CACHE_HOME \
14 | /etc/ \
15 | /home/ \
16 | /root/ \
17 | /var/backups/ \
18 | /var/lib/bitlbee \
19 | /var/mail/ \
20 | /var/sieve/ \
21 | /var/vmail/ \
22 | /var/www/;
23 |
24 | obnam force-lock --config"=$obnam_conf";
25 |
26 | obnam forget --config"=$obnam_conf" --keep=2w;
27 | '
28 |
29 | # vim: set ft=sh :
30 |
--------------------------------------------------------------------------------
/ARCHIVE/ocean:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Simulate ocean sound.
4 | # Source: https://github.com/vain/bin-pub/blob/master/ocean
5 |
6 | exec play -q -n -c 2 \
7 | synth 0 \
8 | noise 100 \
9 | noise 100 \
10 | lowpass 100 \
11 | gain 12 \
12 | tremolo 0.125 80
13 |
14 | # vim: set ft=sh :
15 |
--------------------------------------------------------------------------------
/ARCHIVE/packen.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # tar and gzip $1.
4 |
5 | tar czvf "${1}-$(date +%y%m%d-%H%M%S).tar.gz" "$1"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/passivedns-archive.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # gzip logs of passivedns.
4 |
5 | if
6 | ! test -e "/var/log/passivedns-archive"
7 | then
8 | sudo mkdir -p "/var/log/passivedns-archive"
9 | fi
10 |
11 | if
12 | test -s "/var/log/passivedns.log"
13 | then
14 | sudo mv "/var/log/passivedns.log" "/var/log/passivedns-archive"
15 | sudo gzip -S ".$(date +%Y-%m-%d_%H:%M:%S).gz" "/var/log/passivedns-archive/passivedns.log"
16 | fi
17 |
18 | # vim: set ft=sh :
19 |
--------------------------------------------------------------------------------
/ARCHIVE/passivedns.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Run passivedns.
4 |
5 | sudo passivedns -i wlan0 -l "/var/log/passivedns.log" -D
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/pdf-purge-metadata-recur-with-BecCyPDFMetaEdit.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Remove PDF metadata with BeCyPDFMetaEdit (recur).
4 |
5 | wine "${HOME}/.wine/drive_c/Program Files/BeCyPDFMetaEdit/BeCyPDFMetaEdit.exe" \
6 | "./*.pdf" -s -d 2 -T "" -S "" -A "" -K "" -R "" -P "" -C "" -M "" -X 1 -q;
7 |
8 | # vim: set ft=sh :
9 |
--------------------------------------------------------------------------------
/ARCHIVE/pdf-purge-metadata-with-BecCyPDFMetaEdit.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Run BeCyPDFMetaEdit.
4 |
5 | wine "${HOME}/.wine/drive_c/Program Files/BeCyPDFMetaEdit/BeCyPDFMetaEdit.exe" \
6 | "./*.pdf" -d 2 -T "" -S "" -A "" -K "" -R "" -P "" -C "" -M "" -X 1 -q;
7 |
8 | # vim: set ft=sh :
9 |
--------------------------------------------------------------------------------
/ARCHIVE/pdfxviewer.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Run PDFXCview.
4 |
5 | wine "${HOME}/.wine/drive_c/Program Files/Tracker Software/PDF Viewer/PDFXCview.exe"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/pkg.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Install that pkg.
4 |
5 | set -e
6 |
7 | PKG_BASE="${PKG_BASE:-${HOME}/stow}"
8 | PKG_DEST="${PKG_DEST:-${HOME}}"
9 |
10 | test -d "$PKG_BASE" || {
11 | printf '%s: %s\n' "stow dir missing" "$PKG_BASE" 1>&2;
12 | exit 1
13 | }
14 |
15 | test -d "$PKG_DEST" || {
16 | printf '%s: %s\n' "target dir missing" "$PKG_DEST" 1>&2;
17 | exit 1
18 | }
19 |
20 | for arg
21 | do
22 | case "${arg#-}" in
23 | S)
24 | action=_
25 | readonly action
26 | shift 1
27 | ;;
28 | [DR])
29 | action="$arg"
30 | readonly action
31 | shift 1
32 | ;;
33 | *)
34 | PKG_NAME="$arg"
35 | readonly PKG_NAME
36 | shift 1
37 | esac
38 | done
39 |
40 | : "${PKG_NAME:?pkg name missing}"
41 | : "${action:?action missing}"
42 |
43 | test -d "${PKG_BASE}/${PKG_NAME}" || {
44 | printf '%s: %s\n' "pkg does not exist; no directory found" "${PKG_BASE}/${PKG_NAME}" 1>&2;
45 | exit 1
46 | }
47 |
48 | xstow -v -dir "$PKG_BASE" -target "$PKG_DEST" ${action##*_*} "$PKG_NAME"
49 |
50 | # vim: set ft=sh :
51 |
--------------------------------------------------------------------------------
/ARCHIVE/print-horiz.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Print horizontal line.
4 | # Source: http://wiki.bash-hackers.org/snipplets/print_horizontal_line
5 |
6 | #printf '%*s\n' "${1:-$(tput cols)}" ' ' | tr ' ' -
7 | printf -v horiz '%*s\n%s' "${1:-$(tput cols)}" ''
8 | printf '%s' "${horiz// /-}"
9 | #eval printf %.0s- '{1..'"${1:-$(tput cols)}"\}; echo
10 |
11 | # vim: set ft=sh :
12 |
--------------------------------------------------------------------------------
/ARCHIVE/proxychains-get-random-server.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Get a server ip (random) for proxychains.
4 |
5 | __get()
6 | {
7 | line_number="$(wc -l < ${HOME}/.proxychains/server_list.txt)"
8 | line_random="$(expr "$RANDOM" % "$line_number")"
9 | }
10 |
11 | __select() {
12 | printf '%s\n' "$(
13 | sort -Rr "${HOME}/.proxychains/server_list.txt" \
14 | | head -n"${line_random}" \
15 | | sort -Rr \
16 | | sed -n -e'#^$#d' -e'$p';
17 | )"
18 | }
19 |
20 | __main()
21 | {
22 | if
23 | [ "$line_random" -gt 0 ]
24 | then
25 | __select
26 | else
27 | __get
28 | __main
29 | fi
30 | }
31 |
32 | __get
33 | __main
34 |
35 | # vim: set ft=sh :
36 |
--------------------------------------------------------------------------------
/ARCHIVE/pycalendar:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2
2 | #
3 | # Display calendar.
4 | # Source: https://github.com/vain/bin-pub/blob/master/pycal
5 | # Licence: https://github.com/vain/bin-pub/blob/master/LICENSE
6 |
7 | import gtk
8 | import sys
9 |
10 | dlg = gtk.Dialog('Calendar')
11 | dlg.set_has_separator(False)
12 | dlg.vbox.pack_start(gtk.Calendar())
13 | dlg.show_all()
14 |
15 | if len(sys.argv) >= 2:
16 | _, x, y, _ = gtk.gdk.display_get_default().get_pointer()
17 | w, h = dlg.get_size()
18 | dlg.move(x - w, y - h)
19 |
20 | dlg.run()
21 |
22 | # vim: set ft=python :
23 |
--------------------------------------------------------------------------------
/ARCHIVE/pyrandgen:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | #
3 | # Generate random password.
4 | # Source: https://github.com/vain/bin-pub/blob/master/randgen
5 | # Licence: https://github.com/vain/bin-pub/blob/master/LICENSE
6 |
7 | import string
8 | import random
9 | import sys
10 |
11 | if len(sys.argv) > 1:
12 | numchars = int(sys.argv[1])
13 | else:
14 | numchars = 64
15 |
16 | pool = string.ascii_letters + string.digits
17 | pwd = ''
18 | for i in range(numchars):
19 | pwd += random.choice(pool)
20 |
21 | print(pwd)
22 |
23 | # vim: set ft=python :
24 |
--------------------------------------------------------------------------------
/ARCHIVE/pyrandgen-xsel:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # X-select random password.
4 |
5 | printf "$(pyrandgen)" |
6 | xclip -i -l 1 -selection clipboard
7 |
8 | # vim: set ft=sh :
9 |
--------------------------------------------------------------------------------
/ARCHIVE/ronn2man.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Create manpage from ronn.
4 |
5 | cp -- "$1" "${1%.*}.ronn"
6 | ronn --roff "${1%.*}.ronn"
7 | man -l "${1%.*}.1"
8 |
9 | # vim: set ft=sh :
10 |
--------------------------------------------------------------------------------
/ARCHIVE/run-xstow-home:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # xstow wrapper.
4 |
5 | exec xstow -v 3 \
6 | -F /home/latch/etc/xstow/local.ini \
7 | -dir /home/stow \
8 | -target "$HOME" \
9 | "${@:?package missing}"
10 |
11 | # vim: set ft=sh :
12 |
--------------------------------------------------------------------------------
/ARCHIVE/screenshot-multi:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Take a quick screenshot.
4 |
5 | mkdir -p /tmp/screenshots
6 |
7 | cd /tmp/screenshots ||
8 | exit 1
9 |
10 | exec scrot \
11 | '%Y-%m-%d--%s_$wx$h.png' \
12 | -q 100 \
13 | -m
14 |
15 | # vim: set ft=sh :
16 |
--------------------------------------------------------------------------------
/ARCHIVE/show-ports-opened:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Check open network ports.
4 |
5 | ss --all --numeric --processes --ipv4 --ipv6
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/show-ports-opened2:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Check still open network ports.
4 |
5 | echo
6 | lsof -a +L1 /
7 | echo
8 |
9 | # vim: set ft=sh :
10 |
--------------------------------------------------------------------------------
/ARCHIVE/show-who:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Who.
4 |
5 | echo
6 | uptime
7 | echo
8 | who --all -H
9 | echo
10 | w
11 | echo
12 |
13 | # vim: set ft=sh :
14 |
--------------------------------------------------------------------------------
/ARCHIVE/spotify-stream-gist:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Stream music links from my gist file.
4 |
5 | while
6 | read -r;
7 | do
8 | audio-player "$REPLY";
9 | read -r -t 3 < /dev/tty;
10 | [[ $REPLY == q ]] && exit;
11 | done < <(
12 | curl https://gist.githubusercontent.com/d630/323420bbb1466bcd58925df610ed5fcd/raw/spotify.md |
13 | sed -n 's/^.*(\([^ ]*\))$/\1/p';
14 | );
15 |
16 | # vim: set ft=sh :
17 |
--------------------------------------------------------------------------------
/ARCHIVE/squid-backup-urls.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Backup all uris from squid3 log.
4 |
5 | log="${HOME}/local/var/log/urls.log"
6 |
7 | if
8 | grep -o 'GET .* - HIER_DIRECT' "/var/log/squid3/access.log" \
9 | | cut -d ' ' -f 2 \
10 | | cat "$log" - \
11 | | sort -u > "${log}.$$";
12 | then
13 | mv "${log}.$$" "$log"
14 | fi
15 |
16 | # vim: set ft=sh :
17 |
--------------------------------------------------------------------------------
/ARCHIVE/stjerm-autostart.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Run stjerm.
4 |
5 | stjerm -m windows -k c -ah false -o 100 -w 100% -h 20% -p bottom \
6 | -sh /bin/bash -l 5000 -st never -ub false \
7 | -fn "-*-terminus-medium-*-*-*-14-*-*-*-*-*-iso10646-*" -ab false;
8 |
9 | # vim: set ft=sh :
10 |
--------------------------------------------------------------------------------
/ARCHIVE/stow-data-new:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Set up a new stow-data package.
4 |
5 | set -- "${1:? need a name}" "${2:-$HOSTNAME}" "${3:-$USER}";
6 |
7 | s=$(
8 | IFS=;
9 | md5sum <<< "$*";
10 | );
11 | s=${s%% *};
12 |
13 | . /home/stow-data/map ||
14 | typeset -A map;
15 |
16 | map[$s]=$2/$3/$1;
17 |
18 | mkdir -v /home/stow-data"/$s" ||
19 | exit;
20 |
21 | typeset -p map > /home/stow-data/map;
22 |
23 | chmod 755 /home/stow-data"/$s";
24 | > /home/stow-data"/$s/".gitignore;
25 | ln -vfrs /home/stow-data"/$s" /home/stow-data"/$1";
26 |
27 | typeset -x \
28 | GIT_DIR=/home/stow-data/$s/.git \
29 | GIT_WORK_TREE=/home/stow-data/$s;
30 |
31 | git init;
32 | git add -f .gitignore;
33 | git commit -m I;
34 |
35 | # vim: set ft=sh :
36 |
--------------------------------------------------------------------------------
/ARCHIVE/stow-local.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # xstow wrapper for $HOME.
4 |
5 | xstow -v -t "$HOME" "$@"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/stow-new:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Set up a new stow package.
4 |
5 | set -- "${1:? need a name}" "${2:-$HOSTNAME}" "${3:-$USER}";
6 |
7 | s=$(
8 | IFS=;
9 | md5sum <<< "$*";
10 | );
11 | s=${s%% *};
12 |
13 | . /home/stow/map ||
14 | declare -A map;
15 |
16 | map[$s]=$2/$3/$1;
17 |
18 | mkdir -v "/home/stow/$s" ||
19 | exit;
20 |
21 | mv -v /home/stow/map /home/stow/map~;
22 | declare -p map > /home/stow/map;
23 |
24 | chmod -v 750 "/home/stow/$s";
25 | > "/home/stow/$s/.gitignore";
26 | ln -vfrs "/home/stow/$s" "/home/stow/$1";
27 |
28 | declare -x \
29 | GIT_DIR=/home/stow/$s/.git \
30 | GIT_WORK_TREE=/home/stow/$s;
31 |
32 | git init;
33 | git add -f .gitignore;
34 | git commit -m I;
35 |
36 | # vim: set ft=sh :
37 |
--------------------------------------------------------------------------------
/ARCHIVE/sxiv-browser:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Open all files in the current directory with sxiv.
4 | # source: archlinux wiki
5 |
6 | shopt -s nullglob;
7 |
8 | [[ -f $1 ]] || {
9 | printf '%s: first argument is not a file\n' "$0" 1>&2;
10 | exit 1;
11 | };
12 |
13 | typeset \
14 | file=$(basename -- "$1") \
15 | dir=$(dirname -- "$1");
16 | typeset -a arr=();
17 |
18 | shift 1;
19 |
20 | cd -- "$dir" ||
21 | exit 1;
22 |
23 | for i in *; do
24 | [[ -f $i ]] ||
25 | continue;
26 | arr+=("$i")
27 | [[ $i == "$file" ]] &&
28 | c=$((${#arr[@]} - 1));
29 | done;
30 |
31 | echo exec sxiv -- "${arr[@]:c}" "${arr[@]:0:c}";
32 |
33 | # vim: set ft=sh :
34 |
--------------------------------------------------------------------------------
/ARCHIVE/tcsh--filetest:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env tcsh
2 | #
3 | # Use the filetest builtin command of tcsh.
4 |
5 | filetest $argv[*];
6 |
7 | # vim: set ft=csh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/tcsh--printenv:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env tcsh
2 | #
3 | # Use the printenv builtin command of tcsh.
4 |
5 | printenv $argv[*];
6 |
7 | # vim: set ft=csh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/urldiff-add:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Add to urlwatch and urldiff.
4 |
5 | if
6 | test -n "$1"
7 | then
8 | printf '\n%s\n' URLDIFF
9 | printf %s\\n "$1" >>"${XDG_VAR_HOME:?}/"lib/urldiff/urls.txt &&
10 | tail -n2 "$XDG_VAR_HOME/"lib/urldiff/urls.txt
11 | else
12 | printf 'Es muss eine url angegeben werden ...\n' 1>&2
13 | exit 1
14 | fi
15 |
16 | # vim: set ft=sh :
17 |
--------------------------------------------------------------------------------
/ARCHIVE/urlview2:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Use choose to simulate urlview.
4 | #
5 | # https://github.com/vain/bin-pub/blob/master/choose
6 | # http://www.uninformativ.de/?section=news&ndo=single&newsid=194
7 | # https://github.com/vain/bin-pub/blob/master/urlview2
8 |
9 | while
10 | read -r;
11 | do
12 | if
13 | [[ -n $DISPLAY ]];
14 | then
15 | setsidw x-web-browser "$REPLY";
16 | else
17 | exec web-browser "$REPLY";
18 | fi
19 | done < <(
20 | grep -oP '(((http|https|ftp|gopher)|mailto|file):(//)?[^ <>"\t]*|' \
21 | '(www|ftp)[0-9]?\.[-a-z0-9.]+)[^ .,;\t\n\r<">\):]?[^, <>"\t]*' \
22 | '[^ .,;\t\n\r<">\):]' "$@" |
23 | menu choose;
24 | );
25 |
26 | # vim: set ft=sh :
27 |
--------------------------------------------------------------------------------
/ARCHIVE/vfh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Preview files in a directory like in vifm.
4 |
5 | ls -1a "${1:-$PWD}" |
6 | xib -- less -R
7 |
8 | # vim: set ft=sh :
9 |
--------------------------------------------------------------------------------
/ARCHIVE/wetter:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Get infos from http://wetter.tagesschau.de.
4 |
5 | case $1 in
6 | -d)
7 | uri=http://wetter.tagesschau.de/deutschland/wetterstationen/
8 | ;;
9 | -w)
10 | uri=http://wetter.tagesschau.de/europawelt/
11 | ;;
12 | *)
13 | printf 'argument?\n' 1>&2
14 | exit 1
15 | ;;
16 | esac
17 |
18 | curl -s "$uri" |
19 | scrape -be table |
20 | w3m -dump -T text/html
21 |
22 | # vim: set ft=sh :
23 |
--------------------------------------------------------------------------------
/ARCHIVE/xombrero-open-url-run.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Run script for xombrero-open-url.sh.
4 |
5 | daemonize.sh terminal.sh -e -sh -c "xombrero-open-url.sh;exec ${SHELL}"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/xombrero-open-url-tab-run.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Run script for xombrero-open-url-tab.sh.
4 |
5 | daemonize.sh terminal.sh -e sh -c "xombrero-open-url-tab.sh; exec ${SHELL}"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/xombrero-open-url-tab.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Select url with menu and open it in a new tab in xombrero.
4 |
5 | count="$(pgrep -c xombrero)"
6 |
7 | file_uris="${HOME}/local/var/log//urls.log"
8 | uri="$(
9 | grep -oP -e '((http|https|gopher|ftp|ftps|webdav|webdavs|dav|davs):(//)?[^ <>"\t]*|(www|ftp)[0-9]?\.[-a-z0-9.]+)[^ .,;\t\n\r<">\):]?[^, <>"\t]*[^ .,;\t\n\r<">\):]' "$file_uris" \
10 | | menu.sh "dmenu2" ">";
11 | )"
12 |
13 | test -n "$uri" || exit 1;
14 |
15 | if
16 | [ "$count" -eq 0 ]
17 | then
18 | setsid.sh xombrero "$uri"
19 | else
20 | xombrero -n "$uri"
21 | fi
22 |
23 | # vim: set ft=sh :
24 |
--------------------------------------------------------------------------------
/ARCHIVE/xombrero-open-url.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Select url with menu and open it in current tab in xombrero.
4 |
5 | count="$(pgrep -c xombrero)"
6 |
7 | file_uris="${HOME}/local/var/log/urls.log"
8 | uri="$(
9 | grep -oP -e '((http|https|gopher|ftp|ftps|webdav|webdavs|dav|davs):(//)?[^ <>"\t]*|(www|ftp)[0-9]?\.[-a-z0-9.]+)[^ .,;\t\n\r<">\):]?[^, <>"\t]*[^ .,;\t\n\r<">\):]' "$file_uris" \
10 | | menu.sh "dmenu2" ">";
11 | )"
12 |
13 | test -n "$uri" || exit 1;
14 |
15 | if
16 | [ "$count" -eq 0 ]
17 | then
18 | setsid.sh xombrero "$uri"
19 | else
20 | xombrero -e "open $uri"
21 | fi
22 |
23 | # vim: set ft=sh :
24 |
--------------------------------------------------------------------------------
/ARCHIVE/xorg-autolock-old:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default xautolock program.
4 |
5 | exec daemonize xautolock \
6 | -detectsleep \
7 | -time 60 \
8 | -locker "$XDG_BIN_HOME/xorg-lock" \
9 | -nowlocker "$XDG_BIN_HOME/xorg-lock" \
10 | -notify 60 \
11 | -notifier "loggi 3 .misc.exlamation 'Screen is going to be locked'"
12 |
13 | # vim: set ft=sh :
14 |
--------------------------------------------------------------------------------
/ARCHIVE/xorg-dpms-standby:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Set DPMS to standby state.
4 |
5 | sleep 1
6 | xset dpms force standby
7 |
8 | # vim: set ft=sh :
9 |
--------------------------------------------------------------------------------
/ARCHIVE/xorg-export-xinfo:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Export the dbus session address on startup so it can be used by cron.
4 | # Based on: http://dev.gentoo.org/~tomka/mail.html
5 | #
6 | # other methode : source "${HOME}/.dbus/session-bus/$(dbus-uuidgen --get)"
7 |
8 | spool_dir=${XDG_VAR_HOME}/spool;
9 |
10 | > "${spool_dir}/xdbus";
11 | chmod 600 "${spool_dir}/xdbus";
12 |
13 | env \
14 | | grep DBUS_SESSION_BUS_ADDRESS >> "${spool_dir}/xdbus";
15 |
16 | printf '%s\n' "export DBUS_SESSION_BUS_ADDRESS" >> "${spool_dir}/xdbus";
17 |
18 | # vim: set ft=sh :
19 |
--------------------------------------------------------------------------------
/ARCHIVE/xorg-lock-old:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default xlock program.
4 |
5 | case $1 in
6 | enable | disable)
7 | xautolock "-$1"
8 | exit
9 | ;;
10 | esac
11 |
12 | t() {
13 | xset -dpms
14 | s
15 | }
16 |
17 | s() {
18 | test "${X_DPI:-96}" -eq 96 ||
19 | return
20 |
21 | spotify-mpris PlayPause
22 | mpc toogle
23 | } 2>/dev/null
24 |
25 | trap t INT TERM QUIT EXIT HUP
26 | xset +dpms dpms 3 3 3
27 | s
28 | i3lock \
29 | --nofork \
30 | --image="$XDG_DATA_HOME/wallpapers/current.wallpaper" \
31 | --no-unlock-indicator \
32 | --show-failed-attempts \
33 | --tiling
34 |
35 | # vim: set ft=sh :
36 |
--------------------------------------------------------------------------------
/ARCHIVE/xorg-rename-current-desktop:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # rename current desktop; manipulate _NET_DESKTOP_NAMES.
4 |
5 | read -r _ _ desk_current < <(xprop -root _NET_CURRENT_DESKTOP);
6 |
7 | xorg-set-desktop-name "$desk_current" "$(menu "dmenu2" ">" 0<&-)";
8 |
9 | # vim: set ft=sh :
10 |
--------------------------------------------------------------------------------
/ARCHIVE/xorg-set-desktop-name:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2
2 | #
3 | # Helper for setting current desktop's name
4 | # http://superuser.com/questions/508128/is-it-possible-to-set-the-name-of-the-current-virtual-desktop-via-commandline
5 |
6 | import sys
7 |
8 | from xpybutil import conn, root
9 |
10 | import xpybutil.ewmh as ewmh
11 |
12 | if len(sys.argv) == 2 and sys.argv[1] == '--help':
13 | print "Usage: "
14 | print " set_desktop_name NAME_OF_NEW_DESKTOP - sets current desktop name"
15 | print " set_desktop_name NR NAME_OF_NEW_DESKTOP - sets name of NRth desktop"
16 |
17 | if len(sys.argv) > 2:
18 | desktop_offset = int(sys.argv[1])
19 | new_name = sys.argv[2]
20 |
21 | else:
22 | desktop_offset = ewmh.get_current_desktop().reply()
23 | new_name = sys.argv[1]
24 |
25 | current_names = ewmh.get_desktop_names().reply()
26 |
27 | current_names[desktop_offset] = new_name
28 |
29 | # Not sure why I have to do it twice - somehow
30 | # doesn't work if I only call it once
31 | c = ewmh.set_desktop_names(current_names)
32 | c = ewmh.set_desktop_names(current_names)
33 |
34 | # vim: set ft=python :
35 |
--------------------------------------------------------------------------------
/ARCHIVE/xorg-switch-keyboard-layout:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Switch keyboard layout and take the necessary actions.
4 | # and do not use 'setxkbmap -option grp:alt_shift_toggle'.
5 |
6 | if
7 | xkblayout-state set +1
8 | then
9 | layout="$(xkblayout-state print "%s-%e")"
10 | # case "$X_XCLIENT" in
11 | # openbox)
12 | # for i in "${XDG_CONFIG_HOME}/openbox/${layout}"/*
13 | # do
14 | # ln -vsrf "$i" -t "${XDG_CONFIG_HOME}/openbox"
15 | # done
16 | # xdotool key Super_L+q && sleep 1 && xdotool key Super_L+b
17 | # ln -vsrf "${XDG_CONFIG_HOME}/xbindkeys/${layout}/xbindkeysrc_ob" \
18 | # "${XDG_CONFIG_HOME}/xbindkeys/xbindkeysrc";
19 | # return 0
20 | # ;;
21 | # bspwm|cwm|spectrwm|x-terminal-tabbed)
22 | # :
23 | # ;;
24 | # *)
25 | # X_XCLIENT=fallback
26 | # esac
27 | ln -vsrf "${XDG_CONFIG_HOME}/sxhkd/${layout}/sxhkdrc_${X_XCLIENT}" \
28 | "${XDG_CONFIG_HOME}/sxhkd/sxhkdrc";
29 | fi
30 |
31 | # vim: set ft=sh :
32 |
--------------------------------------------------------------------------------
/ARCHIVE/xorg-touchpad:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Xorg: Disable or enable touchpad.
4 |
5 | exec xinput --"${1:?}" "ETPS/2 Elantech Touchpad"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/xorg-uniconify-all-xwins.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Unhide all xwindows on current desktop, and the active region of xwinreg.
4 |
5 | xwinreg-unhide-active-region.sh
6 |
7 | get-xids.sh \
8 | | xwinpp -I - --hidden --desk=curr -p \
9 | | xwinmo - -U;
10 |
11 | # vim: set ft=sh :
12 |
--------------------------------------------------------------------------------
/ARCHIVE/xtermj1.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # Use xterm like kuake and yeahconsole terminal.
4 | # Source: https://wiki.archlinux.org/index.php/ \
5 | # Urxvt#Improved_Kuake-like_behavior_in_Openbox
6 |
7 | id="$(cat /tmp/xtermj1)"
8 |
9 | if
10 | test -n "$id" && xprop -id "0x${id}" 1>/dev/null 2>&1;
11 | then
12 | if
13 | xprop -root _NET_CLIENT_LIST \
14 | | fgrep -q "0x${id}";
15 | then
16 | xdotool windowunmap "0x${id}"
17 | else
18 | wmctrl -i -a "0x${id}"
19 | fi
20 | else
21 | (
22 | exec xterm -b 4 -name xtermj1 \
23 | -e sh -c "printf '%x\n' \${WINDOWID} >/tmp/xtermj1;bash" &
24 | )
25 | fi
26 |
27 | # vim: set ft=sh :
28 |
--------------------------------------------------------------------------------
/ARCHIVE/xwinreg-close-active-region.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # xwinreg-close-active-region.sh
4 |
5 | xwinreg close -r active
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/xwinreg-cycle-anticlock.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # xwinreg-cycle-anticlock.sh
4 |
5 | xwinreg cycle -w -r any -d aclock
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/xwinreg-cycle-clock.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # xwinreg-cycle-clock.sh
4 |
5 | xwinreg cycle -w -r any -d clock
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/xwinreg-cycle-reg-clock.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # xwinreg-cycle-reg-clock.sh
4 |
5 | xwinreg cycle -d clock -k
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/xwinreg-cycle-reverse.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # xwinreg-cycle-reverse.sh
4 |
5 | xwinreg cycle -w -r any -d rev
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/xwinreg-focus-active-region.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # xwinreg-focus-active-region.sh
4 |
5 | xwinreg -f -r active
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/xwinreg-focus-toggle-next.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # xwinreg-focus-toggle-next.sh
4 |
5 | xwinreg focus-toggle -d next
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/xwinreg-focus-toggle-prev.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # xwinreg-focus-toggle-prev.sh
4 |
5 | xwinreg focus-toggle -d prev
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/xwinreg-grid-horizontal.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # xwinreg-grid-horizontal.sh
4 |
5 | xorg-get-xids.sh \
6 | | xwinpp print -I - --visible -P 0 \
7 | | xwinreg -I - -L 1,max,grid-horiz,alias:0,all;
8 |
9 | # vim: set ft=sh :
10 |
--------------------------------------------------------------------------------
/ARCHIVE/xwinreg-grid-square-horizontal.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # xwinreg-grid-square-horizontal.sh
4 |
5 | get-xids.sh \
6 | | xwinpp print -I - --visible -P 0 \
7 | | xwinreg -I - -L 1,max,grid-square-horiz,alias:0,all;
8 |
9 | # vim: set ft=sh :
10 |
--------------------------------------------------------------------------------
/ARCHIVE/xwinreg-grid-square-vertical.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # xwinreg-grid-square-vertical.sh
4 |
5 | xorg-get-xids.sh \
6 | | xwinpp print -I - --visible -P 0 \
7 | | xwinreg -I - -L 1,max,grid-square-verti,alias:0,all;
8 |
9 | # vim: set ft=sh :
10 |
--------------------------------------------------------------------------------
/ARCHIVE/xwinreg-grid-vertical.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # xwinreg-grid-vertical.sh
4 |
5 | xorg-get-xids.sh \
6 | | xwinpp print --visible -P 0 \
7 | | xwinreg -I - -L 1,max,grid-verti,alias:0,all;
8 |
9 | # vim: set ft=sh :
10 |
--------------------------------------------------------------------------------
/ARCHIVE/xwinreg-hide-active-region.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # xwinreg-hide-active-region.sh
4 |
5 | xwinreg hide -r active -A add
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/xwinreg-loop.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Do layouting dynamically (xev).
4 |
5 | win_active=
6 | win_active_old=
7 |
8 | while
9 | xev -root -event property \
10 | | grep -q "(_NET_CLIENT_LIST).*state PropertyNewValue";
11 | do
12 | read -r _ _ _ _ win_active < <(
13 | xprop -root -notype _NET_ACTIVE_WINDOW
14 | )
15 | if
16 | [[
17 | $(xprop -id "$win_active" WM_CLASS) =~ xtermj[12] ||
18 | $(xprop -id "${win_active_old:-${win_active}}" WM_CLASS) =~ xtermj[12]
19 | ]]
20 | then
21 | :
22 | else
23 | if
24 | source "${XWINREG_TMP_FILE:-${TMPDIR:-/tmp}/xwinreg_default.tmp}"
25 | then
26 | if
27 | get-xids.sh \
28 | | xwinpp print -I - --visible -D curr \
29 | | ! xwinreg ${_xwinreg_options[command]};
30 | then
31 | source <(
32 | get-xids.sh \
33 | | xwinpp print -I - --visible -D curr -P 0;
34 | )
35 | wmctrl -i -r "$_xwinpp_win_xid" -b "add,maximized_vert,maximized_horz"
36 | fi
37 | else
38 | get-xids.sh \
39 | | xwinpp print -I - --visible -D curr -P end
40 | | xwinreg -I - -L 1,1,maxi,alias:0,west -L 2,max,horiz,alias:0,east;
41 | fi
42 | fi
43 | win_active_old=$win_active
44 | done 2>/dev/null
45 |
46 | # vim: set ft=sh :
47 |
--------------------------------------------------------------------------------
/ARCHIVE/xwinreg-loop2.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Do layouting dynamically (xprop -spy -root).
4 |
5 | win_active=
6 | win_active_old=
7 | xids=
8 |
9 | xprop -spy -root _NET_CLIENT_LIST \
10 | | {
11 | while
12 | read -r _ _ _ _ xids
13 | do
14 | read -r _ _ _ _ win_active < <(
15 | xprop -root _NET_ACTIVE_WINDOW
16 | )
17 | if
18 | [[
19 | $(xprop -id "$win_active" WM_CLASS) =~ xtermj[12] ||
20 | $(xprop -id "${win_active_old:-${win_active}}" WM_CLASS) =~ xtermj[12]
21 | ]]
22 | then
23 | :
24 | else
25 | if
26 | source "${XWINREG_TMP_FILE:-${TMPDIR:-/tmp}/xwinreg_default.tmp}"
27 | then
28 | if
29 | printf '%s\n' ${xids//,/} \
30 | | xwinpp print -I - --visible -D curr \
31 | | ! xwinreg ${_xwinreg_options[command]};
32 | then
33 | source <(
34 | printf '%s\n' ${xids//,/} \
35 | | xwinpp print -I - --visible -D curr -P 0;
36 | )
37 | wmctrl -i -r "$_xwinpp_win_xid" -b "add,maximized_vert,maximized_horz"
38 | }
39 | else
40 | printf '%s\n' ${xids//,/} \
41 | | xwinpp print -I - --visible -D curr -P end \
42 | | xwinreg -I - -L 1,1,maxi,alias:0,west -L 2,max,horiz,alias:0,east;
43 | fi
44 | fi
45 | win_active_old=$win_active
46 | done 2>/dev/null
47 | }
48 |
49 | # vim: set ft=sh :
50 |
--------------------------------------------------------------------------------
/ARCHIVE/xwinreg-master-east.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # xwinreg-master-east.sh
4 |
5 | xorg-get-xids.sh \
6 | | xwinpp print -I - --visible -P 0 \
7 | | xwinreg -I - -L 1,1,maxi,alias:0,east -L 2,max,horiz,alias:0,west;
8 |
9 | # vim: set ft=sh :
10 |
--------------------------------------------------------------------------------
/ARCHIVE/xwinreg-master-north.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # xwinreg-master-north.sh
4 |
5 | xorg-get-xids.sh \
6 | | xwinpp print -I - --visible -P 0 \
7 | | xwinreg -I - -L 1,1,maxi,alias:0,north -L 2,max,verti,alias:0,south;
8 |
9 | # vim: set ft=sh :
10 |
--------------------------------------------------------------------------------
/ARCHIVE/xwinreg-master-south.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # xwinreg-master-south.sh
4 |
5 | xorg-get-xids.sh \
6 | | xwinpp print -I - --visible -P 0 \
7 | | xwinreg -I - -L 1,1,maxi,alias:0,south -L 2,max,verti,alias:0,north;
8 |
9 | # vim: set ft=sh :
10 |
--------------------------------------------------------------------------------
/ARCHIVE/xwinreg-master-west.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # xwinreg-master-west.sh
4 |
5 | xorg-get-xids.sh \
6 | | xwinpp print -I - --visible -P 0 \
7 | | xwinreg -I - -L 1,1,maxi,alias:0,west -L 2,max,horiz,alias:0,east;
8 |
9 | # vim: set ft=sh :
10 |
--------------------------------------------------------------------------------
/ARCHIVE/xwinreg-maximize-all.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # xwinreg-maximize-all.sh
4 |
5 | xorg-get-xids.sh \
6 | | xwinpp print -I - --visible -P 0 \
7 | | xwinreg -I - -L 1,max,maxi,alias:0,all;
8 |
9 | # vim: set ft=sh :
10 |
--------------------------------------------------------------------------------
/ARCHIVE/xwinreg-unhide-active-region.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dash
2 | #
3 | # xwinreg-unhide-active-region.sh
4 |
5 | xwinreg hide -r active -A remove
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/ARCHIVE/zettelkasten:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run Zettelkasten.
4 | #
5 |
6 | java -jar /opt/java/Zettelkasten.jar
7 |
8 | # vim: set ft=sh :
9 |
--------------------------------------------------------------------------------
/audio-player:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default audio player (cli).
4 |
5 | IFS=\|
6 | set -f &&
7 | set -- $AUDIO_PLAYER_OPTS ${1:+"$@"} &&
8 | exec "$AUDIO_PLAYER" "$@"
9 |
10 | # vim: set ft=sh :
11 |
--------------------------------------------------------------------------------
/backup-meta:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Backup my system.
4 | #
5 | # Commands:
6 | # - prepare | pp
7 |
8 | backup_dir=${XDG_BACKUP_HOME:?}
9 |
10 | [[ -d $backup_dir ]] ||
11 | exit 1
12 |
13 | printf -v horiz %80s
14 | .hd() {
15 | printf '%s\n' "${horiz// /-}" "$1" "${horiz// /-}" 1>&2
16 | }
17 |
18 | apt() (
19 | .hd apt
20 |
21 | command -- sudo rm -rv -- "$backup_dir/pkgs"
22 | command -- mkdir -pv -- "$backup_dir/pkgs"
23 |
24 | cd -- "$backup_dir/pkgs" ||
25 | exit 1
26 |
27 | COLUMNS=200 command -- dpkg-query -l >./query.txt
28 | exec -- sudo sh -c '
29 | command -- apt-cache policy >./cache.txt
30 | command -- apt-mark showauto >./auto.txt
31 | command -- apt-mark showmanual >./manual.txt
32 | # command -- cp -v /etc/apt/trusted.gpg ./trusted.gpg
33 | exec apt-clone clone .
34 | '
35 | )
36 |
37 | bin() (
38 | .hd bin
39 |
40 | exec -- find /var/lib/dpkg/info/ \
41 | -daystart \( -name \*.list -a -mtime -7 \) \
42 | -printf '%f\n' |
43 | exec -- sed 's:.list$::' |
44 | command -- sort >"$backup_dir/7_days.txt"
45 |
46 | IFS=:
47 | set -f
48 |
49 | exec -- whatis -w \* $PATH /usr/bin/X11 2>&1 |
50 | exec -- sort -u >"$backup_dir/whatis.txt"
51 | )
52 |
53 | # init() (
54 | # .hd init
55 |
56 | # {
57 | # command -- find /etc/init.d/ -perm /111 -type f -printf '%f\n'
58 | # exec -- find /etc/init -type f -printf '%f\n'
59 | # } |
60 | # exec -- sort -u >"$backup_dir/init.txt"
61 | # )
62 |
63 | cclean() (
64 | .hd cclean
65 |
66 | exec -- cclean
67 | )
68 |
69 | etckeeper() (
70 | .hd etckeeper
71 |
72 | cd / ||
73 | exit 1
74 |
75 | printf -v d %\(%s\)T -1
76 | exec -- sudo etckeeper commit "$d prepare backup"
77 | )
78 |
79 | case $1 in
80 | prepare | pp)
81 | apt
82 | bin
83 | cclean
84 | etckeeper
85 | ;;
86 | esac
87 |
88 | # vim: set ft=zsh :
89 |
--------------------------------------------------------------------------------
/bash-count-occurence:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Count most used commands from bash history.
4 |
5 | exec cut -d ' ' -f 1 -- "${HISTFILE:?}" |
6 | exec sort |
7 | exec uniq -c |
8 | command -- sort -nr
9 |
10 | # vim: set ft=sh :
11 |
--------------------------------------------------------------------------------
/bash-dedup-history:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Remove duplicates from bash history and rewrite file.
4 |
5 | exec sed -e 's:^[[:space:][:cntrl:]]*::; s:[[:space:][:cntrl:]]*$::' -- "${HISTFILE:?}" |
6 | exec nl |
7 | exec sort -u -k 2 |
8 | exec sort -n |
9 | command -- cut -f 2 >"$HISTFILE.$$"
10 |
11 | test -s "$HISTFILE.$$" &&
12 | exec mv -- "$HISTFILE.$$" "$HISTFILE"
13 |
14 | # vim: set ft=sh :
15 |
--------------------------------------------------------------------------------
/binary2nibble:
--------------------------------------------------------------------------------
1 | #!/usr/bin/gawk -f
2 | #
3 | # Group binary numbers into nibbles (used with bc output).
4 |
5 | BEGIN {
6 | FPAT = "...."
7 | }
8 |
9 | {
10 | while (length%4)
11 | $0 = 0$0
12 |
13 | $1 = $1
14 | print $0
15 | }
16 |
17 | # vim: set ft=awk :
18 |
--------------------------------------------------------------------------------
/bitbucket-rest-api:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: Bitbucket REST API.
4 |
5 | . "$(command -v -- rest-api)" ||
6 | exit
7 |
8 | server_address=${BITBUCKET_SERVER_ADDRESS:-https://bitbucket.wir.invalid}
9 | token=${BITBUCKET_REST_TOKEN:-$(exec cat -- "$HOME/.bitbucket-wir-invalid-read-read-token")}
10 | user=${BITBUCKET_REST_USER:-d630}
11 |
12 | unset -v \
13 | BITBUCKET_REST_TOKEN \
14 | BITBUCKET_REST_USER \
15 | BITBUCKET_SERVER_ADDRESS
16 |
17 | curl() {
18 | exec curl -v -s \
19 | --user "$user:$token" \
20 | -X "$(echo "$method" | exec tr '[:lower:]' '[:upper:]')" \
21 | "$server_address$endpoint" \
22 | ${1:+"$@"}
23 | }
24 |
25 | get() {
26 | case $endpoint in
27 | projects | repos | users)
28 | endpoint=/rest/api/latest/$endpoint?limit=999
29 | ;;
30 | esac
31 |
32 | \curl
33 | }
34 |
35 | \main "$@"
36 |
37 | # vim: set ft=sh noexpandtab :
38 |
--------------------------------------------------------------------------------
/bspot-create-featured-lists:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Take pub list1 and create audio-featured public lists.
4 |
5 | token=${1:?}
6 | file=${2:-${XDG_VAR_HOME:?}/lib/bspot/bspot_create_featured_list.sh}
7 |
8 | . "$file" ||
9 | exit 1
10 |
11 | _list1=/tmp/$list1.json
12 |
13 | exec -- bspot getTracks "$list1" "$token" |
14 | exec -- cut -d : -f 3 |
15 | command -- bspot getTracksFeatures "$token" >"$_list1"
16 |
17 | for f in "${!Features[@]}"; do
18 | command -- bspot clearList "${Features[$f]}" "$token"
19 | exec -- jq -r ".audio_features[] | [.$f, .uri] | @tsv" "$_list1" |
20 | LC_ALL=C exec -- sort -k 1gr,1gr -k 2d,2d |
21 | exec -- cut -f 2 |
22 | command -- bspot addTracks "${Features[$f]}" "$token"
23 | done
24 |
25 | # vim: set ft=zsh :
26 |
--------------------------------------------------------------------------------
/bspot-create-gpb-lists:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Take pub list1 and create public gpb lists.
4 |
5 | token=${1:?}
6 | file=${2:-${XDG_VAR_HOME:?}/lib/bspot/bspot_create_gpb_lists.bash}
7 |
8 | # wants:
9 | # -A dates[%s|playlist-id]
10 | # -a dates_sorted (newest first)
11 | # list1
12 | . "$file" ||
13 | exit 1
14 |
15 | while read -r time uri; do
16 | for d in "${dates_sorted[@]}"; do
17 | ((time >= ${d%|*})) &&
18 | dates[$d]+=$uri, &&
19 | break
20 | done
21 | done < <(
22 | exec -- bspot getTracksObjects "$list1" "$token" |
23 | exec -- jq -r '
24 | .items[] |
25 | "date --date=\(.added_at) +%s_\(([.track.artists[].uri]|join("/")))_\(.track.uri)"
26 | ' |
27 | exec -- xargs -I {} -P 4 -- sh -c {} |
28 | LC_ALL=C exec -- sort -t _ -k 1nr,1nr -k 2d,2d |
29 | exec -- sed 's/^\([^_]*\)_\([^_]*\)_\([^_]*\)$/\1 \3/'
30 | )
31 |
32 | for k in "${!dates[@]}"; do
33 | list2=${k#*|}
34 | [[ $list2 == END ]] &&
35 | continue
36 | mapfile -t -d , <<<"${dates[$k]}"
37 | command -- bspot clearList "$list2" "$token"
38 | for ((i = ${#MAPFILE[@]} - 2; i >= 0; i--)); do
39 | printf '%s\n' "${MAPFILE[$i]}"
40 | done |
41 | command -- bspot addTracks "$list2" "$token"
42 | done
43 |
44 | # vim: set ft=zsh :
45 |
--------------------------------------------------------------------------------
/bspot-create-label:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Take pub list1 and sort it by label.
4 |
5 | list1=${1:?}
6 | list2=${2:?}
7 | token=${3:?}
8 |
9 | command -- bspot clearList "$list2" "$token"
10 |
11 | command -- bspot getAlbums "$list1" "$token" >/tmp/bspot_albums.txt
12 | exec cut -f 1 /tmp/bspot_albums.txt |
13 | exec cut -d : -f 3 |
14 | exec bspot getAlbumsObjects "$token" |
15 | command -- jq -e -r '.albums[].label | [.] | @sh' >/tmp/bspot_labels.txt
16 |
17 | test -s /tmp/bspot_albums.txt && test -s /tmp/bspot_labels.txt &&
18 | exec paste /tmp/bspot_albums.txt /tmp/bspot_labels.txt |
19 | LC_ALL=C exec sort -k 3df,3df -k 1d,1d -k 2d,2d |
20 | exec cut -f 2 |
21 | command -- bspot addTracks "$list2" "$token"
22 |
23 | # vim: set ft=sh :
24 |
--------------------------------------------------------------------------------
/bspot-create-not-playable:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Take pub list1 and create a list with unplayable tracks.
4 |
5 | list1=${1:?}
6 | list2=${2:?}
7 | token=${3:?}
8 | market=${4:-DE}
9 |
10 | list=/tmp/$list1.json
11 |
12 | command -- bspot getTracksInMarket "$list1" "$token" "$market" >"$list"
13 |
14 | command -- bspot clearList "$list2" "$token"
15 |
16 | exec jq -e -r '.items[] | if .track.is_playable then empty else .track.uri end' "$list" |
17 | command -- bspot addTracks "$list2" "$token"
18 |
19 | # vim: set ft=sh :
20 |
--------------------------------------------------------------------------------
/bspot-create-release-date:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Take pub list1 and sort it by release_date.
4 |
5 | list1=${1:?}
6 | list2=${2:?}
7 | token=${3:?}
8 |
9 | command -- bspot clearList "$list2" "$token"
10 |
11 | command -- bspot getAlbums "$list1" "$token" >/tmp/bspot_albums.txt
12 |
13 | exec cut -f 1 /tmp/bspot_albums.txt |
14 | exec cut -d : -f 3 |
15 | exec bspot getAlbumsObjects "$token" |
16 | command -- jq -e -r '.albums[].release_date' >/tmp/bspot_labels.txt
17 |
18 | test -s /tmp/bspot_albums.txt && test -s /tmp/bspot_labels.txt &&
19 | exec paste /tmp/bspot_albums.txt /tmp/bspot_labels.txt |
20 | LC_ALL=C exec sort -k 3d,3d -k 1d,1d -k 2d,2d |
21 | exec cut -f 2 |
22 | command -- bspot addTracks "$list2" "$token"
23 |
24 | # vim: set ft=sh :
25 |
--------------------------------------------------------------------------------
/bspot-get-tracks:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Get track info of a public playlist.
4 |
5 | list=${1:?}
6 | token=${2:?}
7 |
8 | command -- bspot getTracksObjects "$list" "$token" >"/tmp/$list.json"
9 |
10 | exec jq -e -c '
11 | .items[] |
12 | [
13 | ([.track.artists[].name] | join(" / ") ),
14 | .track.name, .track.track_number,
15 | .track.disc_number,
16 | .track.album.name,
17 | .track.duration_ms,
18 | .track.uri,
19 | .added_at
20 | ]
21 | ' "/tmp/$list.json" |
22 | LC_ALL=en_US.UTF-8 command -- sort
23 |
24 | # vim: set ft=sh :
25 |
--------------------------------------------------------------------------------
/bspot-shuffle-list:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Take pub list1, shuffle it and add the songs to cleared pub list2.
4 |
5 | list1=${1:?}
6 | list2=${2:?}
7 | token=${3:?}
8 |
9 | command -- bspot clearList "$list2" "$token"
10 |
11 | exec bspot getTracks "$list1" "$token" |
12 | exec shuf |
13 | command -- bspot addTracks "$list2" "$token"
14 |
15 | # vim: set ft=sh :
16 |
--------------------------------------------------------------------------------
/cclean:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Clean up some dirs and files.
4 |
5 | command -- rm -frv -- \
6 | "${HOME:?}/.adobe" \
7 | "$HOME/.gconf" \
8 | "$HOME/.git-credential-cache" \
9 | "$HOME/.gnome2" \
10 | "$HOME/.gnome2_private" \
11 | "$HOME/.icedteaplugin" \
12 | "$HOME/.macromedia" \
13 | "$HOME/.thumbnails" \
14 | "$HOME/.vifm/Trash/"* \
15 | "$XDG_CONFIG_HOME/freshwrapper-data" \
16 | "$XDG_DATA_HOME/webkit" \
17 | "${XDG_CONFIG_HOME:?}/cef_user_data" \
18 | "${XDG_DATA_HOME:?}/gegl-0.3"
19 |
20 | exec rm -fv -- \
21 | "$HOME/.gksu.lock" \
22 | "$XDG_CONFIG_HOME/newsboat/newsboat_cache.db" \
23 | "$HOME/.recentf" \
24 | "$HOME/.recently-used" \
25 | "$XDG_DATA_HOME/recently-used.xbel"
26 |
27 | # vim: set ft=sh :
28 |
--------------------------------------------------------------------------------
/checkout-all-wir-bare-repos:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Turn all downloaded wir bare git repositories into normal repos.
4 |
5 | src=${1:-$HOME/src/wir}
6 |
7 | exec find -H "$src" \
8 | -mindepth 2 \
9 | -maxdepth 2 \
10 | -type d \
11 | -print0 |
12 | command -- xargs -0 -n 1 -P 0 -- sh -c '
13 | test -d "$1/.git" ||
14 | exit 1
15 |
16 | export \
17 | GIT_DIR \
18 | GIT_WORK_TREE;
19 | GIT_WORK_TREE=$1
20 | GIT_DIR=$1/.git
21 |
22 | eval "$(exec git config --local --get --bool core.bare)" ||
23 | exit 0
24 |
25 | command -- git config --local core.bare false
26 | command -- git config --local remote.origin.mirror false
27 | command -- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
28 |
29 | command -- git fetch origin
30 |
31 | head=$(exec git symbolic-ref --short HEAD)
32 |
33 | command -- git branch --set-upstream-to="origin/$head" "$head"
34 |
35 | command -- git checkout "$head"
36 |
37 | command -- git submodule sync --recursive
38 | exec git submodule update --init --recursive --jobs 12
39 | ' --
40 |
41 | # vim: set ft=sh :
42 |
--------------------------------------------------------------------------------
/chromium-history:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Browse the history of chromium via fzf, and then open selection.
4 | #
5 | # See: https://github.com/junegunn/fzf/wiki/Examples#browsing-history
6 |
7 | cols=$(($(exec tput cols) / 3))
8 | sep={{::}}
9 |
10 | command -- cp -f -- "${XDG_CACHE_HOME:?}/run-chromium/Default/History" "$XDG_CACHE_HOME/h.chromium"
11 |
12 | __sqlite() {
13 | exec sqlite3 -separator "$sep" "$XDG_CACHE_HOME/h.chromium" "
14 | select substr(title, 1, $cols), url
15 | from urls
16 | order by last_visit_time desc"
17 | }
18 |
19 | __awk() {
20 | exec gawk -F "$sep" '{ printf "%-'$cols's \x1b[36m%s\n", $1, $2 }'
21 | }
22 |
23 | __chromium() {
24 | while IFS='' read -r REPLY; do
25 | command -- daemonize run-chromium "$REPLY"
26 | done
27 | }
28 |
29 | __sqlite |
30 | __awk |
31 | exec fzf --ansi --multi |
32 | exec sed 's#.*\(https*://\)#\1#' |
33 | __chromium
34 |
35 | # vim: set ft=sh :
36 |
--------------------------------------------------------------------------------
/compose-my-confluence-how-to-article:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Compose my confluence how-to article in vim.
4 |
5 | set -e
6 |
7 | title=${1:?title missing}
8 | shift 1
9 | : "${1:?keyword missing}"
10 | keyword_list=$(printf -- '- %s\n' "$@")
11 |
12 | clean_title=$(
13 | printf "$title" |
14 | exec tr -cs '[:alnum:]-' - |
15 | exec tr '[:upper:]' '[:lower:]'
16 | )
17 | : "${clean_title:?invalid title}"
18 |
19 | author=d630
20 | date_=$(exec date +%Y-%m-%d)
21 | doc_dir=$HOME/src/doc/how-to-articles
22 | if command -- test-ctty; then
23 | v=vim
24 | else
25 | v=gvim
26 | fi
27 |
28 | howto_dir=$doc_dir/$clean_title
29 | command -- mkdir -p "$howto_dir/asset"
30 |
31 | command -- cat >"$howto_dir/metadata.yaml" <"$howto_dir/article.pandoc.md" </dev/null 2>&1 &
10 | #setsid "$@"
11 |
12 | # vim: set ft=sh :
13 |
--------------------------------------------------------------------------------
/daylight:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Test against daytime and adjust my theme config.
4 |
5 | f=${XDG_RUNTIME_DIR:?}/DAYLIGHT
6 |
7 | case $1 in
8 | dark | 1)
9 | command -- rm -f -- "$f"
10 | exec theme dark
11 | ;;
12 | light | 0)
13 | : >"$f"
14 | exec theme light
15 | ;;
16 | *)
17 | command -- test-daylight
18 | exec "$0" "$?"
19 | ;;
20 | esac
21 |
22 | # vim: set ft=sh :
23 |
--------------------------------------------------------------------------------
/debian-dist-upgrade:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Dist-upgrade packages from Debian.
4 |
5 | exec sudo sh -c 'apt-get update && apt-get -y dist-upgrade'
6 | #sudo aptitude update && sudo aptitude full-upgrade;
7 |
8 | # vim: set ft=sh :
9 |
--------------------------------------------------------------------------------
/debian-update-alternatives:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Update Debian alternatives.
4 |
5 | if test "$(exec id -u)" -ne 0; then
6 | echo 'damn. invoke me as root, please' 1>&2
7 | exit 1
8 | fi
9 |
10 | while IFS=' ' read -r a b c; do
11 | update-alternatives --install "$a" "$b" "$c" 100
12 | update-alternatives --set "$b" "$c"
13 | done <"/tmp/$file.$$"
15 |
16 | test -s "/tmp/$file.$$" &&
17 | command -- mv -- "/tmp/$file.$$" "$log" &&
18 | exec chmod 755 "$log"
19 |
20 | # vim: set ft=sh :
21 |
--------------------------------------------------------------------------------
/download-rocketchat-entities:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Download Rocket.Chat user and channel list.
4 |
5 | dir=${XDG_VAR_HOME:?}/lib/rocketchat
6 |
7 | command -- mkdir -p -- "$dir"
8 |
9 | exec rest rocketchat get channels.list 2>/dev/null |
10 | exec jq -r .channels[].name |
11 | exec sort >"$dir/channels.list" &
12 |
13 | exec rest rocketchat get users.list 2>/dev/null |
14 | exec jq -r .users[].username |
15 | exec sort >"$dir/users.list" &
16 |
17 | wait
18 |
19 | # vim: set ft=sh noexpandtab :
20 |
--------------------------------------------------------------------------------
/dudel:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Disk usage of unlinked, but still open files.
4 | #
5 | # Source: http://chneukirchen.org/dotfiles/bin/dudel
6 |
7 | exec find -L /proc/*/fd -maxdepth 1 -type f -links 0 -printf '%b %p\n' 2>/dev/null |
8 | while IFS=' ' read -r size fd; do
9 | pid=${fd#/proc/}
10 | pid=${pid%/fd/*}
11 | prog=$(exec readlink -- "/proc/$pid/exe")
12 | prog=${prog##*/}
13 | printf '%-10d %-10s %-20s %s\n' "$size" "$prog" "$fd" "$(exec readlink -- "$fd")"
14 | done |
15 | exec sort -r
16 |
17 | # vim: set ft=sh :
18 |
--------------------------------------------------------------------------------
/emacsd:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: emacs --daemon.
4 |
5 | exec /usr/bin/emacs --daemon "$@"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/event:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: Use taskwarrior in my 'event' context.
4 |
5 | TASKRC=$XDG_CONFIG_HOME/taskwarrior/taskrc-event exec task "$@"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/event-editor:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Add a task to Taskwarrior ('event' context) via vim (yaml).
4 |
5 | export TASKRC=$XDG_CONFIG_HOME/taskwarrior/taskrc-event
6 |
7 | eval "$(exec date '+s=%s d=%Y-%m-%d t=%H:%M')"
8 | f=${TMPDIR:-${XDG_RUNTIME_DIR}/tmp}/$s.task
9 |
10 | trap 'exec rm -- "$f"' EXIT
11 |
12 | command -- cat >"$f" </dev/tty ||
34 | exit 1
35 |
36 | exec yaml2json <"$f" |
37 | exec jq 'if (.description | length) > 0 then . else empty end' |
38 | exec task import -
39 |
40 | # vim: set ft=sh :
41 |
--------------------------------------------------------------------------------
/fb-image-viewer:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default image viewer (framebuffer).
4 |
5 | IFS=\|
6 | set -f &&
7 | set -- $FB_IMAGE_VIEWER_OPTS ${1:+"$@"} &&
8 | exec "$FB_IMAGE_VIEWER" "$@"
9 |
10 | # vim: set ft=sh :
11 |
--------------------------------------------------------------------------------
/fc-edit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default fc editor ($FCEDIT).
4 |
5 | exec vim -f '+set ft=sh' "$@"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/feed2newsboat:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Select feed url via dmenu and use it in newsboat.
4 |
5 | cache=${XDG_VAR_HOME:?}/lib/feedfaetcher/cache
6 | tagfile=${XDG_CONFIG_HOME:?}/newsboat/tags
7 | feedfile=$XDG_CONFIG_HOME/newsboat/urls
8 |
9 | feed=$(
10 | exec find -H "$cache" -type f |
11 | exec menu dmenu2 FEED
12 | )
13 |
14 | tags=$(
15 | exec grep -v -e '^"_Filter' -- "$tagfile" |
16 | exec menu dmenu2 TAGS
17 | )
18 |
19 | if test -n "$tags"; then
20 | printf 'file://%s %s\n' "$feed" "$tags" >>"$feedfile"
21 | else
22 | printf 'No tag has been chosen\n' 1>&2
23 | fi
24 |
25 | # vim: set ft=sh :
26 |
--------------------------------------------------------------------------------
/feedfaetcher:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | #
3 | # Simple news feed downloader.
4 |
5 | import asyncio
6 | import concurrent.futures
7 | import os
8 | import shutil
9 | import sys
10 |
11 | import requests
12 |
13 | var_dir = os.environ.get("XDG_VAR_HOME")
14 | if var_dir is None or not os.path.exists(var_dir):
15 | sys.exit(1)
16 |
17 | feedfaetcher_dir = os.path.join(var_dir, "lib", "feedfaetcher")
18 | cache_dir = os.path.join(feedfaetcher_dir, "cache")
19 | url_list = os.path.join(feedfaetcher_dir, "urls.txt")
20 | table = os.path.join(feedfaetcher_dir, "table.txt")
21 |
22 | executor = concurrent.futures.ThreadPoolExecutor(10)
23 | loop = asyncio.new_event_loop()
24 | urls = []
25 |
26 |
27 | def handle(url):
28 | resp = get(url)
29 | if resp is not None:
30 | write(url, resp)
31 |
32 |
33 | def get(url):
34 | return requests.get(url, stream=True, timeout=5)
35 |
36 |
37 | def write(url, resp):
38 | fname = "{}.xml".format(
39 | url[:121].replace("_", "-").replace(" ", "_").replace("/", "_")
40 | )
41 |
42 | with open(os.path.join(cache_dir, fname), "wb") as f:
43 | f.write(resp.content)
44 | with open(table, "a+") as f:
45 | f.write("{} {}\n".format(url, fname))
46 |
47 |
48 | async def make_requests():
49 | futures = [loop.run_in_executor(executor, handle, url) for url in urls]
50 | await asyncio.gather(*futures)
51 |
52 |
53 | if __name__ == "__main__":
54 | if os.path.exists(cache_dir):
55 | shutil.rmtree(cache_dir)
56 | os.makedirs(cache_dir)
57 |
58 | try:
59 | os.remove(table)
60 | except OSError:
61 | ...
62 |
63 | with open(url_list) as f:
64 | for l in f:
65 | if not l.strip().startswith("#"):
66 | urls.append(l.strip())
67 | if not urls:
68 | sys.exit(1)
69 |
70 | loop.run_until_complete(make_requests())
71 | loop.close()
72 |
73 | # vim: set ft=python :
74 |
--------------------------------------------------------------------------------
/fetch-all-wir-repo-refs:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Fetch all refs from wir git repositories.
4 |
5 | export log
6 | log=${TMPDIR:-/tmp}/fetch-all-wir-repo-refs
7 | src=$HOME/src/wir
8 |
9 | exec find -H "$src" \
10 | -mindepth 2 \
11 | -maxdepth 2 \
12 | -type d \
13 | -print0 |
14 | exec -- xargs -0 -n 1 -P 0 -- sh -c '
15 | test -d "$1/.git" ||
16 | exit 0
17 |
18 | path=$1
19 |
20 | export \
21 | GIT_DIR \
22 | GIT_WORK_TREE;
23 | GIT_WORK_TREE="$path";
24 | GIT_DIR="$path/.git";
25 |
26 | eval "$(exec git config --local --get --bool core.bare)" &&
27 | exit 0
28 |
29 | command -- mkdir -p -- "$log/${path%/*}"
30 | : >"$log/$path"
31 |
32 | command -- git fetch --all --prune --tags --recurse-submodules=on-demand \
33 | >>"$log/$path" 2>&1 ||
34 | echo error: "$log$path"
35 | ' --
36 |
37 | # vim: set ft=sh :
38 |
--------------------------------------------------------------------------------
/file-browser:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default file manager (tui).
4 |
5 | IFS=\|
6 | set -f &&
7 | set -- $FILE_BROWSER_OPTS ${1:+"$@"} &&
8 | exec "$FILE_BROWSER" "$@"
9 |
10 | # vim: set ft=sh :
11 |
--------------------------------------------------------------------------------
/furlview:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Simple replacement for urlview using fzf in X.
4 | #
5 | # Usage:
6 | #
7 | # $ furlview FILE1 ... FILEn
8 | # $ foo | furlview
9 | # $ furlview < FILE
10 | # $ furlview <<< "foo"
11 | # $ furlview <&2
32 | exit 1
33 | fi
34 |
35 | mapfile -t furls < <(
36 | for f in "$@"; do
37 | if __is_file "$f"; then
38 | command -- cat -- "$f"
39 | else
40 | printf \
41 | "Error: File '%s' is neather a regular file nor a named pipe\n" \
42 | "$f" 1>&2
43 | fi
44 | done |
45 | __select
46 | )
47 | fi
48 |
49 | for u in "${furls[@]}"; do
50 | command -- daemonize run-chromium "$u" &
51 | done
52 |
53 | wait
54 |
55 | # vim: set ft=zsh :
56 |
--------------------------------------------------------------------------------
/gaisma:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Get sun data infos from www.gaisma.com.
4 |
5 | exec curl -s https://www.gaisma.com/en/location"/${1:-${X_MY_LOCATION1:?}}."html |
6 | exec scrape -be table.sun-data |
7 | exec w3m -dump -T text/html |
8 | exec head
9 |
10 | # vim: set ft=sh :
11 |
--------------------------------------------------------------------------------
/generate-my-confluence-how-to-article:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Generate markdown version of my confluence how-to article and push it.
4 |
5 | set -e
6 |
7 | title=${1:?title missing}
8 | clean_title=$(
9 | printf "$title" |
10 | exec tr -cs '[:alnum:]-' - |
11 | exec tr '[:upper:]' '[:lower:]'
12 | )
13 | : "${clean_title:?invalid title}"
14 |
15 | repo=$HOME/src/doc
16 | doc_dir=$repo/how-to-articles
17 | howto_dir=$doc_dir/$clean_title
18 | asset_dir=$howto_dir/asset
19 | pandoc_file=$howto_dir/article.pandoc.md
20 | article_file=$howto_dir/article.md
21 | metadata_file=$howto_dir/metadata.yaml
22 | reference_links_file=$doc_dir/reference-links.pandoc.md
23 |
24 | test -r "$asset_dir" &&
25 | test -r "$pandoc_file" &&
26 | test -r "$metadata_file" &&
27 | test -r "$reference_links_file" ||
28 | exit 1
29 |
30 | cd -- "$repo" ||
31 | exit 1
32 |
33 | export \
34 | GIT_DIR \
35 | GIT_WORK_TREE
36 | GIT_WORK_TREE=$repo
37 | GIT_DIR=$repo/.git
38 |
39 | pandoc() {
40 | command pandoc \
41 | -o "$article_file" \
42 | -f markdown \
43 | -t commonmark \
44 | --indented-code-classes numberLines \
45 | "$pandoc_file" \
46 | "$reference_links_file"
47 |
48 | # command pandoc \
49 | # -s \
50 | # -o "$article_file.html" \
51 | # -f markdown \
52 | # -t html5 \
53 | # --indented-code-classes numberLines \
54 | # "$metadata_file" "$pandoc_file" "$reference_links_file";
55 | }
56 |
57 | \pandoc &&
58 | command -- git add -f "$howto_dir" &&
59 | command -- git commit -m "edit: $title" &&
60 | exec git push -u --tags origin master
61 |
62 | # vim: set ft=sh :
63 |
--------------------------------------------------------------------------------
/get-basic-edid-identification:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Get some EDID vendor and product information.
4 |
5 | exec edid-decode -S -s --skip-sha "${1:?missing file arg}" |
6 | exec mawk '
7 | /^Checksum: / {
8 | exit
9 | }
10 |
11 | /^[ ]+(Manufacturer|Model|Serial Number|Made in|Display Product Name|Display Product Serial Number): / {
12 | sub("^[ ]+", "")
13 | print
14 | }
15 | '
16 |
17 | # vim: set ft=sh :
18 |
--------------------------------------------------------------------------------
/get-battery-capacity:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Get battery capacity.
4 |
5 | shopt -s nullglob
6 |
7 | c=-101
8 |
9 | case ${PRODUCT_NAME_SUM:=$(exec -- get-product-name-by-md5sum)} in
10 | dd791b3dd44b647e91524123fa1c6d0f)
11 | b=(/sys/class/power_supply/CMB*)
12 | if ((${#b})); then
13 | c=$(<"$b/capacity")
14 | [[ $(<"$b/status") != Discharging ]] &&
15 | c=-$c
16 | fi
17 | ;;
18 | esac
19 |
20 | printf '%d\n' "$c"
21 |
22 | # vim: set ft=zsh :
23 |
--------------------------------------------------------------------------------
/get-edid-as-sha256sums:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Get sha256sums of the connected monitor's EDID info.
4 |
5 | exec grep -l '^connected' /sys/class/drm/*/status |
6 | while IFS= read -r REPLY; do
7 | sum=$(exec hexdump-raw-edid "${REPLY%/*}/edid" | exec sha256sum)
8 | echo "${sum% *}"
9 | done
10 |
11 | # vim: set ft=sh :
12 |
--------------------------------------------------------------------------------
/get-input-device-names-as-md5sums:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Get md5sums of names in /proc/bus/input/devices.
4 |
5 | exec sed -n '/N: Name=/ { s/^[^=]*="\(.*\)"$/\1/; p }' /proc/bus/input/devices |
6 | exec xargs -P 0 -I {} -- sh -c 'printf %s "{}" | exec md5sum | exec cut -d " " -f 1' |
7 | LC_ALL=C exec sort -u
8 |
9 | # vim: set ft=sh :
10 |
--------------------------------------------------------------------------------
/get-lifeday:
--------------------------------------------------------------------------------
1 | #!/usr/bin/gawk -f
2 | #
3 | # Get lifeday.
4 |
5 | BEGIN {
6 | printf "%d\n", ( systime() - mktime(ENVIRON["X_BDATE"]) ) / 60 / 60 / 24
7 | }
8 |
9 | # vim: set ft=awk :
10 |
--------------------------------------------------------------------------------
/get-nox:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Get concubium and gallicinium.
4 |
5 | set -f
6 | IFS=' '
7 | set -- $(exec get-sundata 2>/dev/null) $(exec get-sundata "$(exec date --date=tomorrow +%s)")
8 | set -- ${3%:*}h ${3#*:}min ${2%:*}h ${2#*:}min
9 |
10 | q=$(exec task-calc "((tomorrow + $1 + $2) - (today + $3 + $4)) / 4 ")
11 |
12 | printf '%s %s\n' \
13 | "$(exec task-calc "today + $3 + $4 + $q")" \
14 | "$(exec task-calc "tomorrow + $1 + $2 - $q")"
15 |
16 | # vim: set ft=sh :
17 |
--------------------------------------------------------------------------------
/get-product-name-as-sha256sum:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Get sha256sum of /sys/class/dmi/id/product_name.
4 |
5 | IFS= read -r comp getOffset() / 3600;
19 |
20 | $sunrise = \date_sunrise(
21 | $now,
22 | \SUNFUNCS_RET_TIMESTAMP,
23 | $latitude,
24 | $longitude,
25 | 90.583333,
26 | $offset
27 | );
28 | $sunset = \date_sunset(
29 | $now,
30 | \SUNFUNCS_RET_TIMESTAMP,
31 | $latitude,
32 | $longitude,
33 | 90.583333,
34 | $offset
35 | );
36 |
37 | print strftime('%H:%M', $sunrise) . ' ' . strftime('%H:%M', $sunset) . PHP_EOL;
38 |
39 | if ($sunrise < $now && $now < $sunset) {
40 | exit(0);
41 | } else {
42 | exit(1);
43 | }
44 |
45 | // vim: set ft=php :
46 |
--------------------------------------------------------------------------------
/get-wan-ip:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Get WAN IP.
4 |
5 | command -- test-inet &&
6 | exec dig -4 +short whoami.akamai.net @ns1-1.akamaitech.net
7 |
8 | # vim: set ft=sh :
9 |
--------------------------------------------------------------------------------
/github-build-bin-readme:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Build README.md in github.com/D630/bin.
4 |
5 | cd -- /home/stow/bin/bin ||
6 | exit 1
7 |
8 | IFS=.: read -r _ _ p _ _ < <(exec -- git config --local --get remote.origin.url)
9 | P=https://github.com/$p
10 |
11 | export LC_ALL=C
12 |
13 | __find() {
14 | # find . -maxdepth 1 -regextype posix-egrep \
15 | # \( -path "./.*" -o -name README.md \) \
16 | # -prune \
17 | # -o \( -type f -a -regex "\./.*\.(awk|py|sh)" \) \
18 | # -exec grep -H -m 1 '^# ' {} +;
19 | # git ls-files -z '*.awk' '*.py' '*.sh' \
20 | # | xargs -0 grep -H -m 1 '^# ';
21 |
22 | exec -- git ls-files -z '[!A][!R]*' |
23 | exec -- xargs -0 -- grep -E -Z -l -m 1 '^#!.*(awk|[bdtm][ack]sh|python|sh|perl).*' |
24 | command -- xargs -0 -- grep -H -m 1 '^# '
25 |
26 | # find . -maxdepth 1 \
27 | # \( -path "./.*" -o -name README.md \) \
28 | # -prune \
29 | # -o \( -type f -a -name "*.php" \) \
30 | # -exec grep -H -m 1 '// ' {} + \
31 | # | sed 's/ \/\//#/';
32 | # git ls-files -z '*.php' \
33 | # | xargs -0 grep -H -m 1 '// ' \
34 | # | sed 's/ \/\//#/';
35 |
36 | exec -- git ls-files -z '[!A][!R]*' |
37 | exec -- xargs -0 -- grep -E -Z -l -m 1 '^#!.*php.*' |
38 | exec -- xargs -0 -- grep -H -m 1 '// ' |
39 | exec -- sed 's:[[:space:]]*//:#:'
40 | }
41 |
42 | {
43 | header=$(./README.md
61 |
62 | # vim: set ft=zsh :
63 |
--------------------------------------------------------------------------------
/grabc2clipboard:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # X-select color code from grabc into clipboard.
4 |
5 | exec run-grabc |
6 | exec xorg-selection-clipboard-in
7 |
8 | # vim: set ft=sh :
9 |
--------------------------------------------------------------------------------
/grep-url:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Grep url from stdin.
4 | #
5 | # Source: https://gist.github.com/GuillaumeLestringant/36c11afcc35c8c5b9123
6 |
7 | proto="((?:https?|ftp)://|)"
8 | id="?:\S+(?::\S*)?@"
9 | ip_excluded="(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})"
10 | ip_included="(?:1\d\d|2[01]\d|22[0-3]|[1-9]\d?)(?:\.(?:2[0-4]\\d|25[0-5]|1?\\d{1,2})){2}(?:\.(?:1\d\d|2[0-4]\d|25[0-4]|[1-9]\d?))"
11 | ip="$ip_excluded$ip_included"
12 | chars="a-z\x{00a1}-\x{ffff}"
13 | base="(?:[${chars}0-9]-*)*[${chars}0-9]+"
14 | host="(?:$base)"
15 | domain="(?:\.$base)*"
16 | tld="(?:\.(?:[${chars}]{2,}))"
17 | fulldomain=$host$domain$tld"\.?"
18 | name="(?:$ip|$fulldomain)"
19 | port="(?::\d{2,5})?"
20 | path="(?:[/?#]\S*)?"
21 |
22 | exec grep ${1:+"$@"} -P -i -e "^($proto($id)?$name$port$path)\$"
23 |
24 | # vim: set ft=sh :
25 |
--------------------------------------------------------------------------------
/habit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: Use taskwarrior in my 'habit' context.
4 |
5 | TASKRC=$XDG_CONFIG_HOME/taskwarrior/taskrc-habit exec task "$@"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/habit-editor:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Add a task to Taskwarrior ('habit' context) via vim (yaml).
4 |
5 | export TASKRC=$XDG_CONFIG_HOME/taskwarrior/taskrc-habit
6 |
7 | eval "$(exec date '+s=%s d=%Y-%m-%d t=%H:%M')"
8 | f=${TMPDIR:-${XDG_RUNTIME_DIR}/tmp}/$s.task
9 |
10 | trap 'exec rm -- "$f"' EXIT
11 |
12 | command -- cat >"$f" </dev/tty ||
52 | exit 1
53 |
54 | exec yaml2json <"$f" |
55 | exec jq 'if (.description | length) > 0 then . else empty end' |
56 | exec task import -
57 |
58 | # vim: set ft=sh :
59 |
--------------------------------------------------------------------------------
/hexdump-raw-edid:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Hexdump raw EDID monitor description usable with edid-decode(1).
4 |
5 | exec hexdump -ve '1/1 "%.2x"' "${1:?missing file arg}"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/idea-file-info:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Display Java file info. To be run as external tool within IDEA.
4 |
5 | exec jq -R --slurp . <<-IN | exec jq -r '. | fromjson' | exec vim '+set ft=json' -
6 | {
7 | "AffectedModuleNames": "$1",
8 | "Classpathl": "$2",
9 | "ClasspathEntry": "$3",
10 | "ColumnNumber": "$4",
11 | "ContentRoot": "$5",
12 | "FileClass": "$6",
13 | "FileDir": "$7",
14 | "FileDirName": "$8",
15 | "FileDirPathFromParent": "$9",
16 | "FileDirRelativeToProjectRoot": "${10}",
17 | "FileDirRelativeToSourcepath": "${11}",
18 | "FileEncoding": "${12}",
19 | "FileExt": "${13}",
20 | "FileFQPackage": "${14}",
21 | "FileName": "${15}",
22 | "FileNameWithoutAllExtensions": "${16}",
23 | "FileNameWithoutExtension": "${17}",
24 | "FilePackage": "${18}",
25 | "FileParentDir": "${19}",
26 | "FilePath": "${20}",
27 | "FilPatheRelativeToProjectRoot": "${21}",
28 | "FilePathRelativeToSourcepath": "${22}",
29 | "FileRelativeDir": "${23}",
30 | "FileRelativePath": "${24}",
31 | "IsMake": "${25}",
32 | "JavaDocPath": "${26}",
33 | "JDKPath": "${27}",
34 | "LineNumber": "${28}",
35 | "ModuleFileDir": "${29}",
36 | "ModuleFilePath": "${30}",
37 | "ModuleName": "${31}",
38 | "ModuleSdkPath": "${32}",
39 | "ModuleSourcePath": "${33}",
40 | "OutputPath": "${34}",
41 | "ProjectFileDir": "${35}",
42 | "ProjectName": "${36}",
43 | "Projectpath": "${37}",
44 | "PyInterpreterDirectory": "${38}",
45 | "SelectionEndColumn": "${39}",
46 | "SelectionEndLine": "${40}",
47 | "SelectionStartColumn": "${41}",
48 | "SelectionStartLine": "${42}",
49 | "Sourcepath": "${43}",
50 | "SourcepathEntry": "${44}"
51 | }
52 | IN
53 |
54 | # vim: set ft=sh noexpandtab :
55 |
--------------------------------------------------------------------------------
/image-viewer:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default image viewer (tui).
4 |
5 | IFS=\|
6 | set -f &&
7 | set -- $IMAGE_VIEWER_OPTS ${1:+"$@"} &&
8 | exec "$IMAGE_VIEWER" "$@"
9 |
10 | # vim: set ft=sh :
11 |
--------------------------------------------------------------------------------
/iplog:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Log WAN IP.
4 |
5 | log=${XDG_VAR_HOME:?}/log/ip-log.log
6 | to=ip-log
7 | subject=ip-log
8 |
9 | printf '%(%Y-%m-%d_%R)T %s\n' -1 "$(exec -- get-wan-ip)" |
10 | exec -- tee -a "$log" |
11 | exec -- mailx -s "$subject" "$to"
12 |
13 | # vim: set ft=zsh :
14 |
--------------------------------------------------------------------------------
/issue:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: Use taskwarrior in my 'issue' context.
4 |
5 | TASKRC=$XDG_CONFIG_HOME/taskwarrior/taskrc-issue exec task "$@"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/issue-editor:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Add a task into Taskwarrior ('issue' context) via vim (yaml).
4 |
5 | export TASKRC=$XDG_CONFIG_HOME/taskwarrior/taskrc-issue
6 |
7 | eval "$(exec date +'s=%s d=%Y-%m-%d t=%H:%M')"
8 | f=${TMPDIR:-${XDG_RUNTIME_DIR}/tmp}/$s.task
9 |
10 | trap 'exec rm -- "$f"' EXIT
11 |
12 | cat >"$f" </dev/tty ||
28 | exit 1
29 |
30 | exec yaml2json <"$f" |
31 | exec jq 'if (.description | length) > 0 then . else empty end' |
32 | exec task import -
33 |
34 | # vim: set ft=sh :
35 |
--------------------------------------------------------------------------------
/jira-rest-api:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: Jira REST API.
4 |
5 | server_address=${JIRA_SERVER_ADDRESS:-https://jira.wir.invalid}
6 |
7 | unset -v JIRA_SERVER_ADDRESS
8 |
9 | . "$(command -v rest-api)" ||
10 | exit
11 |
12 | \main "$@"
13 |
14 | # vim: set ft=sh :
15 |
--------------------------------------------------------------------------------
/jira-rest-api-libexec:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Libexec: Confluence REST API.
4 |
5 | export API=${API:-${api:-jira-rest-api}}
6 |
7 | # Get all mates' unresolved issues.
8 | f_get_mates_unresolved_issues() {
9 | local mates=${1:-'error: mates missing'}
10 |
11 | command -- "$API" get \
12 | "/rest/api/2/search?maxResults=999&jql=assignee%20IN%20($mates)%20and%20resolution=Unresolved"
13 | }
14 |
15 | # Get all user's watching issues.
16 | f_get_users_watched_issues() {
17 | local user=${1:-'error: user missing'}
18 |
19 | command -- "$API" get "/rest/api/2/search?maxResults=999&jql=watcher=$user"
20 | }
21 |
22 | # Watch all issues a user's team members have been assigned to.
23 | f_watch_mates_issues() {
24 | local \
25 | user=${1:-'error: user missing'} \
26 | mates=${2:-'error: mates missing'}
27 |
28 | \f_get_mates_unresolved_issues "$mates" |
29 | exec jq -r '"/rest/api/2/issue/\(.issues[].key)/watchers"' |
30 | exec sort -u |
31 | command -- xargs -n 1 -P 0 -I {} -- "$API" post "{}" "\"$user\""
32 | }
33 |
34 | # Remove user everywhere as watcher.
35 | f_unwatch_issues() {
36 | local user=${1:-'error: user missing'}
37 |
38 | \f_get_users_watched_issues "$user" |
39 | exec jq -r --arg user "$user" \
40 | '"/rest/api/2/issue/\(.issues[].key)/watchers?username=\($user)"' |
41 | command -- xargs -n 1 -P 0 -- "$API" delete
42 | }
43 |
44 | ${1:+"f_$@"}
45 |
46 | # vim: set ft=sh :
47 |
--------------------------------------------------------------------------------
/lan-down:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: Set lan off.
4 |
5 | exec sudo -- "${XDG_BIN_HOME:?}/reconfigure-network-device" \e -d
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/lan-up:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: Set lan on.
4 |
5 | exec sudo -- "${XDG_BIN_HOME:?}/reconfigure-network-device" \e -c
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/lesspipew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # My preprocessor for less.
4 |
5 | test "$#" -gt 0 ||
6 | exit 1
7 |
8 | trap exit\ 0 PIPE
9 | umask 077
10 | space=' '
11 | tab=' '
12 | newline='
13 | '
14 | LESSMETACHARS="$space$tab$newline'"';*?"()<>[|&^`#\$%=~'
15 | export LESSMETACHARS
16 |
17 | test -x "$HOME/.lessfilter" &&
18 | "$HOME/.lessfilter" "$1" &&
19 | exit 82
20 |
21 | set -f
22 | for i in $LESSIGNORE; do
23 | case $1 in
24 | *.$i)
25 | exit 82
26 | ;;
27 | esac
28 | done
29 |
30 | if
31 | test "${LESSCOLOR:-0}" -eq 2 ||
32 | case $LESS in
33 | *-[rR]*) : ;;
34 | *) ! : ;;
35 | esac
36 | then
37 | A=cdog
38 | else
39 | A=dog
40 | fi
41 |
42 | exec open -A "$A" -A about -f "$1" 2>&1
43 |
44 | # vim: set ft=sh :
45 |
--------------------------------------------------------------------------------
/list-all-branches:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # List all branches of all project repos.
4 |
5 | exec rest bitbucket libexec get_branches 2>/dev/null |
6 | exec jq -r '
7 | .[] |
8 | .project_key as $project |
9 | .repo_slug as $repo |
10 | .values[] |
11 | [
12 | $project,
13 | $repo,
14 | .displayId
15 | ] |
16 | @tsv' |
17 | exec sort -k 1,1 -k 2,2 -k 3,3 |
18 | exec column -t
19 |
20 | # vim: set ft=sh :
21 |
--------------------------------------------------------------------------------
/list-all-can-merge-prs:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # List all open prs, which can be merged.
4 |
5 | exec rest bitbucket libexec get_open_prs 2>/dev/null |
6 | exec jq -r '
7 | .[].values[] |
8 | "\(.links.self[0].href)\t/rest/api/latest/projects/\(.toRef.repository.project.key)/repos/\(.toRef.repository.slug)/pull-requests/\(.id)/merge"
9 | ' |
10 | exec xargs -n 2 -P 0 -- sh -c '
11 | merge=$(
12 | exec rest bitbucket get "$2" 2>/dev/null |
13 | exec jq -r ".canMerge"
14 | );
15 |
16 | if test "$merge" = true; then
17 | echo "$1"
18 | fi
19 | ' -- |
20 | exec sort
21 |
22 | # vim: set ft=sh :
23 |
--------------------------------------------------------------------------------
/list-all-confluence-blogposts:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # List all confluence blog posts.
4 |
5 | next='/rest/api/content?type=blogpost&expand=space,history,metadata.labels&limit=999'
6 |
7 | until
8 | next=$(
9 | exec rest confluence get "$next" 2>/dev/null |
10 | exec jq -r --unbuffered '
11 | (
12 | .results[] | [
13 | .history.createdDate,
14 | .space.key,
15 | .history.createdBy.username,
16 | ([.metadata.labels.results[].name // "n.a."] | sort | join("+")),
17 | .title
18 | ] | @tsv
19 | ),
20 | ._links.next
21 | '
22 | )
23 | test -z "$next"
24 | do
25 | echo "$next" | exec head -n -1
26 | next=$(echo "$next" | exec tail -1)
27 | done |
28 | exec sort -k 1,1 -k 2,2 -k 3,3 -k 4,4 -k 5,5 |
29 | exec column -t -s ' '
30 |
31 | # vim: set ft=sh :
32 |
--------------------------------------------------------------------------------
/list-all-inactive-reviewers:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # List all inactive reviewers of open and overdue prs.
4 |
5 | exec rest bitbucket libexec get_overdue_prs 2>/dev/null |
6 | exec jq -r '
7 | .[] |
8 | . as $root |
9 | [
10 | .reviewers[] |
11 | select(
12 | (has("lastReviewedCommit") | not) or
13 | .lastReviewedCommit != $root.fromRef.latestCommit
14 | ) |
15 | .user.slug
16 | ] |
17 | select((. | length) > 0) |
18 | "\($root.links.self[0].href)\t\(sort | join(","))"
19 | ' |
20 | exec sort -k 1,1 |
21 | exec column -t
22 |
23 | # vim: set ft=sh :
24 |
--------------------------------------------------------------------------------
/list-all-my-confluence-how-to-articles:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # List all my confluence how-to articles.
4 |
5 | exec rest confluence get '/rest/api/content/21173362/child?expand=page.metadata.labels&limit=999' 2>/dev/null |
6 | exec jq -r --unbuffered '
7 | .page.results[] |
8 | [
9 | .id,
10 | ([.metadata.labels.results[].name] | sort | join("+")),
11 | .title
12 | ] |
13 | @tsv
14 | ' |
15 | exec column -t -s ' '
16 |
17 | # vim: set ft=sh :
18 |
--------------------------------------------------------------------------------
/list-all-other-rocketchat-channels:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # List all rocketchat channels I haven't joined yet.
4 |
5 | joined=$(
6 | exec rest rocketchat get channels.list.joined 2>/dev/null |
7 | exec jq -rc '.channels | map({(._id): null}) | add'
8 | )
9 |
10 | exec rest rocketchat get channels.list 2>/dev/null |
11 | exec jq -r --argjson joined "$joined" '
12 | .channels[] |
13 | ._id as $_id |
14 | select($joined | has($_id?) | not) |
15 | "\(.name)\t\(.u.username)\t\(.ts)"
16 | ' |
17 | exec sort -s -k 3,3 |
18 | exec column -t
19 |
20 | # vim: set ft=sh :
21 |
--------------------------------------------------------------------------------
/list-all-overdue-prs:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # List all open and overdue prs.
4 |
5 | exec rest bitbucket libexec get_overdue_prs 2>/dev/null |
6 | exec jq -r '
7 | .[] |
8 | [
9 | (.id | tostring) + "/" + (.version | tostring),
10 | (.updatedDate / 1000 | strftime("%Y-%m-%d_%H:%M:%S")),
11 | (.properties.commentCount // 0 | tostring) + "," + (.properties.openTaskCount | tostring),
12 | .toRef.repository.project.key + "/" + .toRef.repository.slug + ":" + .toRef.displayId,
13 | (
14 | (.title | gsub("\\s"; "_")) as $title |
15 | if (.title | length) <= 37
16 | then $title
17 | else $title[0:35] + "…"
18 | end
19 | )
20 | ] |
21 | @tsv
22 | ' |
23 | exec sort -k 2,2 |
24 | exec column -t
25 |
26 | # vim: set ft=sh :
27 |
--------------------------------------------------------------------------------
/list-all-tags:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # List all tags of all project repos.
4 |
5 | exec rest bitbucket libexec get_tags 2>/dev/null |
6 | exec jq -r '
7 | .[] |
8 | .project_key as $project |
9 | .repo_slug as $repo |
10 | .values[] |
11 | [
12 | $project,
13 | $repo,
14 | .displayId
15 | ] |
16 | @tsv
17 | ' |
18 | exec sort -k 1,1 -k 2,2 -k 3,3 |
19 | exec column -t
20 |
21 | # vim: set ft=sh :
22 |
--------------------------------------------------------------------------------
/list-all-users-contact-data:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # List all users with their contact data.
4 |
5 | if test "$1" = all; then
6 | search='(&(departmentNumber=*)(!(givenName=Meetingroom)))'
7 | else
8 | search='(|(departmentNumber=DEV*)(departmentNumber=MGMT))'
9 | fi
10 |
11 | exec ldapsearch -x -H ldap://ldap.wir.invalid -LLL -b 'ou=Users,dc=wir,dc=invalid' \
12 | "$search" uid mail telephoneNumber |
13 | exec mawk '
14 | /dn: / {
15 | split("", data)
16 |
17 | while(getline && NF)
18 | data[$1] = $2;
19 |
20 | if (!data["telephoneNumber:"])
21 | data["telephoneNumber:"] = -1;
22 |
23 | printf(\
24 | "%s\t%d\t%s\n",
25 | data["uid:"],
26 | data["telephoneNumber:"],
27 | data["mail:"]\
28 | );
29 | }
30 | ' |
31 | exec sort
32 |
33 | # vim: set ft=sh :
34 |
--------------------------------------------------------------------------------
/list-all-users-ip-addresses:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # List all users with their ip addresses.
4 |
5 | exec ldapsearch -x -H ldap://ldap.wir.invalid -LLL -b 'ou=Users,dc=wir,dc=invalid' \
6 | '(&(|(departmentNumber=DEV*)(departmentNumber=MGMT))(telephoneNumber=*))' \
7 | telephoneNumber |
8 | exec mawk '
9 | BEGIN {
10 | net = "192.168.210";
11 | }
12 |
13 | /dn: / {
14 | uid = $0
15 | sub(",.*", "", uid);
16 | sub(".*=", "", uid);
17 |
18 | getline;
19 | telephone_number = $2;
20 |
21 | printf("%s.%d\t%s\n", net, telephone_number, uid);
22 | }
23 | ' |
24 | exec sort-ipv4
25 |
26 | # vim: set ft=sh :
27 |
--------------------------------------------------------------------------------
/list-commits-totals:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # List all all project repos' commit totals.
4 |
5 | exec rest bitbucket get repos 2>/dev/null |
6 | exec jq -r --unbuffered '
7 | .values[] |
8 | select(.project.key | contains("~") | not) |
9 | .project.key, .slug
10 | ' |
11 | exec xargs -n 2 -P 0 -- sh -c '
12 | endpoint=/rest/api/latest/projects/$1/repos/$2/commits?limit=1\&withCounts=true\&merges=exclude
13 |
14 | exec rest bitbucket get "$endpoint" 2>/dev/null |
15 | exec jq -rc --arg project "$1" --arg repo "$2" "
16 | \"\(\$project)\t\(\$repo)\t\(.authorCount // 0)\t\(.totalCount // 0)\"
17 | "
18 | ' -- |
19 | exec sort |
20 | exec column -t
21 |
22 | # vim: set ft=sh :
23 |
--------------------------------------------------------------------------------
/list-rocketchat-user-presences:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # List all user presences in Rocket.Chat.
4 |
5 | exec rest rocketchat get users.presence 2>/dev/null |
6 | exec jq -r '
7 | .users[] |
8 | "\(.name)\t\(.username)\t\(.status)\t\(.statusText)"
9 | ' |
10 | exec sort |
11 | exec column -t -s ' '
12 |
13 | # vim: set ft=sh :
14 |
--------------------------------------------------------------------------------
/lock:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Manually lock screen.
4 |
5 | if command -- test-xorg; then
6 | exec xorg-lock
7 | else
8 | command -- fgconsole 1>/dev/null 2>&1 ||
9 | exit 1
10 | case $TERM in
11 | linux*)
12 | exec physlock -m
13 | ;;
14 | esac
15 | fi
16 |
17 | # vim: set ft=sh :
18 |
--------------------------------------------------------------------------------
/log:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: Use taskwarrior in my 'log' context.
4 |
5 | export TASKRC=$XDG_CONFIG_HOME/taskwarrior/taskrc-todo
6 |
7 | exec 2>/dev/null
8 |
9 | command -- task context log >/dev/null
10 | trap 'exec task context none >/dev/null' EXIT
11 |
12 | command -- task +log +todo "$@"
13 |
14 | # vim: set ft=sh :
15 |
--------------------------------------------------------------------------------
/log-editor:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Log a task into Taskwarrior ('log' context) via vim (yaml).
4 |
5 | export TASKRC=$XDG_CONFIG_HOME/taskwarrior/taskrc-todo
6 |
7 | eval "$(exec date '+=%s d=%Y-%m-%d t=%H:%M')"
8 | f=${TMPDIR:-${XDG_RUNTIME_DIR}/tmp}/$s.task
9 |
10 | trap 'exec rm -- "$f"' EXIT
11 |
12 | command -- cat >"$f" </dev/tty ||
45 | exit 1
46 |
47 | exec yaml2json <"$f" |
48 | exec jq 'if (.description | length) > 0 and .status == "completed" then . else empty end' |
49 | exec task import -
50 |
51 | # vim: set ft=sh :
52 |
--------------------------------------------------------------------------------
/lsdisk:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Display information about block devices and disk space on the file system.
4 |
5 | sudo lsblk -a -i -T -M \
6 | -o NAME,FSTYPE,UUID,RO,RM,SIZE,STATE,OWNER,GROUP,MODE,TYPE,MOUNTPOINT,LABEL,MODEL
7 |
8 | echo
9 |
10 | exec df -a -h --total \
11 | --output=source,fstype,itotal,iused,iavail,ipcent,size,used,avail,pcent,file,target |
12 | exec mawk '
13 | BEGIN {
14 | cmd = "exec head -n -1 | exec sort"
15 | }
16 |
17 | NR == 1 {
18 | print $0;
19 | next;
20 | }
21 |
22 | {
23 | print $0 | cmd
24 | }
25 |
26 | END {
27 | close(cmd)
28 | print $0
29 | }
30 | '
31 |
32 | # vim: set ft=sh :
33 |
--------------------------------------------------------------------------------
/lsort:
--------------------------------------------------------------------------------
1 | #!/usr/bin/gawk -f
2 | #
3 | # Sort strings by lenght.
4 | #
5 | # Source: https://github.com/izabera/bin/blob/master/lsort
6 |
7 | {
8 | line[length][counter[length]++] = $0
9 | }
10 |
11 | END {
12 | for (i in line)
13 | for (j in line[i])
14 | print line[i][j]
15 | }
16 |
17 | # vim: set ft=awk :
18 |
--------------------------------------------------------------------------------
/mail-archive:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Archive mails (dovecot -> maildir).
4 |
5 | exec mbsync -V dovecot
6 | #run-imapfilter localhost-delete;
7 |
8 | # vim: set ft=sh :
9 |
--------------------------------------------------------------------------------
/mail-deliver:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Deliver mails (msmtp).
4 |
5 | exec msmtpqw "$@"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/mail-get:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Get mails and give notification + sound (via run-logger).
4 |
5 | exec 9<"$0"
6 | if ! flock -n 9; then
7 | printf 'sorry, I am already running\n' 1>&2
8 | exit 1
9 | fi
10 |
11 | command -- mail-retrieve ${1:+"$@"}
12 | command -- sleep 0.5
13 |
14 | mapfile -t reply < <(exec -- mail-inbox)
15 |
16 | ((\
17 | ${reply[0]##*[[:space:]]} + \
18 | ${reply[1]##*[[:space:]]} + \
19 | ${reply[2]##*[[:space:]]} + \
20 | ${reply[3]##*[[:space:]]} + \
21 | ${reply[4]##*[[:space:]]} > 0)) ||
22 | exit 1
23 |
24 | printf '%s\n' "${reply[@]}"
25 | exec -- run-logger 6 .email.arrived \
26 | "\n${reply[0]:-?}\n${reply[1]:-?}\n${reply[2]:-?}\n${reply[3]:-?}\n${reply[4]:-?}" 2>/dev/null
27 |
28 | # vim: set ft=zsh :
29 |
--------------------------------------------------------------------------------
/mail-hook-post:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run command after mail-get.
4 |
5 | # vim: set ft=sh :
6 |
--------------------------------------------------------------------------------
/mail-hook-pre:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run command before mail-get.
4 |
5 | # vim: set ft=sh :
6 |
--------------------------------------------------------------------------------
/mail-inbox:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env mksh
2 | #
3 | # Display statistics about new/unseen mails (imapfilter).
4 |
5 | exec run-imapfilter localhost-unseen |
6 | exec column -t -s $'\t'
7 |
8 | # vim: set ft=zsh :
9 |
--------------------------------------------------------------------------------
/mail-queue:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Display mail queue (msmtp).
4 |
5 | exec msmtp-queue -d
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/mail-retrieve:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Retrieve mails (mpop).
4 |
5 | exec mpop "${@:--a}" >>"${XDG_VAR_HOME:?}/log/mpop.log" 2>&1
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/mail-send:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Sends mail via msmtp-queue and give notification + sound (via run-logger).
4 |
5 | exec 9<"$0"
6 | if ! flock -n 9; then
7 | printf 'sorry, I am already running\n' 1>&2
8 | exit 1
9 | fi
10 |
11 | maildir=${XDG_VAR_HOME:?}/mail/queue
12 | if ! [[ -d $maildir ]]; then
13 | printf "maildir '%s' is not a directory\n" "$maildir" 1>&2
14 | exit 1
15 | fi
16 |
17 | shopt -s nullglob
18 | shopt -s extglob
19 | shopt -s dotglob
20 | set -- "$maildir/"!(\.*)
21 |
22 | if (($#)); then
23 | cnt=$#
24 | else
25 | exit 1
26 | fi
27 |
28 | i=0
29 | until ! (($#)); do
30 | case $i in
31 | 30)
32 | command -- run-logger 3 .email.error "Delivery error. [posteo] Mails not sent: $cnt"
33 | exit 1
34 | ;;
35 | *)
36 | command -- msmtpqw -r
37 | set -- "$maildir/"!(\.*)
38 | ((i++))
39 | command -- sleep 1
40 | ;;
41 | esac
42 | done
43 |
44 | command -- run-logger 6 .email.bounced "[posteo] Sent Mails: $cnt"
45 |
46 | # vim: set ft=zsh :
47 |
--------------------------------------------------------------------------------
/mail-update:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Update mail folders.
4 |
5 | if command -- test-inet; then
6 | command -- mail-send &
7 | #mail-hook-pre
8 | command -- mail-get
9 | #mail-hook-post
10 | wait
11 | else
12 | command -- run-logger 3 .network.error 'We are offline. Mails have not been updated'
13 | ! :
14 | fi
15 |
16 | # vim: set ft=sh :
17 |
--------------------------------------------------------------------------------
/mail-viewer:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default mua (tui).
4 |
5 | IFS=\|
6 | set -f &&
7 | set -- $MAIL_VIEWER_OPTS ${1:+"$@"} &&
8 | exec "$MAIL_VIEWER" "$@"
9 |
10 | # vim: set ft=sh :
11 |
--------------------------------------------------------------------------------
/menu:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # A wrapper script for selecting "menu driven" programs.
4 |
5 | menu=${1:?}
6 | menu_prompt=$2
7 |
8 | fn=monospace:size=9
9 |
10 | color() {
11 | if test -f "${XDG_RUNTIME_DIR:?}/DAYLIGHT"; then
12 | nb=\#FDF6E3 # base3
13 | nf=\#657B83 # base00
14 | sb=\#EEE8D5 # base2
15 | sf=\#B58900 # yellow
16 | uc=\#B58900 # yellow
17 | else
18 | nb=\#002B36 # base03
19 | nf=\#839496 # base0
20 | sb=\#073642 # base02
21 | sf=\#859900 # green
22 | uc=\#859900 # green
23 | fi
24 | }
25 |
26 | case $menu in
27 | choose)
28 | exec choose -
29 | ;;
30 | dmenu)
31 | color
32 | exec dmenu -b -i \
33 | -fn "$fn" \
34 | -l 10 \
35 | -nb "$nb" \
36 | -nf "$nf" \
37 | -p "${menu_prompt:->}"
38 | ;;
39 | dmenu2)
40 | exec dmenu2 -b -i \
41 | -class dmenu2 \
42 | -fn "$fn" \
43 | -l 10 \
44 | -name dmenu2 \
45 | -p "${menu_prompt:->}"
46 | ;;
47 | dmenu2-save)
48 | exec dmenu2 -b -f \
49 | -class dmenu2-save \
50 | -fn "$fn" \
51 | -mask \
52 | -name dmenu2-save \
53 | -noinput \
54 | -p "${menu_prompt:-*}"
55 | ;;
56 | slmenu)
57 | exec slmenu -b -i -p "${menu_prompt:->}"
58 | ;;
59 | fzf)
60 | exec fzf -x -i +s --prompt="${menu_prompt:->} "
61 | ;;
62 | fzf-print-query)
63 | exec fzf -x -i +s --prompt="${menu_prompt:->} " --print-query
64 | ;;
65 | esac
66 |
67 | # vim: set ft=sh :
68 |
--------------------------------------------------------------------------------
/mime-build-types:
--------------------------------------------------------------------------------
1 | #!/usr/bin/mawk -f
2 | #
3 | # Parse /usr/share/mime and build a mime.type file with ERE globs.
4 |
5 | function mergeAliases() {
6 | FS = " "
7 |
8 | while ((getline < aliasesFile) > 0) {
9 | if (! match($1, "^#")) {
10 | Types[$1] = Types[$2]
11 | }
12 | }
13 |
14 | close(aliasesFile)
15 | }
16 |
17 | function mergeGlobs() {
18 | FS = ":"
19 |
20 | while ((getline < globsFile) > 0) {
21 | if (! match($1, "^#")) {
22 | if (length($4)) {
23 | $3 = $3 FS $4
24 | }
25 |
26 | gsub(/\./, "\.", $3)
27 | gsub(/\*/, ".*", $3)
28 |
29 | if (length(Types[$2])) {
30 | Types[$2] = Types[$2] "|" $3
31 | } else {
32 | Types[$2] = $3
33 | }
34 | }
35 | }
36 |
37 | close(globsFile)
38 | }
39 |
40 | function loadTypes() {
41 | while ((getline < typesFile) > 0) {
42 | if (! match($1, "^#")) {
43 | Types[$1] = ""
44 | }
45 | }
46 |
47 | close(typesFile)
48 | }
49 |
50 | BEGIN {
51 | aliasesFile = "/usr/share/mime/aliases"
52 | globsFile = "/usr/share/mime/globs2"
53 | typesFile = "/usr/share/mime/types"
54 | mimeFile = "/tmp/MIME"
55 | split("", Types)
56 |
57 | loadTypes()
58 | mergeGlobs()
59 | mergeAliases()
60 |
61 | for (t in Types) {
62 | print t, Types[t]
63 | }
64 | }
65 |
66 | # vim: set ft=awk :
67 |
--------------------------------------------------------------------------------
/mirror-all-wir-repos:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Mirror all wir git repositories.
4 |
5 | export src
6 | src=${1:-$HOME/src/wir}
7 |
8 | exec rest bitbucket libexec get_repo_urls ssh |
9 | exec xargs -n 1 -P 0 -- sh -c '
10 | set -f
11 | IFS=/
12 |
13 | url=$1
14 | set -- $url
15 | path=$src/$4/${5%.git}
16 |
17 | test -d "$path/.git" &&
18 | exit 1
19 |
20 | command -- mkdir -p -- "$path"
21 |
22 | exec git clone --mirror "$url" "$path/.git"
23 | ' --
24 |
25 | # vim: set ft=sh :
26 |
--------------------------------------------------------------------------------
/msmtpqw:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Replacement for msmtpq.
4 | #
5 | # TODO(d630): finish script
6 |
7 | Q=${XDG_VAR_HOME:?}/mail/queue \
8 | LOG=${XDG_VAR_HOME}/log/msmtp-queue.log \
9 | EMAIL_CONN_TEST=P
10 |
11 | export Q
12 | export LOG
13 | export EMAIL_CONN_TEST
14 |
15 | exec msmtpq "$@"
16 |
17 | __msmpt() { IFS=" " command msmpt $*; }
18 |
19 | lock_queue() {
20 | builtin typeset lock_file=${queue_dir}/.lock
21 | builtin typeset -i \
22 | lock_status= \
23 | sec_max=240 \
24 | SECONDS=
25 |
26 | function make_lock
27 | {
28 | command mkdir "$lock_file"
29 | }
30 |
31 | if
32 | [[ $1 == -u ]]
33 | then
34 | command rm -r "$lock_file"
35 | else
36 | make_lock && lock_status+=1
37 | while
38 | command sleep 0.5 && ( (
39 | lock_status == 0 ||
40 | SECONDS <= sec_max
41 | ))
42 | do
43 | make_lock && lock_status+=1
44 | done
45 | ( (lock_status == 0)) && {
46 | echo fail:
47 | }
48 | fi
49 |
50 | builtin unset -f make_lock
51 | }
52 |
53 | make_id() {
54 | id=$(command date +%Y-%m-%d-%H.%M.%S)-${RANDOM}${RANDOM}${RANDOM}${RANDOM}${RANDOM}${RANDOM}
55 | fqp=${queue_dir}/${id}
56 | }
57 |
58 | send_mail() {
59 | [[ $EMAIL_CONN_TEST != x ]] && connect_test || {
60 | echo fail:
61 | }
62 |
63 | if
64 | __msmpt "$@" <"${fqp}.mail" 1>/dev/null
65 | then
66 | :
67 | else
68 | :
69 | fi
70 | }
71 |
72 | connect_test() {
73 | :
74 | }
75 |
76 | lock_queue() {
77 | :
78 | }
79 |
80 | # vim: set ft=sh :
81 |
--------------------------------------------------------------------------------
/mutt--d630:
--------------------------------------------------------------------------------
1 | ./run-mutt
--------------------------------------------------------------------------------
/mutt--d630-archive:
--------------------------------------------------------------------------------
1 | ./run-mutt
--------------------------------------------------------------------------------
/mutt--gmail:
--------------------------------------------------------------------------------
1 | ./run-mutt
--------------------------------------------------------------------------------
/mutt--gmail-archive:
--------------------------------------------------------------------------------
1 | ./run-mutt
--------------------------------------------------------------------------------
/mutt--hotmail:
--------------------------------------------------------------------------------
1 | ./run-mutt
--------------------------------------------------------------------------------
/mutt--hotmail-archive:
--------------------------------------------------------------------------------
1 | ./run-mutt
--------------------------------------------------------------------------------
/mutt--posteo:
--------------------------------------------------------------------------------
1 | ./run-mutt
--------------------------------------------------------------------------------
/mutt--posteo-archive:
--------------------------------------------------------------------------------
1 | ./run-mutt
--------------------------------------------------------------------------------
/mutt--posteo1:
--------------------------------------------------------------------------------
1 | ./run-mutt
--------------------------------------------------------------------------------
/mutt--posteo1-archive:
--------------------------------------------------------------------------------
1 | ./run-mutt
--------------------------------------------------------------------------------
/mutt--spool:
--------------------------------------------------------------------------------
1 | ./run-mutt
--------------------------------------------------------------------------------
/mutt-save-attachments:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Save attachements in Mutt.
4 | #
5 | # Source: https://github.com/vain/bin-pub/blob/master/mutt-save-attachments
6 |
7 | d=${XDG_TMP_HOME:?}/attachments
8 |
9 | command -- mkdir -p -m 755 -- "$d"
10 |
11 | command -- ripmime --no-nameless -i - -d "$d"
12 | command -- find "$d" -type f -exec chmod 644 {} +
13 | command -- find "$d" -mindepth 1 -type d -exec chmod 755 {} +
14 |
15 | printf 'Saved all attachments to: %s\n' "$d" >&2
16 |
17 | # vim: set ft=sh :
18 |
--------------------------------------------------------------------------------
/news:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Get news.
4 |
5 | exec 9<"$0"
6 | if ! command -- flock -n 9; then
7 | printf 'sorry, I am already running\n' 1>&2
8 | exit 1
9 | fi
10 |
11 | if ! command -- test-inet; then
12 | command -- run-logger 3 .network.error 'We are offline. News have not been updated'
13 | exit 1
14 | fi
15 |
16 | command -- feedfaetcher 1>/dev/null 2>&1
17 | f=$(exec newsboat -x reload print-unread)
18 |
19 | test "${f%% *}" -gt 0 &&
20 | command -- run-logger 6 .transfer.complete "${f%% *} ${f#* }"
21 |
22 | # vim: set ft=sh :
23 |
--------------------------------------------------------------------------------
/open:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Open files or strings in preferred applications.
4 |
5 | # TODO(D630): complete the "string" part.
6 |
7 | flag_A= \
8 | flag_f= \
9 | g= \
10 | m= \
11 | mime= \
12 | opt=
13 |
14 | while getopts :A:f: opt; do
15 | case $opt in
16 | A)
17 | case $OPTARG in
18 | view | vview | edit | vedit | compose | vcompose | dog | cdog | about | gview | gedit | gcompose)
19 | flag_A=${flag_A:+$flag_A }$OPTARG
20 | ;;
21 | *)
22 | printf 'Unknown action: %s\n' "$OPTARG" 1>&2
23 | exit 1
24 | ;;
25 | esac
26 | ;;
27 | f)
28 | readonly flag_f=$OPTARG
29 | ;;
30 | \?)
31 | printf 'Unknown flag: -%s\n' "$OPTARG" 1>&2
32 | exit 1
33 | ;;
34 | esac
35 | done
36 |
37 | if test -z "$flag_f"; then
38 | printf 'File operand is missing\n' 1>&2
39 | exit 1
40 | fi
41 |
42 | eval "$(exec mime_database detect "$flag_f")"
43 |
44 | if test "$m" != ?; then
45 | mime=$m
46 | elif test "$g" != ?; then
47 | mime=$g
48 | else
49 | mime=$(exec file -L -b --mime-type "$flag_f")
50 | fi
51 |
52 | . "${XDG_CONFIG_HOME:?}/mailcap.d/$mime"
53 |
54 | set -f
55 | IFS=' '
56 | set -- $flag_A
57 |
58 | for A in "$@"; do
59 | "$A" "$flag_f" &&
60 | break
61 | printf 'action for mime <%s> was <%s>\n' "$mime" "$A" 1>&2
62 | done
63 |
64 | # vim: set ft=sh :
65 |
--------------------------------------------------------------------------------
/pass2clipboard:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Copy password from pass.
4 |
5 | if command -- test-ctty; then
6 | menu=fzf
7 | else
8 | menu=dmenu2
9 | fi
10 |
11 | read -r file < <(
12 | exec -- find "$HOME/.password-store/" -type f -name \*.gpg -printf %f\\n |
13 | exec -- sed 's/.gpg$//g' |
14 | exec -- sort |
15 | exec -- menu "$menu"
16 | )
17 |
18 | if [[ -f $HOME/.password-store/$file.gpg ]]; then
19 | if [[ $1 == --type ]]; then
20 | exec -- pass show "$file" |
21 | exec -- xdotool type --clearmodifiers --file -
22 | else
23 | PASSWORD_STORE_CLIP_TIME=10 exec -- pass show -c "$file"
24 | fi
25 | fi
26 |
27 | # vim: set ft=zsh :
28 |
--------------------------------------------------------------------------------
/pdf-purge-metadata:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Remove PDF metadata with pdftk and exiftool.
4 |
5 | shopt -s nocaseglob
6 |
7 | if [[ -e ./tmp ]]; then
8 | printf 'There is already a tmp dir.\n' 1>&2
9 | exit 1
10 | elif [[ -e ./pdf_new ]]; then
11 | printf 'There is already a pdf_new dir.\n' 1>&2
12 | exit 1
13 | fi
14 |
15 | command -- mkdir ./tmp ./pdf_new
16 | command -- cp ./*.pdf ./tmp
17 |
18 | while IFS='' read -d '' -r; do
19 | filename=$(exec -- basename "$REPLY")
20 |
21 | # remove XMP-Metadata incrementell
22 | command -- exiftool -all= "$REPLY"
23 |
24 | # then rewrite PDF
25 | exec -- pdftk "$REPLY" dump_data |
26 | exec -- sed -r -e 's/^(InfoValue:).*/\1/g' |
27 | command -- pdftk "$REPLY" update_info - output "./pdf_new/$filename" 2>/dev/null
28 | done < <(exec -- find ./tmp -type f -iname \*.pdf -print0)
29 |
30 | exec -- rm -r ./tmp
31 |
32 | # vim: set ft=zsh :
33 |
--------------------------------------------------------------------------------
/power:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Notify, if battery power is (almost) gone.
4 |
5 | c=$(exec get-battery-capacity)
6 |
7 | ! {
8 | test "$c" -ge 0 -a "$c" -le 25 &&
9 | command -- run-logger 3 .device.error \
10 | "Battery capacity is only $c%. Go and connect charger!"
11 | }
12 |
13 | # vim: set ft=sh :
14 |
--------------------------------------------------------------------------------
/print-apt-conf:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | #
3 | # Print APT config of a single file.
4 |
5 | import apt_pkg
6 | import sys
7 |
8 |
9 | if __name__ == "__main__":
10 | if len(sys.argv) >= 2:
11 | cnf = apt_pkg.Configuration()
12 | apt_pkg.read_config_file(cnf, sys.argv[1])
13 | print(cnf.dump())
14 |
15 | # vim: set ft=python :
16 |
--------------------------------------------------------------------------------
/pwgen2clipboard:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # X-select generated password into clipboard.
4 |
5 | exec run-pwgen |
6 | exec xorg-selection-clipboard-in
7 |
8 | # vim: set ft=sh :
9 |
--------------------------------------------------------------------------------
/pycolor:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | #
3 | # Pick color code.
4 |
5 | import gi
6 | gi.require_version('Gtk', '3.0')
7 | from gi.repository import Gtk
8 |
9 | w = Gtk.ColorSelectionDialog(title="color")
10 | w.show()
11 | w.connect("destroy", Gtk.main_quit)
12 | Gtk.main()
13 |
14 | # vim: set ft=python :
15 |
--------------------------------------------------------------------------------
/pyfonts:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | #
3 | # Display fonts.
4 |
5 | import gi
6 | gi.require_version('Gtk', '3.0')
7 | from gi.repository import Gtk
8 |
9 | w = Gtk.FontSelectionDialog(title="font")
10 | w.show()
11 | w.connect("destroy", Gtk.main_quit)
12 | Gtk.main()
13 |
14 | # vim: set ft=python :
15 |
--------------------------------------------------------------------------------
/readline-editor:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default readline editor.
4 |
5 | IFS=\|
6 | set -f &&
7 | set -- $READLINE_EDITOR_OPTS ${1:+"$@"} &&
8 | exec "$READLINE_EDITOR" "$@"
9 |
10 | # vim: set ft=sh :
11 |
--------------------------------------------------------------------------------
/reconfigure-audio:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Reconfigure audio devices.
4 |
5 | # case $1 in
6 | # (PCH)
7 | # c=PCH;
8 | # d=0;;
9 | # (HDMI)
10 | # c=HDMI;
11 | # d=3;;
12 | # (*)
13 | # printf '?\n';
14 | # exit 1;;
15 | # esac;
16 |
17 | # ed -s "$HOME/".asoundrc </dev/null 2>&1 ||
35 | exit 1
36 |
37 | case $TERM in
38 | linux*)
39 | sudo sh -c '
40 | command -- kbdrate -s -d 250 -r 30.0
41 | command -- kbd_mode -u
42 | command -- loadkeys "$1/xmodmap/us-altgr-intl-german.rc.map"
43 | command -- setterm -bfreq 0 --blength 0
44 | ' -- "$XDG_CONFIG_HOME"
45 | ;;
46 | esac
47 | fi
48 |
49 | # vim: set ft=sh :
50 |
--------------------------------------------------------------------------------
/reconfigure-linux-console-color:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Configure color in linux console.
4 | #
5 | # See: https://github.com/adeverteuil/console-solarized/blob/master/console-solarized
6 |
7 | test -t 1 && command -- fgconsole 1>/dev/null 2>&1 ||
8 | exit 1
9 |
10 | S_base03=002b36
11 | S_base02=073642
12 | S_base01=586e75
13 | S_base00=657b83
14 | S_base0=839496
15 | S_base1=93a1a1
16 | S_base2=eee8d5
17 | S_base3=fdf6e3
18 | S_yellow=b58900
19 | S_orange=cb4b16
20 | S_red=dc322f
21 | S_magenta=d33682
22 | S_violet=6c71c4
23 | S_blue=268bd2
24 | S_cyan=2aa198
25 | S_green=859900
26 |
27 | case $TERM in
28 | linux*)
29 | if test "$1" = light; then
30 | S_rebase03=$S_base3
31 | S_rebase02=$S_base2
32 | S_rebase01=$S_base1
33 | S_rebase00=$S_base0
34 | S_rebase0=$S_base00
35 | S_rebase1=$S_base01
36 | S_rebase2=$S_base02
37 | S_rebase3=$S_base03
38 | else
39 | S_rebase03=$S_base03
40 | S_rebase02=$S_base02
41 | S_rebase01=$S_base01
42 | S_rebase00=$S_base00
43 | S_rebase0=$S_base0
44 | S_rebase1=$S_base1
45 | S_rebase2=$S_base2
46 | S_rebase3=$S_base3
47 | fi
48 | ;;
49 | esac
50 |
51 | printf "\033]P0$S_rebase02" # Black
52 | printf "\033]P1$S_red" # Red
53 | printf "\033]P2$S_green" # Green
54 | printf "\033]P3$S_yellow" # Brown
55 | printf "\033]P4$S_blue" # Blue
56 | printf "\033]P5$S_magenta" # Magenta
57 | printf "\033]P6$S_cyan" # Cyan
58 | printf "\033]P7$S_rebase2" # White
59 | printf "\033]P8$S_rebase03"
60 | printf "\033]P9$S_orange"
61 | printf "\033]Pa$S_rebase01"
62 | printf "\033]Pb$S_rebase00"
63 | printf "\033]Pc$S_rebase0"
64 | printf "\033]Pd$S_violet"
65 | printf "\033]Pe$S_rebase1"
66 | printf "\033]Pf$S_rebase3"
67 |
68 | # vim: set ft=sh :
69 |
--------------------------------------------------------------------------------
/reconfigure-pointer:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Reconfigure pointer.
4 |
5 | : "${XDG_CONFIG_HOME:?}" "${PRODUCT_NAME_SUM:=$(exec get-product-name-as-sha256sum)}"
6 |
7 | command -- test-xorg ||
8 | exit 1
9 |
10 | if test -r "$XDG_CONFIG_HOME/computer/$PRODUCT_NAME_SUM/touchpad"; then
11 | exec get-input-device-names-as-md5sums |
12 | while IFS='' read -r sum; do
13 | if test -e "$XDG_CONFIG_HOME/computer/plug/pointer/$sum"; then
14 | xinput --disable "$(exec cat -- "$XDG_CONFIG_HOME/computer/$PRODUCT_NAME_SUM/touchpad")"
15 | break
16 | fi
17 | done
18 | fi
19 |
20 | exec xset mouse 3 4
21 |
22 | # vim: set ft=sh :
23 |
--------------------------------------------------------------------------------
/reload-sxhkd:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Reload sxhkd config.
4 |
5 | p=${XDG_RUNTIME_DIR:?}/sxhkd${DISPLAY:?}.pid
6 |
7 | test -r "$p" ||
8 | exit 1
9 |
10 | IFS= read -r pp <"$p"
11 |
12 | test -n "$pp" &&
13 | kill -USR1 "$pp"
14 |
15 | # vim: set ft=sh :
16 |
--------------------------------------------------------------------------------
/repeat:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Exec a command n times.
4 |
5 | : "${to:="${1:?}"}" "${2:?}"
6 |
7 | shift 1
8 |
9 | until
10 | from=$((from + 1))
11 | test "$from" -gt "$to"
12 | do
13 | (exec "$@")
14 | done
15 |
16 | :
17 |
18 | # vim: set ft=sh :
19 |
--------------------------------------------------------------------------------
/rest:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: Use several REST APIs.
4 |
5 | case $1 in
6 | bitbucket | confluence | jira | rocketchat)
7 | export API=$1-rest-api
8 | if test "${2:?error: operation missing}" = libexec; then
9 | shift 2
10 | exec "$API-libexec" "$@"
11 | else
12 | shift 1
13 | exec "$API" "$@"
14 | fi
15 | ;;
16 | *)
17 | printf 'error: unknown service %s\n' "$1" >&2
18 | exit 1
19 | ;;
20 | esac
21 |
22 | # vim: set ft=sh noexpandtab :
23 |
--------------------------------------------------------------------------------
/rest-api:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default REST API functions.
4 |
5 | curl() {
6 | exec curl -v -s -n \
7 | -X "$(echo "$method" | exec tr '[:lower:]' '[:upper:]')" \
8 | "${server_address:-.}$endpoint" \
9 | ${1:+"$@"}
10 | }
11 |
12 | delete() {
13 | \curl
14 | }
15 |
16 | get() {
17 | \curl
18 | }
19 |
20 | post() {
21 | \curl -H 'Content-Type: application/json' ${1:+-d "$1"}
22 | }
23 |
24 | main() {
25 | local \
26 | endpoint \
27 | method
28 |
29 | eval "
30 | case \$1 in
31 | (${method_casematch:-delete|get|post})
32 | method=\$1
33 | endpoint=\${2:?'error: endpoint missing'}
34 | ;;
35 | (*)
36 | echo 'error: valid method missing' 1>&2
37 | return 1
38 | ;;
39 | esac
40 | "
41 |
42 | shift 2
43 |
44 | "$method" "$@"
45 | }
46 |
47 | # vim: set ft=sh :
48 |
--------------------------------------------------------------------------------
/restart-dunst:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Restart dunst.
4 |
5 | p=${XDG_RUNTIME_DIR:?}/dunst${DISPLAY:?}.pid
6 |
7 | test -r "$p" &&
8 | command -- pkill -F "$p"
9 |
10 | (
11 | exec dunst -to 10 -config "${XDG_CONFIG_HOME:?}/dunst/dunstrc" &
12 | echo "$!" >"$p"
13 | )
14 |
15 | # vim: set ft=sh :
16 |
--------------------------------------------------------------------------------
/restart-sxhkd:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Restart sxhkd.
4 |
5 | p=${XDG_RUNTIME_DIR:?}/sxhkd${DISPLAY:?}.pid
6 |
7 | test -r "$p" &&
8 | command -- pkill -F "$p"
9 |
10 | (
11 | exec sxhkd -c "$XDG_CONFIG_HOME/sxhkd/sxhkdrc" &
12 | echo "$!" >"$p"
13 | )
14 |
15 | # vim: set ft=sh :
16 |
--------------------------------------------------------------------------------
/rocketchat-rest-api:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: Rocket.Chat REST API.
4 |
5 | . "$(command -v rest-api)" ||
6 | exit
7 |
8 | server_address=${ROCKETCHAT_SERVER_ADDRESS:-https://rocketchat.wir.invalid}
9 | auth_token=${ROCKETCHAT_REST_TOKEN:-$(exec cat -- "$HOME/.rocketchat_wir_invalid_auth_token")}
10 | user_id=${ROCKETCHAT_REST_USER_ID:-z6O73D6HJPjP9viLD}
11 |
12 | unset -v \
13 | ROCKETCHAT_REST_TOKEN \
14 | ROCKETCHAT_REST_USER_ID \
15 | ROCKETCHAT_SERVER_ADDRESS
16 |
17 | curl() {
18 | exec curl -v -s \
19 | -H "X-User-Id: $user_id" \
20 | -H "X-Auth-Token: $auth_token" \
21 | -X "$(echo "$method" | exec tr '[:lower:]' '[:upper:]')" \
22 | "$server_address$endpoint" \
23 | ${1:+"$@"}
24 | }
25 |
26 | get() {
27 | case $endpoint in
28 | channels.list | channels.list.joined | users.list | users.presence)
29 | endpoint=/api/v1/$endpoint?count=999
30 | ;;
31 | login | logout)
32 | endpoint=/api/v1/$endpoint
33 | ;;
34 | esac
35 |
36 | \curl
37 | }
38 |
39 | method_casematch='get|post'
40 | \main "$@"
41 |
42 | # vim: set ft=sh noexpandtab :
43 |
--------------------------------------------------------------------------------
/rocketchat-rest-api-libexec:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Libexec: Rocketchat REST API.
4 |
5 | export API=${API:-${api:-rocketchat-rest-api}}
6 |
7 | f_login() {
8 | local pw
9 | IFS= read -e -s -r -p 'pw: ' pw
10 |
11 | local \
12 | auth_token_file=$HOME/.rocketchat_wir_invalid_auth_token \
13 | user=${1:-'error: user missing'}
14 |
15 | >"$auth_token_file"
16 | command -- chmod 640 "$auth_token_file"
17 |
18 | local auth_token=$(
19 | ROCKETCHAT_REST_TOKEN=. \
20 | ROCKETCHAT_REST_USER_ID=. \
21 | exec -- "$API" post login \
22 | '{"user": "'"$user"'", "password": "'"${pw:?error: pw missing}"'"}' |
23 | exec -- jq -r .data.authToken
24 | )
25 |
26 | if [[ -z "$auth_token" || "$auth_token" == null ]]; then
27 | echo 'login failed' 1>&2
28 | exit 1
29 | fi
30 |
31 | printf '%s\n' "$auth_token" >>"$auth_token_file"
32 | printf '%s\n' "$auth_token"
33 | }
34 |
35 | f_logout() (
36 | local ROCKETCHAT_REST_USER_ID=${1:-'error: user id missing'}
37 |
38 | local auth_token_file=$HOME/.rocketchat_wir_invalid_auth_token
39 | local ROCKETCHAT_REST_TOKEN=$(<"$auth_token_file") ||
40 | exit 1
41 |
42 | export \
43 | ROCKETCHAT_REST_TOKEN \
44 | ROCKETCHAT_REST_USER_ID
45 |
46 | exec -- "$API" post logout |
47 | command -- jq -r .
48 |
49 | exec -- rm -- "$auth_token_file"
50 | )
51 |
52 | ${1:+"f_$@"}
53 |
54 | # vim: set ft=zsh :
55 |
--------------------------------------------------------------------------------
/rocketchat-status:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Set Rocket.Chat online status.
4 |
5 | case ${1:?error: status missing} in
6 | command -- date
7 | away | busy | offline | online)
8 | exec rest rocketchat post /api/v1/users.setStatus "{
9 | \"status\": \"$1\",
10 | \"message\": \"${2:-$1}\"
11 | }" 2>/dev/null |
12 | exec jq -r .
13 | ;;
14 | *)
15 | ! :
16 | ;;
17 | esac
18 |
19 | # vim: set ft=sh :
20 |
--------------------------------------------------------------------------------
/run-black:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run black.
4 |
5 | exec black \
6 | --line-length '88' \
7 | --target-version 'py39' \
8 | --target-version 'py38' \
9 | --target-version 'py37' \
10 | --target-version 'py36' \
11 | --target-version 'py35' \
12 | --include '\.pyi?$' \
13 | --exclude '/(\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\venv|\.venv|_build|buck-out|build|dist)/' \
14 | --safe \
15 | "$@"
16 |
17 | # vim: set ft=sh :
18 |
--------------------------------------------------------------------------------
/run-borg-weekly:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run weekly borg backup.
4 |
5 | hostname=$(exec uname -n | exec tr '[:lower:]' '[:upper:]')
6 |
7 | exec sudo \
8 | HOME=${HOME:?} \
9 | XDG_CACHE_HOME=${XDG_CACHE_HOME:?} \
10 | BORG_REPO=/media/user1/a5a5b889-14f5-475d-86fc-b67bcd8f247a/linux/$hostname/borg/ \
11 | BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=yes \
12 | sh -c '
13 | exec 1>&2
14 |
15 | echo CREATING ...
16 | command -- borg create --warning --progress --stats \
17 | --exclude-caches \
18 | --exclude-nodump \
19 | --exclude-from /dev/stdin \
20 | --comment auto \
21 | --compression none \
22 | ::{now:%Y-%m-%dT%H:%M:%S.%f} \
23 | /etc/ \
24 | /home/ \
25 | /root/ \
26 | /usr/local/ \
27 | /usr/share/chromium/ \
28 | /var/backups/ \
29 | /var/mail/ \
30 | /var/sieve/ \
31 | /var/vmail/ \
32 | /var/www/ <<-EXCLUDE || exit
33 | /home/latch/tmp
34 | /home/latch/var/mirror
35 | $XDG_CACHE_HOME
36 | $HOME/opt
37 | $HOME/.vifm/Trash
38 | EXCLUDE
39 |
40 | echo PRUNING ...
41 | exec borg prune --warning --progress --stats --list --keep-within=12w ::
42 | '
43 |
44 | # vim: set ft=sh noexpandtab :
45 |
--------------------------------------------------------------------------------
/run-chromium-incognito:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run chromium in incognito.
4 |
5 | force_new=1 exec run-chromium --temp-profile --incognito ${1:+"$@"}
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/run-feedfaetcher:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run feedfaetcher.
4 |
5 | feedcacherdir=${XDG_VAR_HOME:?}/lib/feedfaetcher
6 | urllist=$feedcacherdir/urls.txt
7 |
8 | command -- mkdir -p -- "$feedcacherdir"
9 |
10 | if test -n "$1"; then
11 | list=$(exec cat -- "$urllist" - | exec sort -u) <<-IN
12 | $1
13 | IN
14 | echo "$list" >"$urllist"
15 | else
16 | exec feedfaetcher
17 | fi
18 |
19 | # vim: set ft=sh noexpandtab :
20 |
--------------------------------------------------------------------------------
/run-flake8:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run flake8.
4 |
5 | # B All B class violations are reported by flake8-bugbear
6 | # B9 All B9 class violations are optional warnings reported by flake8-bugbear
7 | # C All C class violations are reported by mccabe
8 | # E All E class violations are "errors" reported by pycodestyle
9 | # F All F class violations are reported by pyflakes
10 | # W All W class violations are "warnings" reported by pycodestyle
11 | # T4 All T4 violations are reported by flake8-mypy
12 |
13 | # B950 Line too long
14 | # E501 Line too long (82 > 79 characters)
15 | # T484 Relative import climbs too many namespaces
16 | # W503 Line break before binary operator
17 |
18 | exec flake8 \
19 | --select 'B,C,E,F,W,T4,B9' \
20 | --ignore 'B950,E501,W503' \
21 | --max-line-length '80' \
22 | --max-complexity '18' \
23 | "$@"
24 |
25 | # vim: set ft=sh :
26 |
--------------------------------------------------------------------------------
/run-generate-bookmarks-file:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run generate-bookmarks-file.
4 | # Generates bookmarks.md and converts it into bookmarks.html.
5 |
6 | repo=$HOME/src/bookmarks
7 |
8 | cd -- "$repo" ||
9 | exit 1
10 |
11 | export \
12 | GIT_DIR \
13 | GIT_WORK_TREE
14 | GIT_WORK_TREE=$repo
15 | GIT_DIR=$repo/.git
16 |
17 | command -- generate-bookmarks-file >bookmarks.md &&
18 | command -- pandoc --metadata title=bookmarks bookmarks.md -f markdown -s -o bookmarks.html &&
19 | command -- git add bookmarks.md bookmarks.html &&
20 | command -- git commit -m "$(exec fortune -as -n 80)" &&
21 | exec git push -u --tags origin master
22 |
--------------------------------------------------------------------------------
/run-grabc:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Run grabc.
4 |
5 | c=$(exec -- grabc |& exec -- grep -o -e '#.*')
6 | printf %s "${c^^}"
7 |
8 | # vim: set ft=zsh :
9 |
--------------------------------------------------------------------------------
/run-idea:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run intellij-idea-ultimate.
4 |
5 | command -- mkdir -p "/tmp/${USER:-$(exec id -un)}"
6 |
7 | exec env \
8 | -u _JAVA_OPTIONS \
9 | _JAVA_AWT_WM_NONREPARENTING=1 \
10 | intellij-idea-ultimate "$@"
11 |
12 | # vim: set ft=sh :
13 |
--------------------------------------------------------------------------------
/run-imapfilter:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run imapfilter with specific conf file.
4 |
5 | case $1 in
6 | localhost-unseen | localhost-delete | localhost-action)
7 | set -- -c "$HOME/.imapfilter/$1.lua"
8 | ;;
9 | *)
10 | exit 1
11 | ;;
12 | esac
13 |
14 | exec imapfilter -l "${XDG_VAR_HOME:?}/log/imapfilter.log" "$@"
15 |
16 | # vim: set ft=sh :
17 |
--------------------------------------------------------------------------------
/run-isort:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run isort.
4 |
5 | exec isort \
6 | --multi-line=3 \
7 | --trailing-comma \
8 | --force-grid-wrap=0 \
9 | --use-parentheses \
10 | --line-width=88 \
11 | "$@"
12 |
13 | # vim: set ft=sh :
14 |
--------------------------------------------------------------------------------
/run-logger:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run logger.
4 | #
5 | # For local scripting.
6 | # Needs facility local6 to work properly with my configured rsyslog.
7 | #
8 | # $ run-logger level category [summary [body]]
9 |
10 | l=$1
11 | c=$2
12 |
13 | shift 2
14 |
15 | exec logger -d -s --id="$PPID" \
16 | -t "$(exec basename "$(exec strings "/proc/$PPID/cmdline")")" \
17 | -p "local6.$l" "$c" "$@"
18 |
19 | # vim: set ft=sh :
20 |
--------------------------------------------------------------------------------
/run-mutt:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Run mutt.
4 |
5 | export LOCAL_CONFIG
6 |
7 | cmd=${BASH_SOURCE[0]##*/mutt--}
8 | cmd=${cmd//-/.}
9 |
10 | case $cmd in
11 | d630 | d630.archive | \
12 | gmail | gmail.archive | \
13 | hotmail | hotmail.archive | \
14 | posteo | posteo.archive | \
15 | posteo1 | posteo1.archive | \
16 | spool)
17 | LOCAL_CONFIG=$cmd
18 | ;;
19 | *)
20 | if [[ -n $MUTT_LOCAL_CONFIG ]]; then
21 | LOCAL_CONFIG=$MUTT_LOCAL_CONFIG
22 | else
23 | unset -v LOCAL_CONFIG
24 | fi
25 | ;;
26 | esac
27 |
28 | exec -- mutt -n "$@"
29 |
30 | # vim: set ft=zsh :
31 |
--------------------------------------------------------------------------------
/run-mypy:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run mypy.
4 |
5 | # --python-version '3.5'
6 |
7 | exec mypy \
8 | --platform linux \
9 | --follow-import normal \
10 | --ignore-missing-imports \
11 | --disallow-untyped-calls \
12 | --warn-return-any \
13 | --strict-optional \
14 | --warn-no-return \
15 | --warn-redundant-casts \
16 | --warn-unused-ignores \
17 | --disallow-untyped-defs \
18 | --check-untyped-defs \
19 | --cache-dir /dev/null \
20 | "$@"
21 |
22 | # vim: set ft=sh :
23 |
--------------------------------------------------------------------------------
/run-notify-send:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run notify-send.
4 | #
5 | # TODO(d630): multiplexer?
6 |
7 | : "${XDG_RUNTIME_DIR:=/run/user/1000}"
8 | : "${DBUS_SESSION_BUS_ADDRESS:=unix:path=$XDG_RUNTIME_DIR/bus}"
9 | : "${DISPLAY:=:0}"
10 | export DBUS_SESSION_BUS_ADDRESS DISPLAY XDG_RUNTIME_DIR
11 |
12 | if test -p /dev/stdin || test -f /dev/stdin; then
13 | read -r urgency category body
14 | else
15 | urgency=$1
16 | category=$2
17 | body=$3
18 | fi
19 |
20 | case $urgency in
21 | emerg | alert | crit | err | [0-3])
22 | urgency=critical
23 | ;;
24 | warning | notice | debug | [4,5,7])
25 | urgency=normal
26 | ;;
27 | info | 6)
28 | urgency=low
29 | ;;
30 | *)
31 | exit 1
32 | ;;
33 | esac
34 |
35 | test -f "$XDG_RUNTIME_DIR/.dunst_use_$urgency$DISPLAY" &&
36 | exec notify-send -u "$urgency" "--category=$category" "$category" "$body"
37 |
38 | # vim: set ft=sh :
39 |
--------------------------------------------------------------------------------
/run-pidgin:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run pidgin.
4 |
5 | sudo systemctl start avahi-daemon &&
6 | exec pidgin
7 |
8 | # vim: set ft=sh :
9 |
--------------------------------------------------------------------------------
/run-pwgen:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run pwgen.
4 |
5 | until test "${#p}" -ge 256; do
6 | p=$(
7 | exec pwgen -cnsyC -N 64 -r \'\"\`\$\\ |
8 | exec tr -dc "${1:-[:graph:]}"
9 | )
10 | done
11 |
12 | printf '%s' "$p" |
13 | exec cut -b "1-${2:-64}"
14 |
15 | # vim: set ft=sh :
16 |
--------------------------------------------------------------------------------
/run-rtcwake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Run rtcwake in mem mode and play music/radio on wakeup.
4 |
5 | function bye {
6 | printf 'Bye-bye!\n' 1>&2
7 | exit "${1:-0}"
8 | }
9 |
10 | if command -- test-xorg; then
11 | function __menu {
12 | command -- menu dmenu2 "$1"
13 | }
14 | elif command -- test-ctty; then
15 | function __menu {
16 | command -- menu fzf "$1"
17 | }
18 | else
19 | bye 1
20 | fi
21 |
22 | declare -A music=(
23 | [radio1]=http://www.radioeins.de/live.m3u
24 | [open]=${XDG_MUSIC_DIR:?}/open_your_eyes.mp3
25 | )
26 |
27 | days=(
28 | "$(exec -- date --date=now +%F)"
29 | "$(exec -- date --date=tomorrow +%F)"
30 | )
31 |
32 | date_time=$(
33 | for d in "${days[@]}"; do
34 | printf '%s\n' "$d "{00..23}:{00..59}
35 | done |
36 | __menu "Date (now: $(date +%R))"
37 | )
38 | [[ -n $date_time ]] || bye
39 |
40 | key=$(printf "%s\n" "${!music[@]}" | __menu Play)
41 | [[ -n $key ]] || bye
42 |
43 | go=$(printf %s\\n exit "rtcwake $date_time $key" | __menu Run)
44 |
45 | if [[ -n $go && $go != exit ]]; then
46 | command -- sudo rtcwake --mode mem --time "$(exec -- date -d "$date_time" +%s)" ||
47 | exit 1
48 | command -- sleep 10 && exec -- audio-player --loop=inf "${music[$key]}"
49 | else
50 | bye
51 | fi
52 |
53 | # vim: set ft=zsh :
54 |
--------------------------------------------------------------------------------
/run-scrot:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run scrot.
4 |
5 | command -- mkdir -p /tmp/screenshots
6 |
7 | cd /tmp/screenshots ||
8 | exit 1
9 |
10 | exec scrot \
11 | '%Y-%m-%d--%s_$wx$h.png' \
12 | -q 100 \
13 | -d 3 \
14 | ${1:+"$@"}
15 |
16 | # vim: set ft=sh :
17 |
--------------------------------------------------------------------------------
/run-source-highlight:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run source-highlight.
4 |
5 | trap 'exec tput sgr0' EXIT
6 |
7 | for f; do
8 | command -- source-highlight \
9 | --failsafe \
10 | --infer-lang \
11 | -f esc-solarized \
12 | --outlang-def="${XDG_DATA_HOME:?}/source-highlight/solarized/esc-solarized.outlang" \
13 | --style-file="$XDG_DATA_HOME/source-highlight/solarized/esc-solarized.style" \
14 | -o STDOUT \
15 | --tab=4 \
16 | --line-number=0 \
17 | -i "$f"
18 | echo
19 | done
20 |
21 | # vim: set ft=sh :
22 |
--------------------------------------------------------------------------------
/run-spotify:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run spotify.
4 |
5 | exec spotify \
6 | --force-unicast-discovery \
7 | --force-device-scale-factor="${GDK_SCALE:-1}"
8 |
9 | # vim: set ft=sh :
10 |
--------------------------------------------------------------------------------
/run-transmission-cli:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run transmission-cli.
4 |
5 | exec transmission-cli -er -d 400 -u 25 -w "${XDG_DOWNLOAD_DIR:?}/torrents" "$@"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/run-vncserver:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run vncserver.
4 |
5 | exec vncserver -localhost no -geometry 2560x1440 "$@"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/run-weechat:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run weechat.
4 |
5 | command -- test-xorg &&
6 | exec x-terminal -a -c st-256color -n weechatw -t weechatw -e weechat
7 |
8 | # vim: set ft=sh :
9 |
--------------------------------------------------------------------------------
/run-z:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run z output and open dir in file manager.
4 |
5 | if command -- test-ctty; then
6 | menu=fzf
7 | __nav() {
8 | exec file-browser "$1"
9 | }
10 | elif test-xorg; then
11 | menu=dmenu2
12 | __nav() {
13 | exec daemonize x-file-browser -t "$1"
14 | }
15 | else
16 | exit 1
17 | fi
18 |
19 | path=$(
20 | exec sort -g "${XDG_VAR_HOME:?}/lib/z/z.data" |
21 | exec cut -d \| -f 1 |
22 | exec menu "$menu" cd
23 | )
24 |
25 | test -d "$path" &&
26 | __nav "$path"
27 |
28 | # vim: set ft=sh :
29 |
--------------------------------------------------------------------------------
/schlafe:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # My very creative suspend wrapper.
4 |
5 | # sudo rtcwake -m mem -t "$(exec date -d year +%s)";
6 | exec systemctl suspend ${1:+"$@"}
7 |
8 | # vim: set ft=sh :
9 |
--------------------------------------------------------------------------------
/sdmenu:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run dmenu2-save menu.
4 |
5 | command -- test-xorg &&
6 | exec menu dmenu2-save ${1:+"$@"} 0<&-
7 |
8 | # vim: set ft=sh :
9 |
--------------------------------------------------------------------------------
/skel-home:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Prepare home directory.
4 |
5 | set -e
6 |
7 | typeset -A XDG=(
8 | [BIN_HOME]=$HOME/bin
9 | [CACHE_HOME]=$HOME/var/cache
10 | [CONFIG_HOME]=$HOME/etc
11 | [DATA_HOME]=$HOME/share
12 | [DESKTOP_DIR]=$HOME/share/desktop
13 | [OPT_HOME]=$HOME/opt
14 | [PUBLICSHARE_DIR]=$HOME/var/public
15 | [SRC_DIR]=$HOME/src
16 | [TEMPLATES_DIR]=$HOME/share/templates
17 | [VAR_HOME]=$HOME/var
18 | )
19 |
20 | typeset -A XDG2=(
21 | [BACKUP_HOME]=/home/files/var/backups
22 | [DOCUMENTS_DIR]=/home/files/share/documents
23 | [DOWNLOAD_DIR]=/home/files/tmp/downloads
24 | [MUSIC_DIR]=/home/files/share/music
25 | [PICTURES_DIR]=/home/files/share/pictures
26 | [TMP_HOME]=/home/files/tmp
27 | [VIDEOS_DIR]=/home/files/share/videos
28 | )
29 |
30 | function doit() {
31 | command -- mkdir -vp -- "$1"
32 | echo \* >"$1/.gitignore"
33 | }
34 |
35 | function forit() {
36 | for d in "$@"; do
37 | doit "$d" &
38 | done
39 | }
40 |
41 | forit "${XDG[@]}" "$HOME/"{.cabal,.ghc,.cpanm,.vim/{autoload,bundle},.emacs.d/site-lisp,.config,.local,games,include,lib/bash,sbin,man}
42 | forit "${XDG[OPT_HOME]}/"{cabal,cpanm,go,misc/bin,npm,perl5,win32,win64}
43 | forit "${XDG[DATA_HOME]}/"{applications,Trash,cert,fonts,icons,sounds,themes,wallpapers,bash,zsh,desktop,keyrings,texmf/tex/latex,doc,locale,ca-certificates,dircolors,man,mutt,xcolors,source-highlight,webkit,X11}
44 | forit "${XDG[VAR_HOME]}/"{lib,log,mail/{storage,queue},spool,tmp}
45 |
46 | for d in "${XDG2[@]}" /home/{files,stow,stow-data}; do
47 | command -- sudo mkdir -vp -- "$d"
48 | command -- sudo chown -Rv "$USER:$USER" -- "$d"
49 | echo \* >"$d/".gitignore
50 | done
51 |
52 | forit "${XDG2[TMP_HOME]}/"{attachments,downloads/torrents}
53 | doit "${XDG2[BACKUP_HOME]}/bash"
54 |
55 | wait
56 |
57 | # vim: set ft=zsh :
58 |
--------------------------------------------------------------------------------
/sort-ipv4:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Sort ipv4 addreses from stdin
4 |
5 | set -- "${1:-n}"
6 |
7 | exec sort -t . -k "1,1$1" -k "2,2$1" -k "3,3$1" -k "4,4$1"
8 |
9 | # vim: set ft=sh :
10 |
--------------------------------------------------------------------------------
/sound:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Play specific sounds.
4 |
5 | if test -p /dev/stdin || test -f /dev/stdin; then
6 | read -r urgency summary _
7 | else
8 | summary=$2
9 | urgency=$1
10 | fi
11 |
12 | case $urgency in
13 | CRITICAL | [0-3])
14 | urgency=true
15 | ;;
16 | *)
17 | urgency=false
18 | ;;
19 | esac
20 |
21 | set -f
22 | IFS=
23 |
24 | case $summary in
25 | .device.added)
26 | f=mac-sound-pack-Device_Connect.wav
27 | ;;
28 | .device.removed)
29 | f=mac-sound-pack-Device_Disconnect.wav
30 | ;;
31 | .device*)
32 | $urgency && f=mac-sound-pack-Device_Failed.wav
33 | ;;
34 | .email.arrived)
35 | f=mac-sound-pack-new-mail.wav
36 | ;;
37 | .email.bounced)
38 | f=mac-sound-pack-mail-sent.wav
39 | ;;
40 | .email*)
41 | $urgency && f=mac-sound-pack-Error.wav
42 | ;;
43 | .email.nomail)
44 | f=mac-sound-pack-no-mail.wav
45 | ;;
46 | .im*)
47 | $urgency && f=mac-sound-pack-Error.wav
48 | ;;
49 | .im.sent)
50 | f=mac-sound-pack-sent-message.wav
51 | ;;
52 | .im.received)
53 | f=mac-sound-pack-received-message.wav
54 | ;;
55 | .misc.exclamation)
56 | f=mac-sound-pack-Exclamation.wav
57 | ;;
58 | .misc*)
59 | $urgency && f=mac-sound-pack-Error.wav
60 | ;;
61 | .network.connected)
62 | f=mac-sound-pack-invitation-accepted.wav
63 | ;;
64 | .network.disconnected)
65 | f=mac-sound-pack-invitation.wav
66 | ;;
67 | .network*)
68 | $urgency && f=mac-sound-pack-Error.wav
69 | ;;
70 | .presence.offline)
71 | f=mac-sound-pack-buddy-logging-out.wav
72 | ;;
73 | .presence.online)
74 | f=mac-sound-pack-buddy-logging-in.wav
75 | ;;
76 | .transfer.complete)
77 | f=mac-sound-pack-file-transfer-complete.wav
78 | ;;
79 | .transfer*)
80 | $urgency && f=mac-sound-pack-Error.wav
81 | ;;
82 | esac
83 |
84 | exec aplay "${XDG_DATA_HOME:-/home/user1/share}/sounds/${f:?}" 1>/dev/null 2>&1
85 |
86 | # vim: set ft=sh
87 |
--------------------------------------------------------------------------------
/spotify-mpris:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Control spotify via mpris player interface.
4 |
5 | case ${1:?} in
6 | Next | Previous | Pause | PlayPause | Stop)
7 | exec dbus-send \
8 | --print-reply \
9 | --dest=org.mpris.MediaPlayer2.spotify \
10 | /org/mpris/MediaPlayer2 \
11 | "org.mpris.MediaPlayer2.Player.$1"
12 | ;;
13 | *)
14 | printf 'errror: unknown method\n' 1>&2
15 | exit 1
16 | ;;
17 | esac
18 |
19 | # vim: set ft=sh :
20 |
--------------------------------------------------------------------------------
/ssudo:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Use sudo with sdmenu via SUDO_ASKPASS.
4 |
5 | exec env SUDO_ASKPASS=${XDG_BIN_HOME:?}/sdmenu sudo -A -- "$@"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/startx.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # My mini wrapper for xinit.
4 | #
5 | # Allow only one xserver; start always on /dev/tty1 and use :0.
6 | #
7 | # $ . startx.sh
8 |
9 | function __startx {
10 | if ! ((EUID)); then
11 | printf '%s: May not run as superuser; aborting\n' "${FUNCNAME[0]}" 1>&2
12 | return 1
13 | fi
14 |
15 | declare -i c
16 | c=$(exec -- fgconsole 2>/dev/null)
17 |
18 | if ((c != 1)); then
19 | printf '%s: Not on /dev/tty1; aborting\n' "${FUNCNAME[0]}" 1>&2
20 | return 1
21 | fi
22 |
23 | command -- rm -rf /tmp/.X11-unix 2>/dev/null
24 |
25 | #umask 077
26 | #cp -bf "$XERRFILE" "$XERRFILE" 2>/dev/null;
27 | # rm -f "$XERRFILE" 2>/dev/null;
28 | # touch "$XERRFILE" && chmod 600 "$XERRFILE" || return 1;
29 |
30 | declare hn mc sxauth
31 | hn=$(exec -- hostname -f)
32 | mc=$(exec -- mcookie)
33 | sxauth=$(exec -- mktemp --tmpdir serverauth.XXXXXXXXXX)
34 |
35 | command -- xauth -q remove :0 "$hn:0" "$hn/unix:0"
36 | command -- xauth -q <<-IN
37 | add :0 . $mc
38 | add $hn:0 . $mc
39 | add $hn/unix:0 . $mc
40 | IN
41 |
42 | command -- logger --id="$$" -t startx.sh -p user.info "Initializing X session for $LOGNAME"
43 |
44 | (
45 | cd -- "$HOME" ||
46 | exit 1
47 | exec 1> >(exec -- logger -e --id=$$ -t Xorg.0 -p user.notice) 2>&1
48 | exec -- xinit "$XINITRC" -- "$HOME/.xserverrc" -auth "$sxauth"
49 | )
50 |
51 | command -- logger --id=$$ -t startx.sh -p user.info "Finishing X session for $LOGNAME"
52 |
53 | # TODO
54 | command -- dbus-update-activation-environment DISPLAY=
55 | command -- systemctl --user unset-environment DISPLAY
56 |
57 | command -- daylight
58 | }
59 |
60 | __startx
61 | unset -f __startx
62 |
63 | # vim: set ft=zsh :
64 |
--------------------------------------------------------------------------------
/stat2assoc:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Stat a file and build an associative bash array.
4 |
5 | if [[ $1 == -f ]]; then
6 | shift 1
7 |
8 | { exec -- stat --file-system --printf="$("$XDG_RUNTIME_DIR/stj1"
15 | exec "$0"
16 | '
17 | }
18 |
19 | read -r id <"${XDG_RUNTIME_DIR:?}/stj1" 2>/dev/null
20 |
21 | command -- xprop -id "0x$id" 1>/dev/null 2>&1 ||
22 | dz st-dark st-light
23 |
24 | if exec xprop -root -notype -f _NET_CLIENT_LIST 32x \$0+, _NET_CLIENT_LIST |
25 | command -- grep -F -q "0x$id,"; then
26 | exec xdotool windowunmap "0x$id"
27 | else
28 | #xdotool mousemove --sync 0 0
29 | exec xdotool windowmap --sync "0x$id"
30 | #wmctrl -i -a "0x${id}"
31 | #xdotool windowraise "0x${id}"
32 | #xdotool windowfocus --sync "0x${id}"
33 | #xdotool mousemove --sync 0 0
34 | fi
35 |
36 | # vim: set ft=sh :
37 |
--------------------------------------------------------------------------------
/swaptop:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Display most swap-using processes.
4 | #
5 | # Source: http://chneukirchen.org/dotfiles/bin/swaptop
6 |
7 | if command -- grep -q -F VmSwap /proc/1/status; then
8 | exec mawk '
9 | /^Name:/ {
10 | name = $2
11 | };
12 | /^Pid:/ {
13 | pid = $2
14 | };
15 | /^VmSwap:/ {
16 | swap = $2
17 | if (swap > 0) {
18 | printf "%8d %s %d\n", swap, name, pid
19 | }
20 | }
21 | ' /proc/[0-9]*/status |
22 | exec sort -r
23 | else
24 | for f in /proc/[0-9]*; do
25 | command -- mawk '
26 | BEGIN {
27 | swap = 0
28 | };
29 | $30 {
30 | pid = $1;
31 | name = substr($2, 2, length($2) - 2)
32 | };
33 | $1 == "Swap:" {
34 | swap += $2
35 | };
36 | END {
37 | if (swap > 0) {
38 | printf "%8d %s %d\n", swap, name, pid
39 | }
40 | }
41 | ' "$f/stat" "$f/smaps" 2>/dev/null
42 | done |
43 | exec sort -r
44 | fi
45 |
46 | # vim: set ft=sh :
47 |
--------------------------------------------------------------------------------
/task-calc:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run task cals: Calculate dates via taskwarrior.
4 |
5 | exec task calc "$@"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/task-colors:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run task colors: Display color info in terminal.
4 |
5 | printf 'TERM: %s\nCOLORS: %d\nLONGNAME: %s\n' \
6 | "$TERM" \
7 | "$(exec tput colors)" \
8 | "$(exec tput longname)"
9 |
10 | exec task rc._forcecolor=on colors
11 | # weechat -c;
12 |
13 | # vim: set ft=sh :
14 |
--------------------------------------------------------------------------------
/task-local:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Simple wrapper for using taskwarrior with local "task-repos".
4 |
5 | export TASKRC=${TASKRC:-$PWD/.task/taskrc}
6 |
7 | case $1 in
8 | init)
9 | if test -d "$PWD/.task"; then
10 | printf '%s:Error:82: Could not create a task repository: "%s/.task/" already exists\n' \
11 | "$0" "$PWD" 1>&2
12 | exit 82
13 | else
14 | command -- mkdir -p -- "$PWD/.task/data" &&
15 | exec task config data.location "$PWD/.task/data"
16 | fi
17 | ;;
18 | --)
19 | shift 1
20 | exec task "$@"
21 | ;;
22 | *)
23 | printf '%s:Error:83: Unknown parameter: %s\n' "$0" "$1" 1>&2
24 | exit 83
25 | ;;
26 | esac
27 |
28 | # vim: set ft=sh :
29 |
--------------------------------------------------------------------------------
/taskum-add:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Add a bookmark to taswarrior-um (used in newsbeuter/newsboat).
4 |
5 | exec taskum add "uri:${1:?}" "name:$2" "note:$3"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/template:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Prepare new file from a template.
4 | #
5 | # TODO(D630): Use awk instead of tr and sed.
6 |
7 | : "${1:? need arg}"
8 |
9 | FFILE=${1##*/}
10 | EXT=${FFILE#*.}
11 | test "$FFILE" = "$EXT" &&
12 | EXT=
13 |
14 | if ! test -r "${XDG_TEMPLATES_DIR:?}/${EXT:-_}"; then
15 | printf 'no template found\n' 1>&2
16 | exit 1
17 | fi
18 |
19 | FILE=${FFILE%.$EXT}
20 |
21 | test -n "$FILE" ||
22 | FILE=x
23 |
24 | GUARD=$(
25 | exec tr -c '[a-zA-Z0-9]' '_' </dev/null 2>&1
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/test-inet:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Test inet connection by trying to connect/ping to google.
4 |
5 | exec >/dev/null 2>&1
6 | echo >/dev/tcp/8.8.8.8/53 ||
7 | exec -- ping -qnc1 -w4 8.8.8.8
8 |
9 | # vim: set ft=zsh :
10 |
--------------------------------------------------------------------------------
/test-xorg:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Test whether we are in an X session.
4 |
5 | # XDG_VTNR is not set, when using TigerVNC
6 | command -- systemctl is-active graphical.target 1>/dev/null 2>&1 &&
7 | test -n "$DISPLAY"
8 |
9 | # vim: set ft=sh :
10 |
--------------------------------------------------------------------------------
/text-editor:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default text editor.
4 |
5 | IFS=\|
6 | set -f &&
7 | set -- $EDITOR_OPTS ${1:+"$@"} &&
8 | exec "$EDITOR" "$@"
9 |
10 | # vim: set ft=sh :
11 |
--------------------------------------------------------------------------------
/text-visual:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default text visual editor.
4 |
5 | IFS=\|
6 |
7 | set -f &&
8 | set -- $VISUAL_OPTS ${1:+"$@"} &&
9 | exec "$VISUAL" "$@"
10 |
11 | # vim: set ft=sh :
12 |
--------------------------------------------------------------------------------
/todo:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: Use taskwarrior in my 'todo' context.
4 |
5 | TASKRC=$XDG_CONFIG_HOME/taskwarrior/taskrc-todo exec task "$@"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/todo-editor:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Add a task to Taskwarrior ('todo' context) via vim (yaml).
4 |
5 | export TASKRC=${XDG_CONFIG_HOME:?}/taskwarrior/taskrc-todo
6 |
7 | eval "$(exec date '+s=%s d=%Y-%m-%d t=%H:%M')"
8 | f=${TMPDIR:-${XDG_RUNTIME_DIR}/tmp}/$s.task
9 |
10 | trap 'exec rm -- "$f"' EXIT
11 |
12 | command -- cat >"$f" </dev/tty ||
51 | exit 1
52 |
53 | exec yaml2json <"$f" |
54 | exec jq 'if (.description | length) > 0 then . else empty end' |
55 | exec task import -
56 |
57 | # vim: set ft=sh :
58 |
--------------------------------------------------------------------------------
/update-all-wir-repo-mirrors:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Update all mirrored wir git repositories.
4 |
5 | src=${1:-$HOME/src/wir}
6 |
7 | exec find -H "$src" \
8 | -mindepth 2 \
9 | -maxdepth 2 \
10 | -type d \
11 | -print0 |
12 | exec xargs -0 -n 1 -P 0 -- sh -c '
13 | test -d "$1/.git" ||
14 | exit 1
15 |
16 | export \
17 | GIT_DIR \
18 | GIT_WORK_TREE
19 | GIT_WORK_TREE=$1
20 | GIT_DIR=$1/.git
21 |
22 | eval "$(exec git config --local --get --bool core.bare)" &&
23 | exec git remote update --prune
24 | ' --
25 |
26 | # vim: set ft=sh :
27 |
--------------------------------------------------------------------------------
/update-packages:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Update software packages via some package managers.
4 |
5 | cd -- "${XDG_OPT_HOME:?}" ||
6 | exit 1
7 |
8 | printf -v horiz %80s
9 | .hd() {
10 | printf '%s\n' "${horiz// /-}" "$1" "${horiz// /-}" 1>&2
11 | }
12 |
13 | .hd 'apt and snap'
14 | command -- sudo sh -c '
15 | command -- apt-get update;
16 | #apt-get -y dist-upgrade
17 | command -- apt-get -y upgrade
18 | #apt-get autoremove --purge;
19 | #apt-get autoclean;
20 | exec snap refresh;
21 | '
22 |
23 | # .hd cabal\ packages;
24 | # cabal v1-update;
25 | # cabal v1-install world --upgrade-dependencies --force-reinstalls;
26 |
27 | # .hd composer\ packages;
28 | # composer global update;
29 |
30 | # .hd cpan\ modules;
31 | # cpan-outdated -p --exclude-core |
32 | # cpanm -iv --self-contained;
33 |
34 | # .hd go\ packages;
35 | # go get -v -u "$GOPATH/...";
36 |
37 | .hd latch
38 | command -- /home/latch/bin/latch mr mirror
39 |
40 | # .hd npm\ modules;
41 | # npm update -g;
42 |
43 | # .hd python3;
44 | # python3 -m pip freeze --user |
45 | # sed 's:==.*::' |
46 | # xargs python3 -m pip install --user --upgrade;
47 |
48 | # vim: set ft=zsh :
49 |
--------------------------------------------------------------------------------
/volume:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Set volume via amixer.
4 |
5 | case $1 in
6 | \+)
7 | set -- 2+
8 | ;;
9 | \+\+)
10 | set -- 2%+
11 | ;;
12 | -)
13 | set -- 2-
14 | ;;
15 | --)
16 | set -- 2%-
17 | ;;
18 | toggle)
19 | set -- toggle
20 | ;;
21 | *)
22 | exit 1
23 | ;;
24 | esac
25 |
26 | exec amixer -q sset Master "$@"
27 |
28 | # vim: set ft=sh :
29 |
--------------------------------------------------------------------------------
/watch-all-confluence-spaces:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Watch all spaces on confluence.
4 |
5 | exec rest confluence libexec watch_spaces post d630 >/dev/null 2>&1
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/watch-all-wir-repos:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Watch all wir git repositories on bitbucket.
4 |
5 | exec rest bitbucket libexec watch_repos post 2>/dev/null
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/web-browser:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default web browser (tui).
4 |
5 | IFS=\|
6 |
7 | set -f &&
8 | set -- ${BROWSER_OPTS} ${1:+"$@"} &&
9 | exec "$BROWSER" "$@"
10 |
11 | # vim: set ft=sh :
12 |
--------------------------------------------------------------------------------
/webheader:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Get webheader via curl.
4 |
5 | exec curl \
6 | --compressed \
7 | --head \
8 | --junk-session-cookies \
9 | --location \
10 | --max-redirs 50 \
11 | --no-keepalive \
12 | --no-sessionid \
13 | --proto-redir -all,http,https \
14 | --proto -all,http,https \
15 | --referer ';auto' \
16 | --stderr - \
17 | --no-styled-output \
18 | ${1:+"$@"}
19 |
20 | # vim: set ft=sh :
21 |
--------------------------------------------------------------------------------
/wlan-down:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: Set wlan off.
4 |
5 | exec sudo -- "${XDG_BIN_HOME:?}/reconfigure-network-device" \w -d
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/wlan-up:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Wrapper: Set wlan on.
4 |
5 | exec sudo -- "${XDG_BIN_HOME:?}/reconfigure-network-device" \w -c
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/wless:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Open the result of command -v in less.
4 |
5 | exec less "$(command -v "${1:?}")"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/wots:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Handle stow packages.
4 |
5 | arg1=${1:?args}
6 | dir=
7 |
8 | shift 1
9 |
10 | wrapper() {
11 | exec -- xstow -v 3 \
12 | -F /home/latch/etc/xstow/local.ini \
13 | -dir "$dir" \
14 | -target "$HOME" \
15 | "${@:?package missing}"
16 | }
17 |
18 | new() {
19 | set -- "${1:?need a name}" "${2:-$HOSTNAME}" "${3:-$USER}"
20 |
21 | declare s
22 | s=$(IFS=; exec -- md5sum <<<"$*")
23 | s=${s%% *}
24 |
25 | command -- mkdir -v -- "$dir/$s" ||
26 | exit 1
27 |
28 | . "$dir/map" && command -- mv -v -- "$dir/map" "$dir/map~" ||
29 | declare -A map
30 |
31 | map[$s]=$2/$3/$1
32 |
33 | declare -p map >"$dir/map"
34 |
35 | command -- chmod -v 750 "$dir/$s"
36 | >"$dir/$s/.gitignore"
37 | command -- ln -vfrs -- "$dir/$s" "$dir/$1"
38 |
39 | declare -x \
40 | GIT_DIR=$dir/$s/.git \
41 | GIT_WORK_TREE=$dir/$s
42 |
43 | command -- git init
44 | command -- git add -f .gitignore
45 | exec -- git commit -m I
46 | }
47 |
48 | case $arg1 in
49 | stow | stow-data)
50 | dir=/home/$arg1
51 | wrapper "$@"
52 | ;;
53 | new-stow | new-stow-data)
54 | dir=/home/${arg1#new-}
55 | new "$@"
56 | ;;
57 | *)
58 | exit 1
59 | ;;
60 | esac
61 |
62 | # vim: set ft=zsh :
63 |
--------------------------------------------------------------------------------
/wradio:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Simple wradio.
4 | #
5 | # Forked from webradio.sh (GNU GPLv3) by Markus Lux, 2013
6 | # https://github.com/mlux/webradio.sh/blob/master/webradio.sh
7 |
8 | file_webradio_streams=${XDG_VAR_HOME:?}/lib/wradio/streams
9 | file_webradio_pid=${XDG_VAR_HOME:?}/lib/wradio/instance.pid
10 |
11 | if command -- test-ctty; then
12 | __menu() {
13 | command -- menu fzf PLAY
14 | }
15 | elif [[ -n $DISPLAY ]]; then
16 | __menu() {
17 | command -- menu dmenu2 PLAY
18 | }
19 | else
20 | exit 1
21 | fi
22 |
23 | __build_streams() {
24 | typeset \
25 | name \
26 | uri
27 |
28 | while IFS=\; read -r name uri; do
29 | streams[$name]=$uri
30 | done <"$file_webradio_streams"
31 | }
32 |
33 | __selectstream() {
34 | printf %s\\n STOPSTREAM "${!streams[@]}" |
35 | exec -- sort -u |
36 | __menu
37 | }
38 |
39 | __stopstream() {
40 | if [[ -r $1 ]]; then
41 | command -- pkill -9 -F "$1"
42 | command -- rm -f -- "$1"
43 | fi >/dev/null 2>&1
44 | }
45 |
46 | __playstream() (
47 | if [[ -n $1 ]]; then
48 | exec -- audio-player --no-terminal "$1" >/dev/null 2>&1 &
49 | echo "$!" >>"$file_webradio_pid"
50 | fi
51 | )
52 |
53 | typeset -A streams
54 | __build_streams
55 |
56 | while :; do
57 | selection=$(__selectstream)
58 | case $selection in
59 | '')
60 | exit 1
61 | ;;
62 | *)
63 | __stopstream "$file_webradio_pid"
64 | __playstream "${streams["$selection"]}"
65 | ;;
66 | esac
67 | done
68 |
69 | # vim: set ft=zsh :
70 |
--------------------------------------------------------------------------------
/wvim:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Open the result of command -v in vim.
4 |
5 | exec vim "$(command -v "${1:?}")"
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/x-audio-player:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default audio player (gui).
4 |
5 | IFS=\|
6 |
7 | set -f &&
8 | set -- $X_AUDIO_PLAYER_OPTS ${1:+"$@"} &&
9 | exec "$X_AUDIO_PLAYER" "$@"
10 |
11 | # vim: set ft=sh :
12 |
--------------------------------------------------------------------------------
/x-file-browser:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default file manager (gui).
4 |
5 | IFS=\|
6 |
7 | set -f &&
8 | set -- $X_FILE_BROWSER_OPTS ${1:+"$@"} &&
9 | exec "$X_FILE_BROWSER" "$@"
10 |
11 | # vim: set ft=sh :
12 |
--------------------------------------------------------------------------------
/x-image-viewer:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default image viewer (gui).
4 |
5 | IFS=\|
6 |
7 | set -f &&
8 | set -- $X_IMAGE_VIEWER_OPTS ${1:+"$@"} &&
9 | exec "$X_IMAGE_VIEWER" "$@"
10 |
11 | # vim: set ft=sh :
12 |
--------------------------------------------------------------------------------
/x-mail-viewer:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default mail viewer (gui).
4 |
5 | IFS=\|
6 |
7 | set -f &&
8 | set -- $X_MAIL_VIEWER_OPTS ${1:+"$@"} &&
9 | exec "$X_MAIL_VIEWER" "$@"
10 |
11 | # vim: set ft=sh :
12 |
--------------------------------------------------------------------------------
/x-pdf-viewer:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default pdf viewer (gui).
4 |
5 | IFS=\|
6 |
7 | set -f &&
8 | set -- $X_PDF_VIEWER_OPTS ${1:+"$@"} &&
9 | exec "$X_PDF_VIEWER" "$@"
10 |
11 | # vim: set ft=sh :
12 |
--------------------------------------------------------------------------------
/x-terminal:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default terminal emulator window.
4 |
5 | IFS=\|
6 | set -f
7 |
8 | if test -f "${XDG_RUNTIME_DIR:?}/DAYLIGHT"; then
9 | set -- "$TERMINAL_L" $TERMINAL_L_OPTS ${1:+"$@"}
10 | else
11 | set -- "$TERMINAL_D" $TERMINAL_D_OPTS ${1:+"$@"}
12 | fi
13 |
14 | exec "$@"
15 |
16 | # vim: set ft=sh :
17 |
--------------------------------------------------------------------------------
/x-terminal-tabbed:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Open some terminal emulators in tabbed.
4 |
5 | xid=$(exec tabbed -cd -n terminal-tabbed 2>/dev/null)
6 | : "${xid:?}"
7 |
8 | case $X_XCLIENT in
9 | x-terminal-tabbed)
10 | command -- xdotool windowsize "$xid" 100% 100%
11 | ;;
12 | esac
13 |
14 | {
15 | command -- urxvt -embed "$xid" &
16 | command -- xterm -into "$xid" &
17 | command -- sleep 0.5
18 | command -- x-terminal -w "$xid" &
19 | } 2>/dev/null
20 |
21 | wait
22 |
23 | # vim: set ft=sh :
24 |
--------------------------------------------------------------------------------
/x-text-editor:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default editor (gui).
4 |
5 | IFS=\|
6 |
7 | set -f &&
8 | set -- $X_VISUAL_OPTS ${1:+"$@"} &&
9 | exec "$X_VISUAL" "$@"
10 |
11 | # vim: set ft=sh :
12 |
--------------------------------------------------------------------------------
/x-video-player:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default video player (gui).
4 |
5 | IFS=\|
6 |
7 | set -f &&
8 | set -- $X_VIDEO_PLAYER_OPTS ${1:+"$@"} &&
9 | exec "$X_VIDEO_PLAYER" "$@"
10 |
11 | # vim: set ft=sh :
12 |
--------------------------------------------------------------------------------
/x-web-browser:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default web browser (gui).
4 |
5 | IFS=\|
6 |
7 | set -f &&
8 | set -- $X_BROWSER_OPTS ${1:+"$@"} &&
9 | exec "$X_BROWSER" "$@"
10 |
11 | # vim: set ft=sh :
12 |
--------------------------------------------------------------------------------
/xorg-autolock:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default X screen autolocker program.
4 |
5 | exec daemonize xss-lock \
6 | -n "run-logger 3 .misc.exlamation 'Screen is going to be locked'" \
7 | -- "${XDG_BIN_HOME:?}/xorg-locker"
8 |
9 | # vim: set ft=sh :
10 |
--------------------------------------------------------------------------------
/xorg-get-xclass:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Grab xwindow and get xclass info.
4 |
5 | exec xprop |
6 | exec mawk '
7 | /^WM_CLASS/ {
8 | sub(/.* =/, "instance:");
9 | sub(/,/, "\nclass:");
10 | print
11 | }
12 |
13 | /^WM_NAME/ {
14 | sub(/.* =/, "title:")
15 | print
16 | }
17 | '
18 |
19 | # vim: set ft=sh :
20 |
--------------------------------------------------------------------------------
/xorg-get-xids:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Get xwindow ids.
4 |
5 | exec xprop -root -notype -f _NET_CLIENT_LIST 32x :\\n\$0+,\ _NET_CLIENT_LIST |
6 | exec tr -s ', ' '\n'
7 |
8 | # vim: set ft=sh :
9 |
--------------------------------------------------------------------------------
/xorg-lock:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Manually lock X screen.
4 |
5 | exec xset s activate
6 |
7 | # vim: set ft=sh :
8 |
--------------------------------------------------------------------------------
/xorg-locker:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Default xlock program.
4 |
5 | XSECURELOCK_AUTH_CURSOR_BLINK=0 \
6 | XSECURELOCK_BLANK_DPMS_STATE=standby \
7 | XSECURELOCK_BLANK_TIMEOUT=6 \
8 | XSECURELOCK_PASSWORD_PROMPT=time_hex \
9 | XSECURELOCK_SAVER=saver_blank \
10 | XSECURELOCK_SHOW_DATETIME=0 \
11 | XSECURELOCK_SHOW_HOSTNAME=0 \
12 | XSECURELOCK_SHOW_USERNAME=0 \
13 | exec xsecurelock
14 |
15 | # vim: set ft=sh :
16 |
--------------------------------------------------------------------------------
/xorg-raise-xwin:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # List xwindows with dmenu and raise selection.
4 |
5 | #wmctrl -i -a "$(wmctrl -lGpx | column -t | menu.sh "dmenu2" ">" | awk '{print $1}')"
6 |
7 | id=$(exec wmctrl -lGpx | exec menu dmenu2 \>)
8 |
9 | if test -n "$id"; then
10 | #xdotool windowmap $id
11 | #wmctrl -i -r $id -b remove,hidden
12 | #xdotool windowraise $id
13 | #xdotool windowfocus $id
14 | #xdotool mousemove --window $id 25 25
15 | #xdotool click 1
16 | wmctrl -i -a "${id%% *}"
17 | fi
18 |
19 | # vim: set ft=sh :
20 |
--------------------------------------------------------------------------------
/xorg-selection-clear:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Clear the X selection.
4 |
5 | for s in primary secondary clipboard; do
6 | command -- xsel -l /dev/null --clear "--$s" &
7 | done
8 |
9 | wait
10 |
11 | # vim: set ft=sh :
12 |
--------------------------------------------------------------------------------
/xorg-selection-clipboard-in:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Read into X clipboard selection.
4 |
5 | # xclip -selection clipboard -in -loops 0;
6 |
7 | exec -- tee >(exec -- xsel -l /dev/null --clipboard --input) |
8 | exec -- xorg-selection-primary-in
9 |
10 | # {
11 | # tee /dev/fd/9 |
12 | # xorg-selection-primary-in;
13 | # } 9>&1 |
14 | # exec xsel -l /dev/null --clipboard --input &
15 |
16 | # vim: set ft=zsh :
17 |
--------------------------------------------------------------------------------
/xorg-selection-clipboard-out:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Print the X clipboard selection to stdout.
4 |
5 | exec xsel -l /dev/null --clipboard --output
6 | # xclip -quiet -loops 0 -selection clipboard -out;
7 |
8 | # vim: set ft=sh :
9 |
--------------------------------------------------------------------------------
/xorg-selection-primary-in:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Read into X primary selection.
4 |
5 | exec xsel -l /dev/null --primary --input
6 | # xclip -selection primary -in -loops 0;
7 |
8 | # vim: set ft=sh :
9 |
--------------------------------------------------------------------------------
/xorg-selection-primary-out:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Print the X primary selection to stdout.
4 |
5 | command -- xsel -l /dev/null -k
6 | command -- xsel -l /dev/null --primary --output
7 | # xclip -quiet -loops 0 -selection primary -out;
8 |
9 | # vim: set ft=sh :
10 |
--------------------------------------------------------------------------------
/xorg-switch-to-desktop:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Select X desktop with a menu and then switch with wmctrl to it.
4 |
5 | desk=$(exec wmctrl -d | exec menu dmenu2 \>)
6 |
7 | if test -n "$desk"; then
8 | exec wmctrl -s "${desk%% *}"
9 | fi
10 |
11 | # vim: set ft=sh :
12 |
--------------------------------------------------------------------------------
/youtube-dl-get-audio:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Run youtoube-dl to convert video to audio.
4 |
5 | exec youtube-dl \
6 | --audio-format=${2:-best} \
7 | --audio-quality=${3:-2} \
8 | --batch-file=- \
9 | --continue \
10 | --external-downloader=aria2c \
11 | --extract-audio \
12 | --format=${1:-"bestaudio[ext=m4a]/bestaudio[ext=wbm]/bestaudio"} \
13 | --no-cache-dir \
14 | --no-call-home \
15 | --no-overwrites \
16 | --output='%(title)s.%(ext)s' \
17 | --prefer-ffmpeg \
18 | --prefer-free-formats \
19 | --print-traffic \
20 | --restrict-filenames
21 |
22 | # vim: set ft=sh :
23 |
--------------------------------------------------------------------------------
/zeit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Display times.
4 |
5 | command -- tput bold setaf 7
6 | command -- date '+%Y-%m-%d %H:%M:%S (%a; D%j; KW%V; Q%q)'
7 | command -- tput sgr0
8 |
9 | printf '\nLifeday: '
10 | command -- get-lifeday
11 |
12 | echo
13 | command -- ncal -w -M
14 | echo
15 | # TASKRC=$XDG_CONFIG_HOME/taskrc-life \
16 | # task rc._forcecolor=true calendar 2>/dev/null;
17 |
18 | exec sed "s/.*/TZ=& date \\\'+%Z %t%F %T %t&\\\'/" "$HOME/".tzlist |
19 | command -- xargs -P 0 -I {} -- sh -c {}
20 | echo
21 |
22 | # vim: set ft=sh :
23 |
--------------------------------------------------------------------------------
/zombies:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Display all zombies and their parents to kill.
4 | #
5 | # Source: http://chneukirchen.org/dotfiles/bin/zombies
6 |
7 | exec ps f -eo state,pid,ppid,comm |
8 | exec mawk '
9 | {
10 | cmds[$2] = $NF
11 | }
12 |
13 | /^Z/ {
14 | print $(NF-1) "/" $2 " zombie child of " cmds[$3] "/" $3;
15 | }
16 | '
17 |
18 | # vim: set ft=sh :
19 |
--------------------------------------------------------------------------------