From d935345c8aa7685fa6c5d3fc65a4ae30e1425942 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Mon, 2 Aug 2021 17:26:15 +0200 Subject: [PATCH] Add command and script to automatically switch to nvidia drivers when needed --- .config/i3/config | 2 ++ .zshrc | 3 +++ multihead.sh | 12 ++++++++++++ 3 files changed, 17 insertions(+) create mode 100755 multihead.sh diff --git a/.config/i3/config b/.config/i3/config index bfafe27..ba1a890 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -620,3 +620,5 @@ exec_always --no-startup-id feh --bg-scale ~/Images/Wallpapers/aerial_waves.jpg exec_always --no-startup-id xbindkeys --poll-rc exec_always --no-startup-id eww daemon & exec_always --no-startup-id udiskie & + +exec --no-startup-id /home/tanguy/multihead.sh diff --git a/.zshrc b/.zshrc index a9ee124..4b9fc02 100644 --- a/.zshrc +++ b/.zshrc @@ -88,6 +88,9 @@ dotfiles config --local status.showUntrackedFiles no # Switch between nvidia and intel drivers with one command alias driver='optimus-manager --no-confirm --switch' +# Enable nvidia drivers and trigger the default multi-head configuration +alias multihead='touch /tmp/multihead && driver nvidia' + # Add an alias to the powerpill wrapper for pacman alias pac='sudo pacman -S' diff --git a/multihead.sh b/multihead.sh new file mode 100755 index 0000000..d48452c --- /dev/null +++ b/multihead.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +if [ /tmp/multihead ] ; then + rm /tmp/multihead + # xrandr --auto --output HDMI-0 --right-of eDP-1-1 && xrandr --auto --output DP-1-1 --right-of HDMI-0 + xrandr --auto --output DP-1-1 --left-of eDP-1-1 && xrandr --auto --output HDMI-0 --left-of DP-1-1 + + i3-msg "workspace 3, move workspace to output eDP-1-1" + i3-msg "workspace 1, move workspace to output HDMI-0" + i3-msg "workspace 2, move workspace to output DP-1-1" + ~/.config/polybar/launch.sh > /dev/null 2>&1 +fi