dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit 13a102ae7720e0f9f0effad80c3d5baba7370bb7
parent 3549dc37b9c142e6f11e60f6aeefc168275d8513
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Sun, 23 Dec 2018 11:57:58 +0100

Use lukesmithxyz script for display selection

Diffstat:
Mlinks/.commands.sh | 3+++
Mlinks/.config/i3/config | 20++++++++++----------
Alinks/bin/displayselect | 47+++++++++++++++++++++++++++++++++++++++++++++++
Mlinks/bin/xrandr-auto.sh | 9+++++++--
4 files changed, 67 insertions(+), 12 deletions(-)

diff --git a/links/.commands.sh b/links/.commands.sh @@ -187,4 +187,7 @@ transfer() { # use transfer.sh to share files over the net rm -f "$tmpfile" echo "" } + +alias transmission-cli='transmission-cli --encryption-required --download-dir=~/Downloads' + [ -f ~/.shortcuts ] && source ~/.shortcuts diff --git a/links/.config/i3/config b/links/.config/i3/config @@ -92,8 +92,8 @@ bindsym $mod+grave exec --no-startup-id ~/bin/ddspawn ~/bin/tmuxdd bindsym $mod+p exec --no-startup-id ~/bin/ddspawn ~/bin/dropdowncalc # keyboard backlight -bindsym XF86KbdBrightnessDown exec --no-startup-id /home/ad/bin/kbd_backlight.sh down -bindsym XF86KbdBrightnessUp exec --no-startup-id /home/ad/bin/kbd_backlight.sh up +bindsym XF86KbdBrightnessDown exec --no-startup-id ~/bin/kbd_backlight.sh down +bindsym XF86KbdBrightnessUp exec --no-startup-id ~/bin/kbd_backlight.sh up # mpd control bindsym Control+Shift+m exec $term -e ncmpcpp @@ -103,16 +103,16 @@ bindsym Control+Shift+b exec --no-startup-id mpc prev && pkill -RTMIN+14 i3block bindsym Control+Shift+s exec --no-startup-id mpc stop && pkill -RTMIN+14 i3blocks # configure displays -#bindsym $mod+Shift+d exec --no-startup-id bash /home/ad/code/dotfiles/bin/xrandr-auto.sh -bindsym XF86Display exec --no-startup-id bash /home/ad/code/dotfiles/bin/xrandr-auto.sh -bindsym $mod+Shift+a exec --no-startup-id bash /home/ad/bin/wallpaper.sh && xrandr --auto -bindsym XF86Launch1 exec --no-startup-id bash /home/ad/bin/wallpaper.sh && xrandr --auto +#bindsym $mod+Shift+d exec --no-startup-id bash ~/bin/xrandr-auto.sh +#bindsym $mod+Shift+a exec --no-startup-id bash ~/bin/wallpaper.sh && xrandr --auto +bindsym $mod+Shift+a exec --no-startup-id ~/bin/displayselect +bindsym XF86Launch1 exec --no-startup-id ~/bin/wallpaper.sh && xrandr --auto # screen lock -#bindsym $mod+z exec /home/ad/bin/zzz -#bindsym $mod+x exec /home/ad/bin/xlock -bindsym XF86ScreenSaver exec /home/ad/bin/xlock -bindsym XF86Sleep exec /home/ad/bin/zzz +#bindsym $mod+z exec ~/bin/zzz +#bindsym $mod+x exec ~/bin/xlock +bindsym XF86ScreenSaver exec ~/bin/xlock +bindsym XF86Sleep exec ~/bin/zzz # kill focused window bindsym $mod+Shift+q kill diff --git a/links/bin/displayselect b/links/bin/displayselect @@ -0,0 +1,47 @@ +#!/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. +# 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 + } + +morescreen() { # If multi-monitor is selected and there are more than two screens. + primary=$(echo "$screens" | dmenu -i -p "asdf") + 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 + 1) xrandr $(echo "$allposs" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;; + 2) twoscreen ;; + *) morescreen ;; + esac ;} + +# Get all possible displays +allposs=$(xrandr -q | grep "connected") + +# Get all connected screens. +screens=$(echo "$allposs" | grep " connected" | awk '{print $1}') + +# 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 ;; + *) xrandr --output "$chosen" --auto $(echo "$screens" | grep -v "$chosen" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;; +esac + +# Fix feh background if screen size/arangement has changed. +feh --bg-scale "$HOME/.config/wall.png" +# Re-remap keys if keyboard added (for laptop bases) +#remaps diff --git a/links/bin/xrandr-auto.sh b/links/bin/xrandr-auto.sh @@ -1,6 +1,8 @@ #!/bin/bash -LAPTOPSCR=eDP1 +notify-send "Running xrand-auto.sh" + +LAPTOPSCR=LVDS1 EXTSCR=DP1 #PROJECTOR= @@ -10,7 +12,8 @@ MONITOR=$LAPTOPSCR # functions to switch from LVDS1 to VGA and vice versa function ActivateEXT { #echo "Switching to EXTSCR" - xrandr --output $EXTSCR --auto --output $LAPTOPSCR --off + #xrandr --output $EXTSCR --auto --output $LAPTOPSCR --off + xrandr --output $EXTSCR --auto --output $LAPTOPSCR --auto ~/bin/wallpaper.sh MONITOR=$EXTSCR #notify-send "Activating $EXTSCR" @@ -36,11 +39,13 @@ function EXTConnected { #do if ! EXTActive && EXTConnected then + notify-send "Activating external monitor $EXSCR" ActivateEXT fi if EXTActive && ! EXTConnected then + notify-send "Deactivating external monitor $EXSCR" DeactivateEXT fi