From bdc63949f171e6a1c54e0df76cee22a9f780031f Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Sun, 18 Jan 2026 08:06:36 +0900 Subject: modified shell/aliasrc, modified zsh/.zshrc, deleted bin/displayselect, modified Music/.music.txt, created bin/dmenudisplay --- ar/.config/shell/aliasrc | 2 + ar/.config/zsh/.zshrc | 3 +- ar/.local/bin/displayselect | 95 --------------------------------- ar/.local/bin/dmenudisplay | 126 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 129 insertions(+), 97 deletions(-) delete mode 100755 ar/.local/bin/displayselect create mode 100755 ar/.local/bin/dmenudisplay (limited to 'ar') diff --git a/ar/.config/shell/aliasrc b/ar/.config/shell/aliasrc index e4ac623..3688ef4 100644 --- a/ar/.config/shell/aliasrc +++ b/ar/.config/shell/aliasrc @@ -491,6 +491,8 @@ alias szs="source ${XDG_CONFIG_HOME:-${HOME}/.config}/zsh/.zshrc" alias ylogh='ylog -s hidden -c us | grep $(LC_TIME=C date +%d/%b) | grep -E "[0-9]{2}:[0-9]{2}:[0-9]{2} "' alias ylogi='ylog -s hidden -c us | grep $(LC_TIME=C date -d "1 days ago" +%d/%b) | grep -E "[0-9]{2}:[0-9]{2}:[0-9]{2} "' +alias ylogp='ylog -s peertube | grep $(LC_TIME=C date +%d/%b) | grep -E "[0-9]{2}:[0-9]{2}:[0-9]{2} "' +alias ylogP='ylog -s peertube | grep $(LC_TIME=C date -d "1 days ago" +%d/%b) | grep -E "[0-9]{2}:[0-9]{2}:[0-9]{2} "' alias ylogt='ylog -s diary -c us | grep $(LC_TIME=C date +%d/%b) | grep -E "[0-9]{2}:[0-9]{2}:[0-9]{2} "' alias ylogy='ylog -s diary -c us | grep $(LC_TIME=C date -d "1 days ago" +%d/%b) | grep -E "[0-9]{2}:[0-9]{2}:[0-9]{2} "' alias ylogr='ylog -s diary -c us | grep $(LC_TIME=C date -d "2 days ago" +%d/%b) | grep -E "[0-9]{2}:[0-9]{2}:[0-9]{2} "' diff --git a/ar/.config/zsh/.zshrc b/ar/.config/zsh/.zshrc index a73891e..3602f50 100644 --- a/ar/.config/zsh/.zshrc +++ b/ar/.config/zsh/.zshrc @@ -117,10 +117,9 @@ zstyle ':fzf-tab:*' switch-group ',' '.' # switch group using `,` and `.` [ -f "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/shortcutrc" ] && source "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/shortcutrc" [ -f "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/shortcutenvrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutenvrc" [ -f "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/zshnameddirrc" ] && source "${XDG_CONFIG_HOME:-${HOME}/.config}/shell/zshnameddirrc" -source "$HOME/.local/share/../bin/env" -## --- TMUX --- ### +### --- TMUX --- ### if command -v tmux >/dev/null 2>&1 && [ -z "$TMUX" ]; then terminal_count=$(pgrep -u "$USER" -ax "${TERMINAL:-st}" | grep -Ev 'ncmpcpp|newsboat|pulsemixer|spterm|splf|spcalc|stig|vimwikitodo' | wc -l) if [ "$terminal_count" -le 1 ]; then diff --git a/ar/.local/bin/displayselect b/ar/.local/bin/displayselect deleted file mode 100755 index 87c8bd6..0000000 --- a/ar/.local/bin/displayselect +++ /dev/null @@ -1,95 +0,0 @@ -#!/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?") - [ -z "$mirror" ] && exit - # 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:") - [ -z "$primary" ] && exit - secondary=$(echo "$screens" | grep -v ^"$primary"$) - direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?") - xrandr --output "$primary" --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:") - [ -z "$primary" ] && exit - 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" --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" --primary --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/ar/.local/bin/dmenudisplay b/ar/.local/bin/dmenudisplay new file mode 100755 index 0000000..4673599 --- /dev/null +++ b/ar/.local/bin/dmenudisplay @@ -0,0 +1,126 @@ +#!/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. +# +# Options: +# -r Enable resolution selection for each display + +# Parse options +select_resolution=false +while getopts "r" opt; do + case $opt in + r) select_resolution=true ;; + *) echo "Usage: $0 [-r]" >&2; exit 1 ;; + esac +done +shift $((OPTIND - 1)) + +# Function to select resolution for a display +get_resolution() { + display="$1" + if [ "$select_resolution" = true ]; then + resolutions=$(xrandr --query | sed -n "/^$display/,/^[^ ]/p" | grep -v "^$display" | grep -v "^[^ ]" | awk '{print $1}' | grep -E "^[0-9]+x[0-9]+$") + chosen_res=$(echo "$resolutions" | dmenu -i -p "Resolution for $display:") + [ -n "$chosen_res" ] && echo "--mode $chosen_res" || echo "--auto" + else + echo "--auto" + fi +} + +twoscreen() { # If multi-monitor is selected and there are two screens. + mirror=$(printf "no\\nyes" | dmenu -i -p "Mirror displays?") + [ -z "$mirror" ] && exit + # 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:") + [ -z "$primary" ] && exit + secondary=$(echo "$screens" | grep -v ^"$primary"$) + direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?") + primary_res=$(get_resolution "$primary") + secondary_res=$(get_resolution "$secondary") + xrandr --output "$primary" --primary $primary_res --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" $secondary_res --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:") + [ -z "$primary" ] && exit + 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:") + primary_res=$(get_resolution "$primary") + secondary_res=$(get_resolution "$secondary") + tertiary_res=$(get_resolution "$tertiary") + xrandr --output "$primary" --primary $primary_res --output "$secondary" --"$direction"-of "$primary" $secondary_res --output "$tertiary" --"$(printf "left\\nright" | grep -v "$direction")"-of "$primary" $tertiary_res +} + +multimon() { # Multi-monitor handler. + case "$(echo "$screens" | wc -l)" in + 2) twoscreen ;; + *) morescreen ;; + esac +} + +onescreen() { # If only one output available or chosen. + res_opt=$(get_resolution "$1") + xrandr --output "$1" --primary $res_opt --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 -- cgit v1.2.3