From de9a1ede35d84fdf86fe82d09b8689614a0f359f Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Wed, 18 Jul 2018 12:33:49 -0700 Subject: Consolidate monitor setup and power --- home/.config/i3/config | 40 +++++++++++----------------------------- home/bin/setup | 46 ++++++++++++++++++++-------------------------- 2 files changed, 31 insertions(+), 55 deletions(-) diff --git a/home/.config/i3/config b/home/.config/i3/config index 5f12e1a..f5d9368 100644 --- a/home/.config/i3/config +++ b/home/.config/i3/config @@ -145,8 +145,9 @@ set $term sakura # Move the currently focused window to the scratchpad bindsym $mod+Shift+minus move scratchpad - # Show the next scratchpad window or hide the focused scratchpad window. - # If there are multiple scratchpad windows, this command cycles through them. + # Show the next scratchpad window or hide the focused scratchpad + # window. If there are multiple scratchpad windows, this command + # cycles through them. bindsym $mod+minus scratchpad show # # Resizing containers: @@ -187,7 +188,7 @@ bindsym $mod+r mode "resize" set $urgent-bg-color #676e7d # # Window colors: -# border background text indicator +# border background text indicator client.focused $bg-color $bg-color $text-color $bg-color client.unfocused $inactive-bg-color $inactive-bg-color $inactive-text-color $inactive-bg-color client.focused_inactive $inactive-bg-color $inactive-bg-color $inactive-text-color $inactive-bg-color @@ -248,17 +249,6 @@ bindsym $mod+r mode "resize" # # Quick launch menu # - mode "quick" { - bindsym e exec emacsclient --alternate-editor='' --create-frame --no-wait , mode "default" - bindsym f exec google-chrome, mode "default" - bindsym t exec $term, mode "default" - bindsym y exec ~/bin/passmenu --type, mode "default" - bindsym Shift+y exec ~/bin/passmenu, mode "default" - bindsym Return mode "default" - bindsym Escape mode "default" - } - bindsym $mod+q mode "quick" - mode "media" { bindsym space \ exec --no-startup-id dbus-send --print-reply \ @@ -280,24 +270,16 @@ bindsym $mod+r mode "resize" bindsym Escape mode "default" } bindsym $mod+m mode "media" - - mode "setup" { - bindsym 0 exec --no-startup-id ~/bin/setup mirror - bindsym 1 exec --no-startup-id ~/bin/setup single - bindsym 2 exec --no-startup-id ~/bin/setup double - bindsym 3 exec --no-startup-id ~/bin/setup triple - bindsym Return mode "default" - bindsym Escape mode "default" - } - bindsym $mod+Control+s mode setup - bindsym XF86Explorer mode setup - # # Session and power management # exec --no-startup-id xss-lock -- ~/bin/lock - set $mode_system (l) lock, (e) logout, (s) suspend, (r) reboot, (S) shutdown + set $mode_system [0-3] monitor, (l) lock, (e) logout, (s) suspend, (r) reboot, (S) shutdown mode "$mode_system" { + bindsym 0 exec --no-startup-id ~/bin/setup mirror, mode "default" + bindsym 1 exec --no-startup-id ~/bin/setup single, mode "default" + bindsym 2 exec --no-startup-id ~/bin/setup double, mode "default" + bindsym 3 exec --no-startup-id ~/bin/setup triple, mode "default" bindsym l exec --no-startup-id ~/bin/lock, mode "default" bindsym e exec --no-startup-id i3-msg exit, mode "default" bindsym s exec --no-startup-id systemctl suspend, mode "default" @@ -313,9 +295,9 @@ bindsym $mod+r mode "resize" # disable audible bell exec set -b # enable tap to click on touchpad -exec_always xinput set-prop 12 280 1 +exec_always --no-startup-id xinput set-prop 12 280 1 # increase pointer acceleration on touchpad -exec_always xinput set-prop 12 300 0.5 +exec_always --no-startup-id xinput set-prop 12 300 0.5 exec --no-startup-id redshift exec --no-startup-id sakura --name=sakura_scratchpad diff --git a/home/bin/setup b/home/bin/setup index 310b01e..eafa464 100755 --- a/home/bin/setup +++ b/home/bin/setup @@ -1,16 +1,20 @@ #!/bin/bash internal=eDP-1 -externals=($(xrandr | grep -w connected | grep -v "$internal" | cut -d ' ' -f 1)) - +mapfile -t externals < <(xrandr \ + | grep -w connected \ + | grep -v "$internal" \ + | cut -d ' ' -f 1) move_workspaces() { - local primary=$(i3-msg -t get_outputs | jq '.[]|select(.primary==true)|.name') + local primary + primary=$(i3-msg -t get_outputs | jq '.[]|select(.primary==true)|.name') for workspace_number in $(i3-msg -t get_workspaces | jq .[].num); do - i3-msg workspace number "$workspace_number", move workspace to output "$primary" + i3-msg \ + workspace number "$workspace_number", \ + move workspace to output "$primary" done } -# export -f move_workspace case "$1" in single) @@ -18,42 +22,32 @@ case "$1" in for external in "${externals[@]}"; do xrandr --output "$external" --off done - #xrandr --dpi 172 - #gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gdk/WindowScalingFactor': <1>}" ;; double) - xrandr --output "$internal" --auto --output "${externals[0]}" --auto --primary --above "$internal" - # current_workspace="$(i3-msg -t get_workspaces \ - # | jq '.[] | select(.focused==true).name' \ - # | cut -d"\"" -f2)" - - # i3-msg -t get_workspaces | jq -r .[].name | xargs -I{} bash -c "move_workspace {}" - # i3-msg workspace "$current_workspace" - - - #gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gdk/WindowScalingFactor': <1>}" + xrandr \ + --output "$internal" --auto \ + --output "${externals[0]}" --auto --primary --above "$internal" ;; triple) xrandr \ --output "$internal" --auto \ --output "${externals[0]}" --auto --primary --above "$internal" \ - --output "${externals[1]}" --auto --right-of "${externals[0]}" --rotate left + --output "${externals[1]}" --auto --right-of "${externals[0]}" \ + --rotate left ;; mirror) - xrandr --output "$internal" --primary --auto --output "${externals[0]}" --auto --scale-from 1920x1080 - #gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gdk/WindowScalingFactor': <1>}" + xrandr \ + --output "$internal" --auto --primary \ + --output "${externals[0]}" --auto --scale-from 1920x1080 ;; *) - echo "Usage: $0 (single|double|mirror)" 1>&2 + echo "Usage: $0 (single|double|triple|mirror)" 1>&2 exit 1 ;; esac xmodmap ~/.Xmodmap move_workspaces -i3-msg restart -exit 0 +feh --bg-scale ~/.background.png -#echo "Reverting to single display in 10 seconds." 1>&2 -#sleep 10 -#"$0" single +exit 0 -- cgit v1.2.3