summaryrefslogtreecommitdiffstats
path: root/.scripts/i3cmds
diff options
context:
space:
mode:
Diffstat (limited to '.scripts/i3cmds')
-rwxr-xr-x.scripts/i3cmds/displayselect41
-rwxr-xr-x.scripts/i3cmds/dmenumount7
-rwxr-xr-x.scripts/i3cmds/dmenurecord8
-rwxr-xr-x.scripts/i3cmds/ducksearch13
-rwxr-xr-x.scripts/i3cmds/showclip4
-rwxr-xr-x.scripts/i3cmds/tutorialvids2
6 files changed, 57 insertions, 18 deletions
diff --git a/.scripts/i3cmds/displayselect b/.scripts/i3cmds/displayselect
index c9a2bd9..0bd612e 100755
--- a/.scripts/i3cmds/displayselect
+++ b/.scripts/i3cmds/displayselect
@@ -6,14 +6,41 @@
# I plan on adding a routine from multi-monitor setups later.
twoscreen() { # If multi-monitor is selected and there are two screens.
- primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
- secondary=$(echo "$screens" | grep -v "$primary")
- direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
- xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto
- }
+
+ 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" | grep -v "$external")
+
+ res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" | \
+ tail -n 1 | awk '{print $1}')
+ res_internal=$(xrandr --query | sed -n "/^$internal/,/\+/p" | \
+ tail -n 1 | awk '{print $1}')
+
+ res_ext_x=$(echo $res_external | sed 's/x.*//')
+ res_ext_y=$(echo $res_external | sed 's/.*x//')
+ res_int_x=$(echo $res_internal | sed 's/x.*//')
+ res_int_y=$(echo $res_internal | sed '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" | grep -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 "asdf")
+ primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
secondary=$(echo "$screens" | grep -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" | grep -v "$primary" | grep -v "$secondary" | dmenu -i -p "Select third display:")
@@ -38,7 +65,7 @@ chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p
case "$chosen" in
"manual selection") arandr ; exit ;;
"multi-monitor") multimon ;;
- *) xrandr --output "$chosen" --auto $(echo "$screens" | grep -v "$chosen" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;;
+ *) xrandr --output "$chosen" --auto --scale 1.0x1.0 $(echo "$screens" | grep -v "$chosen" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;;
esac
# Fix feh background if screen size/arangement has changed.
diff --git a/.scripts/i3cmds/dmenumount b/.scripts/i3cmds/dmenumount
index 431141f..4de7438 100755
--- a/.scripts/i3cmds/dmenumount
+++ b/.scripts/i3cmds/dmenumount
@@ -19,7 +19,12 @@ mountusb() { \
chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?" | awk '{print $1}')"
sudo -A mount "$chosen" && notify-send "$chosen mounted." && exit 0
getmount "/mnt /media /mount /home -maxdepth 5 -type d"
- sudo -A mount "$chosen" "$mp" && notify-send "$chosen mounted to $mp."
+ partitiontype="$(lsblk -no "fstype" "$chosen")"
+ case "$partitiontype" in
+ "vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000;;
+ *) sudo -A mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" 741 "$mp";;
+ esac
+ notify-send "$chosen mounted to $mp."
}
mountandroid() { \
diff --git a/.scripts/i3cmds/dmenurecord b/.scripts/i3cmds/dmenurecord
index d5ed889..7f0ea72 100755
--- a/.scripts/i3cmds/dmenurecord
+++ b/.scripts/i3cmds/dmenurecord
@@ -52,7 +52,7 @@ video() { ffmpeg \
}
webcamhidef() { ffmpeg \
- -f v412 \
+ -f v4l2 \
-i /dev/video0 \
-video_size 1920x1080 \
"$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" &
@@ -61,7 +61,7 @@ webcamhidef() { ffmpeg \
}
webcam() { ffmpeg \
- -f v412 \
+ -f v4l2 \
-i /dev/video0 \
-video_size 640x480 \
"$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" &
@@ -85,8 +85,8 @@ askrecording() { \
screencast) screencast;;
audio) audio;;
video) video;;
- webcam) webcamrecord;;
- "webcam (hi-def)") webcamrecord;;
+ webcam) webcam;;
+ "webcam (hi-def)") webcamhidef;;
esac
}
diff --git a/.scripts/i3cmds/ducksearch b/.scripts/i3cmds/ducksearch
index 13a1e19..d69f3fb 100755
--- a/.scripts/i3cmds/ducksearch
+++ b/.scripts/i3cmds/ducksearch
@@ -1,15 +1,22 @@
-#!/bin/sh
+#!/bin/bash
# Gives a dmenu prompt to search DuckDuckGo.
# Without input, will open DuckDuckGo.com.
+# URLs will be directly handed to the browser.
# Anything else, it search it.
+browser=${BROWSER:-firefox}
pgrep -x dmenu && exit
choice=$(echo "🦆" | dmenu -i -p "Search DuckDuckGo:") || exit 1
if [ "$choice" = "🦆" ]; then
- $BROWSER "https://duckduckgo.com"
+ $browser "https://duckduckgo.com"
else
- $BROWSER "https://duckduckgo.com/?q=$choice&t=ffab&atb=v1-1"
+ # Detect if url
+ if [[ "$choice" =~ ^(http:\/\/|https:\/\/)?[a-zA-Z0-9]+\.[a-zA-Z]+(/)?.*$ ]]; then
+ $browser "$choice"
+ else
+ $browser "https://duckduckgo.com/?q=$choice&t=ffab&atb=v1-1"
+ fi
fi
diff --git a/.scripts/i3cmds/showclip b/.scripts/i3cmds/showclip
index 5764487..9f8a6b9 100755
--- a/.scripts/i3cmds/showclip
+++ b/.scripts/i3cmds/showclip
@@ -9,7 +9,7 @@ clip=$(xclip -o -selection clipboard)
prim=$(xclip -o -selection primary)
-[ "$prim" != "" ] && notify-send "<b>Clipboard:</b>
+[ "$clip" != "" ] && notify-send "<b>Clipboard:</b>
$clip"
-[ "$clip" != "" ] && notify-send "<b>Primary:</b>
+[ "$prim" != "" ] && notify-send "<b>Primary:</b>
$prim"
diff --git a/.scripts/i3cmds/tutorialvids b/.scripts/i3cmds/tutorialvids
index 2743bfc..1449cbe 100755
--- a/.scripts/i3cmds/tutorialvids
+++ b/.scripts/i3cmds/tutorialvids
@@ -15,4 +15,4 @@ urlview https://www.youtube.com/watch?v=IgzpAjFgbCw
colorschemes with pywal https://www.youtube.com/watch?v=Es79N_9BblE
vi mode in shell https://www.youtube.com/watch?v=GqoJQft5R2E
"
-mpv "$(echo "$vidlist" | grep -P "^$(echo "$vidlist" | grep "https:" | sed 's/\t.*//g' | dmenu -i -p "Learn about what? (ESC to cancel)" -l 5 | awk '{print $1}')\s" | sed 's/.*\t//')"
+echo "$vidlist" | grep -P "^$(echo "$vidlist" | grep "https:" | sed 's/\t.*//g' | dmenu -i -p "Learn about what? (ESC to cancel)" -l 20 | awk '{print $1}')\s" | sed 's/.*\t//' | xargs -r mpv