summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdisplayselect83
-rwxr-xr-xdmenubookmark27
-rwxr-xr-xdmenukblayout11
-rwxr-xr-xdmenurecord79
4 files changed, 200 insertions, 0 deletions
diff --git a/displayselect b/displayselect
new file mode 100755
index 0000000..04314ad
--- /dev/null
+++ b/displayselect
@@ -0,0 +1,83 @@
+#!/bin/sh
+
+# A UI for detecting and selecting all displays. Probes xrandr for connected
+# displays and lets user select one to use. User may also select "manual
+# selection" which opens arandr.
+
+twoscreen() { # If multi-monitor is selected and there are two screens.
+
+ mirror=$(printf "no\\nyes" | dmenu -i -p "Mirror displays?")
+ # Mirror displays using native resolution of external display and a scaled
+ # version for the internal display
+ if [ "$mirror" = "yes" ]; then
+ external=$(echo "$screens" | dmenu -i -p "Optimize resolution for:")
+ internal=$(echo "$screens" | ggrep -v "$external")
+
+ res_external=$(xrandr --query | gsed -n "/^$external/,/\+/p" | \
+ tail -n 1 | gawk '{print $1}')
+ res_internal=$(xrandr --query | gsed -n "/^$internal/,/\+/p" | \
+ tail -n 1 | gawk '{print $1}')
+
+ res_ext_x=$(echo "$res_external" | gsed 's/x.*//')
+ res_ext_y=$(echo "$res_external" | gsed 's/.*x//')
+ res_int_x=$(echo "$res_internal" | gsed 's/x.*//')
+ res_int_y=$(echo "$res_internal" | gsed 's/.*x//')
+
+ scale_x=$(echo "$res_ext_x / $res_int_x" | bc -l)
+ scale_y=$(echo "$res_ext_y / $res_int_y" | bc -l)
+
+ xrandr --output "$external" --auto --scale 1.0x1.0 \
+ --output "$internal" --auto --same-as "$external" \
+ --scale "$scale_x"x"$scale_y"
+ else
+
+ primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
+ secondary=$(echo "$screens" | ggrep -v "$primary")
+ direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
+ xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --auto --scale 1.0x1.0
+ fi
+ }
+
+morescreen() { # If multi-monitor is selected and there are more than two screens.
+ primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
+ secondary=$(echo "$screens" | ggrep -v "$primary" | dmenu -i -p "Select secondary display:")
+ direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
+ tertiary=$(echo "$screens" | ggrep -v "$primary" | ggrep -v "$secondary" | dmenu -i -p "Select third display:")
+ xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto --output "$tertiary" --"$(printf "left\\nright" | ggrep -v "$direction")"-of "$primary" --auto
+ }
+
+multimon() { # Multi-monitor handler.
+ case "$(echo "$screens" | wc -l)" in
+ 2) twoscreen ;;
+ *) morescreen ;;
+ esac ;}
+
+onescreen() { # If only one output available or chosen.
+ xrandr --output "$1" --auto --scale 1.0x1.0 $(echo "$allposs" | ggrep -v "\b$1" | gawk '{print "--output", $1, "--off"}' | paste -sd ' ' -)
+ }
+
+postrun() { # Stuff to run to clean up.
+ #setbg # Fix background if screen size/arangement has changed.
+ remaps # Re-remap keys if keyboard added (for laptop bases)
+ { killall dunst ; setsid -f dunst ;} >/dev/null 2>&1 # Restart dunst to ensure proper location on screen
+ }
+
+# Get all possible displays
+allposs=$(xrandr -q | ggrep "connected")
+
+# Get all connected screens.
+screens=$(echo "$allposs" | gawk '/ connected/ {print $1}')
+
+# If there's only one screen
+[ "$(echo "$screens" | wc -l)" -lt 2 ] &&
+ { onescreen "$screens"; postrun; notify-send "๐Ÿ’ป Only one screen detected." "Using it in its optimal settings..."; exit ;}
+
+# Get user choice including multi-monitor and manual selection:
+chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p "Select display arangement:") &&
+case "$chosen" in
+ "manual selection") arandr ; exit ;;
+ "multi-monitor") multimon ;;
+ *) onescreen "$chosen" && xwallpaper --stretch $wallpaper ;;
+esac
+
+postrun
diff --git a/dmenubookmark b/dmenubookmark
new file mode 100755
index 0000000..3a99321
--- /dev/null
+++ b/dmenubookmark
@@ -0,0 +1,27 @@
+#!/bin/sh
+if [ -z "$1" ]
+then
+ touch ~/.cache/tmp_bookmarks
+ bookmark_file=~/.cache/bookmarks
+ temp_file=~/.cache/tmp_bookmarks
+ echo 'exit' >> $temp_file &&
+ echo 'remove_bookmark' >> $temp_file &&
+ gawk -F 'ยงยงยง' '{print($2)}' $bookmark_file >> $temp_file &&
+ choice=$(cat $temp_file | dmenu -p 'Search for Bookmark' -l 20)
+ echo $choice
+ rm ~/.cache/tmp_bookmarks
+ if [ "$choice" == 'remove_bookmark' ]; then
+ mark=$(gawk -F 'ยงยงยง' '{print($2)}' $bookmark_file | dmenu -p 'Which bookmark to remove?' -l 20)
+ echo $mark | xargs -I '%%ยง%%' gsed -i 's/^.*%%ยง%%.*$//' $bookmark_file
+ gsed -i '/^$/d' $bookmark_file
+ elif [ "$choice" == 'exit' ]; then
+ exit
+ else
+ link=$(echo $choice | xargs -I ยงโ‚ฌยง grep 'ยงโ‚ฌยง' $bookmark_file | gawk -F 'ยงยงยง' '{print($1)}')
+ echo $link
+ linkhandler $link
+ fi
+else
+ name=$(echo $1 | dmenu -p 'Description of the Bookmark:') &&
+ echo $1ยงยงยง$name >> ~/.cache/bookmarks
+fi
diff --git a/dmenukblayout b/dmenukblayout
new file mode 100755
index 0000000..2e149ef
--- /dev/null
+++ b/dmenukblayout
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+layouts=" \
+us setxkbmap us
+de setxkbmap de
+rus setxkbmap ru"
+choice="$(echo "$layouts" | cut -d" " -f 1 | dmenu )"
+
+$(echo "$layouts" | grep "^$choice " | cut -d ' ' -f2) && remaps
+#xmodmap -e "keysym Super_R = Escape"
+#xmodmap -e "keysym Menu = Escape"
diff --git a/dmenurecord b/dmenurecord
new file mode 100755
index 0000000..8702a3e
--- /dev/null
+++ b/dmenurecord
@@ -0,0 +1,79 @@
+#!/bin/sh
+
+# Usage:
+# `$0`: Ask for recording type via dmenu
+# `$0 screencast`: Record both audio and screen
+# `$0 video`: Record only screen
+# `$0 audio`: Record only audio
+# `$0 kill`: Kill existing recording
+#
+# If there is already a running instance, user will be prompted to end it.
+
+
+killrecording() {
+ recpid="$(cat /tmp/recordingpid)"
+ # kill with SIGTERM, allowing finishing touches.
+ kill -15 "$recpid"
+ rm -f /tmp/recordingpid
+ pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}"
+ # even after SIGTERM, ffmpeg may still run, so SIGKILL it.
+ sleep 3
+ kill -9 "$recpid"
+ exit
+ }
+
+screencast() { \
+
+ffmpeg -y \
+ -f x11grab -probesize 32M -thread_queue_size 32 -i :0 \
+ -f sndio -thread_queue_size 128 -i snd/1 \
+ -codec:v libx264rgb -crf 0 -preset ultrafast \
+ -codec:a pcm_s16le \
+ "$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mkv" &
+# ffmpeg -y \
+# -f x11grab \
+# -framerate 60 \
+# -s "$(xdpyinfo | awk '/dimensions/ {print $2;}')" \
+# -i "$DISPLAY" \
+# -f sndio -i snd/1 \
+# -r 30 \
+# -c:v h264 -crf 0 -preset ultrafast -c:a aac \
+# "$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mp4" &
+ echo $! > /tmp/recordingpid
+ }
+
+
+audio() { \
+ ffmpeg \
+ -f sndio -i snd/1 \
+ -c:a flac \
+ "$HOME/audio-$(date '+%y%m%d-%H%M-%S').flac" &
+ echo $! > /tmp/recordingpid
+ }
+
+askrecording() { \
+ #choice=$(printf "screencast\\nvideo\\nvideo selected\\naudio\\nwebcam\\nwebcam (hi-def)" | dmenu -i -p "Select recording style:")
+ choice=$(printf "screencast\\naudio" | dmenu -i -p "Select recording style:")
+ case "$choice" in
+ screencast) screencast;;
+ audio) audio;;
+ video) video;;
+ # *selected) videoselected;;
+ # webcam) webcam;;
+ # "webcam (hi-def)") webcamhidef;;
+ esac
+ }
+
+asktoend() { \
+ response=$(printf "No\\nYes" | dmenu -i -p "Recording still active. End recording?") &&
+ [ "$response" = "Yes" ] && killrecording
+ }
+
+
+case "$1" in
+ screencast) screencast;;
+ audio) audio;;
+ video) video;;
+ kill) killrecording;;
+ *) ([ -f /tmp/recordingpid ] && asktoend && exit) || askrecording;;
+esac