summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/scripts/switch_window17
-rwxr-xr-xbin/scripts/take_screenshot12
2 files changed, 29 insertions, 0 deletions
diff --git a/bin/scripts/switch_window b/bin/scripts/switch_window
new file mode 100755
index 0000000..55787bc
--- /dev/null
+++ b/bin/scripts/switch_window
@@ -0,0 +1,17 @@
+#!/usr/bin/env sh
+
+windows=$(wmctrl -xl | tr -s '[:blank:]' | cut -d ' ' -f 3-3,5- | sed 's/^[a-zA-Z0-9-]*\.//')
+
+# Add spaces to align the WM_NAMEs of the windows
+max=$(printf %s\\n "$windows" | awk '{cur=length($1); max=(cur>max?cur:max)} END{print max}')
+
+windows=$(printf %s\\n "$windows" | \
+ awk -v max="$max" \
+ '{cur=length($1); printf $1; \
+ for(i=0; i < max - cur + 1; i++) printf " "; \
+ $1 = ""; printf "%s\n", $0}')
+
+
+target=$(printf %s\\n "$windows" | dmenu -l 10 -i -p switch: | tr -s '[:blank:]' | cut -d ' ' -f 2-)
+
+[ -n "$target" ] && wmctrl -a "$target"
diff --git a/bin/scripts/take_screenshot b/bin/scripts/take_screenshot
new file mode 100755
index 0000000..005b702
--- /dev/null
+++ b/bin/scripts/take_screenshot
@@ -0,0 +1,12 @@
+#!/usr/bin/env sh
+
+# Grab a screenshot and save it in $XDG_DATA_HOME/screenshots
+
+screenshot_dir="${XDG_DATA_HOME:-$HOME/.local/share}/screenshots"
+[ -d "$screenshot_dir" ] || mkdir -p "$screenshot_dir"
+
+sleep 0.5 # Allow some time for dmenu or whatever to go away.
+
+filename="$(date -Iseconds -u)"
+filename="${filename%+00:00}.png"
+ffmpeg -f x11grab -i "$DISPLAY" -vframes 1 "$screenshot_dir/$filename"