plumbing: cabl from video

This commit is contained in:
Luke Smith 2019-03-08 10:04:26 -05:00
parent 2e1310169e
commit ee570f046c
2 changed files with 27 additions and 1 deletions

View file

@ -160,7 +160,7 @@ bindsym $mod+Shift+z gaps outer current minus 5
bindsym $mod+x exec --no-startup-id mpc pause; exec --no-startup-id pauseallmpv ; exec --no-startup-id i3lock -e -f -c 1d2021 bindsym $mod+x exec --no-startup-id mpc pause; exec --no-startup-id pauseallmpv ; exec --no-startup-id i3lock -e -f -c 1d2021
bindsym $mod+Shift+x exec --no-startup-id prompt "Shutdown computer?" "$shutdown" bindsym $mod+Shift+x exec --no-startup-id prompt "Shutdown computer?" "$shutdown"
bindsym $mod+c exec --no-startup-id freealf bindsym $mod+c exec --no-startup-id cabl
bindsym $mod+Shift+c exec --no-startup-id camtoggle bindsym $mod+Shift+c exec --no-startup-id camtoggle
bindsym $mod+v exec --no-startup-id $term -e $EDITOR -c "VimwikiIndex" bindsym $mod+v exec --no-startup-id $term -e $EDITOR -c "VimwikiIndex"

26
.scripts/i3cmds/cabl Executable file
View file

@ -0,0 +1,26 @@
#!/bin/bash
# Dependencies are xclip and xorg-xprop.
# qrencode required for qrcode generation.
# groff/zathura required for man pages.
prim="$(xclip -o)"; [ -z "$prim" ] && exit
PID=$(xprop -id "$(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')" | grep -m 1 PID | cut -d " " -f 3)
PID=$(echo "$(pstree -lpA "$PID" | tail -n 1)" | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g')
cd "$(readlink /proc/"$PID"/cwd)"
[ -f "$prim" ] && xdg-open "$prim" && exit
[ -d "$prim" ] && "$TERMINAL" "$prim" && exit
websearch() { "$BROWSER" "https://duckduckgo.com/?q=$@" ;}
wikipedia() { "$BROWSER" "https://en.wikipedia.org/wiki/$@" ;}
wiktionary() { "$BROWSER" "https://en.wiktionary.org/wiki/$@" ;}
maps() { "$BROWSER" "https://www.openstreetmap.org/search?query=$@" ;}
ebay() { "$BROWSER" "https://www.ebay.com/sch/$@" ;}
echo "$prim" | grep "^.*\.[A-Za-z]\+.*" >/dev/null && gotourl() { "$BROWSER" "$@" ;}
echo "$prim" | grep "^.*@.*\.[A-Za-z]\+$" >/dev/null && email() { xdg-email "$@" ;}
command -v qrencode >/dev/null && qrcode() { qrencode "$@" -s 10 -o /tmp/qr.png && xdg-open /tmp/qr.png ;}
man -k "^$prim$" >/dev/null && manual() { man -Tpdf "$prim" | zathura - ;}
func="$(declare -F | awk '{print $3}' | dmenu -p "Plumb $prim to?" -i -l 15)"
[ -z "$func" ] || "$func" "$prim"