From 0ae576d32eb6e76c134c1753d037d93f6738f1c3 Mon Sep 17 00:00:00 2001 From: tucker Date: Fri, 7 Feb 2025 12:08:58 -0500 Subject: [PATCH] things --- Makefile | 20 ++++----- dmenu-scripts/dm-displayselect | 82 ++++++++++++++++++++++++++++++++++ dmenu-scripts/dm-maimpick | 18 ++++++++ dmenu-scripts/dm-streamselect | 2 +- 4 files changed, 109 insertions(+), 13 deletions(-) create mode 100755 dmenu-scripts/dm-displayselect create mode 100755 dmenu-scripts/dm-maimpick diff --git a/Makefile b/Makefile index cb6d970..4522e49 100644 --- a/Makefile +++ b/Makefile @@ -47,12 +47,13 @@ install: all chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_path chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_run chmod 755 $(DESTDIR)$(PREFIX)/bin/stest - chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenuhandler - chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenumountcifs - chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenupass - chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenuunicode - chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenukampv - chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenustreamselect + chmod 755 $(DESTDIR)$(PREFIX)/bin/dm-displayselect + chmod 755 $(DESTDIR)$(PREFIX)/bin/dm-handler + chmod 755 $(DESTDIR)$(PREFIX)/bin/dm-mountcifs + chmod 755 $(DESTDIR)$(PREFIX)/bin/dm-pass + chmod 755 $(DESTDIR)$(PREFIX)/bin/dm-unicode + chmod 755 $(DESTDIR)$(PREFIX)/bin/dm-kampv + chmod 755 $(DESTDIR)$(PREFIX)/bin/dm-streamselect mkdir -p $(DESTDIR)$(MANPREFIX)/man1 sed "s/VERSION/$(VERSION)/g" < dmenu.1 > $(DESTDIR)$(MANPREFIX)/man1/dmenu.1 sed "s/VERSION/$(VERSION)/g" < stest.1 > $(DESTDIR)$(MANPREFIX)/man1/stest.1 @@ -66,11 +67,6 @@ uninstall: $(DESTDIR)$(PREFIX)/bin/stest\ $(DESTDIR)$(MANPREFIX)/man1/dmenu.1\ $(DESTDIR)$(MANPREFIX)/man1/stest.1\ - $(DESTDIR)$(PREFIX)/bin/dmenuhandler\ - $(DESTDIR)$(PREFIX)/bin/dmenumountcifs\ - $(DESTDIR)$(PREFIX)/bin/dmenupass\ - $(DESTDIR)$(PREFIX)/bin/dmenuunicode\ - $(DESTDIR)$(PREFIX)/bin/dmenukampv\ - $(DESTDIR)$(PREFIX)/bin/dmenustreamselect + $(DESTDIR)$(PREFIX)/bin/dm-* .PHONY: all options clean dist install uninstall diff --git a/dmenu-scripts/dm-displayselect b/dmenu-scripts/dm-displayselect new file mode 100755 index 0000000..0227a32 --- /dev/null +++ b/dmenu-scripts/dm-displayselect @@ -0,0 +1,82 @@ +#!/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" | 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 "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:") + xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto --output "$tertiary" --"$(printf "left\\nright" | grep -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" | grep -v "\b$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ' -) + } + +postrun() { # Stuff to run to clean up. + setbg # Fix background if screen size/arangement has changed. + { killall dunst ; setsid -f dunst ;} >/dev/null 2>&1 # Restart dunst to ensure proper location on screen + } + +# Get all possible displays +allposs=$(xrandr -q | grep "connected") + +# Get all connected screens. +screens=$(echo "$allposs" | awk '/ 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" ;; +esac + +postrun diff --git a/dmenu-scripts/dm-maimpick b/dmenu-scripts/dm-maimpick new file mode 100755 index 0000000..5de26c1 --- /dev/null +++ b/dmenu-scripts/dm-maimpick @@ -0,0 +1,18 @@ +#!/bin/sh + +# This is bound to Shift+PrintScreen by default, requires maim. It lets you +# choose the kind of screenshot to take, including copying the image or even +# highlighting an area to copy. scrotcucks on suicidewatch right now. + +# variables +output="$(date '+%y%m%d-%H%M-%S').png" +xclip_cmd="xclip -sel clip -t image/png" + +case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)" | dmenu -l 6 -i -p "Screenshot which area?")" in + "a selected area") maim -u -s pic-selected-"${output}" ;; + "current window") maim -q -d 0.2 -i "$(xdotool getactivewindow)" pic-window-"${output}" ;; + "full screen") maim -q -d 0.2 pic-full-"${output}" ;; + "a selected area (copy)") maim -u -s | ${xclip_cmd} ;; + "current window (copy)") maim -q -d 0.2 -i "$(xdotool getactivewindow)" | ${xclip_cmd} ;; + "full screen (copy)") maim -q -d 0.2 | ${xclip_cmd} ;; +esac diff --git a/dmenu-scripts/dm-streamselect b/dmenu-scripts/dm-streamselect index c278485..d6895f8 100755 --- a/dmenu-scripts/dm-streamselect +++ b/dmenu-scripts/dm-streamselect @@ -1,7 +1,7 @@ #!/bin/sh streamList=" -audio: WXXI Classical (Rochester Classical Music) link:https://22213.live.streamtheworld.com/WXXIFM.mp3 +audio: WXXI Classical (Rochester Classical Radio) link:https://22213.live.streamtheworld.com/WXXIFM.mp3 video: Hasan Piker link:https://twitch.tv/hasanabi " selected=$(echo "$streamList" | grep -P "^$(echo "$streamList" | grep "https:" | sed 's/link:.*//g' | dmenu -i -p "Select a Stream" -l 20 | awk '{print $1}')\s") -- 2.39.5