From 1fcb64c6a29e646a1a08112efa695ce20850c610 Mon Sep 17 00:00:00 2001 From: Nemo Date: Tue, 7 May 2019 14:53:23 +0530 Subject: [PATCH] switch to autorandr, leave warning on display --- files/bash/.bashrc | 71 ++++++++++++++++++++++++--------------------- files/i3/.i3/config | 7 ++++- 2 files changed, 44 insertions(+), 34 deletions(-) diff --git a/files/bash/.bashrc b/files/bash/.bashrc index 835565f..d20c855 100644 --- a/files/bash/.bashrc +++ b/files/bash/.bashrc @@ -452,39 +452,44 @@ man() { # Overrides the display provided by imagemagick function display() { - layout="$1" - if [[ "$1" == "toggle" ]]; then - # exchange it - CURRENT=$(cat ~/.screenlayout/current) - echo "current=$CURRENT" - case "$CURRENT" in - "office") - layout="single" - ;; - "single") - layout="office" - ;; - esac - fi - echo "layout=$layout" - if [[ "$layout" == "home" ]]; then - xrandr --newmode "2560x1080_60.00" \ - 230.00 2560 2720 2992 3424 \ - 1080 1083 1093 1120 -hsync +vsync - xrandr --addmode HDMI1 "2560x1080_60.00" - fi - if [[ -a ~/.screenlayout/$layout.sh ]]; then - `cd ~/.screenlayout && sh $layout.sh` - # Write the current layout - echo $layout > ~/.screenlayout/current - if [[ -e "~/Pictures/$layout.jpg" ]]; then - (cd ~/Pictures && cp "$layout.jpg" "./xin_1.jpg") - fi - sleep 3 - nitrogen --restore - i3-msg reload - # dunst doesn't like screensize changes - killall dunst;notify-send "Display Switched" + if [[ `which autorandr` ]]; then + autorandr + else + echo "[warn] Reminder to switch to autorandr" + layout="$1" + if [[ "$1" == "toggle" ]]; then + # exchange it + CURRENT=$(cat ~/.screenlayout/current) + echo "current=$CURRENT" + case "$CURRENT" in + "office") + layout="single" + ;; + "single") + layout="office" + ;; + esac + fi + echo "layout=$layout" + if [[ "$layout" == "home" ]]; then + xrandr --newmode "2560x1080_60.00" \ + 230.00 2560 2720 2992 3424 \ + 1080 1083 1093 1120 -hsync +vsync + xrandr --addmode HDMI1 "2560x1080_60.00" + fi + if [[ -a ~/.screenlayout/$layout.sh ]]; then + `cd ~/.screenlayout && sh $layout.sh` + # Write the current layout + echo $layout > ~/.screenlayout/current + if [[ -e "~/Pictures/$layout.jpg" ]]; then + (cd ~/Pictures && cp "$layout.jpg" "./xin_1.jpg") + fi + sleep 3 + nitrogen --restore + i3-msg reload + # dunst doesn't like screensize changes + killall dunst;notify-send "Display Switched" + fi fi } diff --git a/files/i3/.i3/config b/files/i3/.i3/config index c79add9..5e8afe0 100644 --- a/files/i3/.i3/config +++ b/files/i3/.i3/config @@ -33,6 +33,9 @@ exec i3-msg "workspace $WS1; exec cwdterm.sh" # Web workspace exec i3-msg "workspace $WS2; exec firefox-beta" +# Startup figure out monitors +exec autorandr + # Quick switching between workspace is disabled # Just leads to confusion workspace_auto_back_and_forth no @@ -258,6 +261,7 @@ bindsym F2 scratchpad show # Only for Nasc bindsym $mod+F3 [class="Com.github.parnold-x.nasc"] scratchpad show + # Scratchpad bindsym $mod+shift+z move scratchpad @@ -274,7 +278,8 @@ bindsym $mod+shift+s move workspace to output right bindsym $mod+shift+w move workspace to output up bindsym $mod+shift+x move workspace to output down -bindsym XF86Display exec arandr +bindsym XF86Display exec autorandr +bindsym $mod+F9 exec autorandr client.focused #4E9C00 #4E9C00 #FFFFFF #FFFFFF client.focused_inactive #1B3600 #1B3600 #888888 #FFFFFF