From a784801badaddb87fcdb5fa1036adcc6aee73826 Mon Sep 17 00:00:00 2001 From: FollieHiyuki Date: Thu, 11 Mar 2021 14:22:29 +0300 Subject: [PATCH] x11: add `monitors.sh` script --- home/.config/bspwm/bspwmrc | 2 +- home/.config/doom/config.el | 2 +- home/.config/doom/exwm.el | 6 ++---- home/.config/spectrwm/autostart | 2 +- home/.local/bin/X11/monitors.sh | 18 ++++++++++++++++++ 5 files changed, 23 insertions(+), 7 deletions(-) create mode 100755 home/.local/bin/X11/monitors.sh diff --git a/home/.config/bspwm/bspwmrc b/home/.config/bspwm/bspwmrc index b6015d6..bbb928d 100755 --- a/home/.config/bspwm/bspwmrc +++ b/home/.config/bspwm/bspwmrc @@ -9,7 +9,7 @@ $HOME/.config/polybar/run_polybar.sh & ibus-daemon -drx & greenclip daemon & # emacs --daemon & -# xrandr --output eDP-1 --primary --auto --output DP-2 --left-of eDP-1 --auto --output HDMI-2 --right-of eDP-1 --auto & +# $HOME/.local/bin/X11/monitors.sh # animatedwall --full ~/Pictures/Animated/fubuki.mp4 & feh --no-fehbg --bg-fill --randomize ~/Pictures/Wallpapers/* & mpDris2 & diff --git a/home/.config/doom/config.el b/home/.config/doom/config.el index 7ab1276..b93a008 100644 --- a/home/.config/doom/config.el +++ b/home/.config/doom/config.el @@ -109,7 +109,7 @@ (map! :map minibuffer-local-map "C-r" 'counsel-minibuffer-history) (use-package! all-the-icons-ivy-rich - :after counsel-projectile + :defer-incrementally counsel-projectile :init (all-the-icons-ivy-rich-mode 1) :config (setq all-the-icons-ivy-rich-icon-size 1.0)) diff --git a/home/.config/doom/exwm.el b/home/.config/doom/exwm.el index fd8f4db..e929afa 100644 --- a/home/.config/doom/exwm.el +++ b/home/.config/doom/exwm.el @@ -36,12 +36,10 @@ (exwm-layout-hide-mode-line)))) (defun follie/update-displays () - (lambda () - (start-process-shell-command - "xrandr" nil "xrandr --output eDP-1 --mode 1920x1080 --pos 0x0 --rotate normal --output HDMI-1 --mode 1920x1080 --pos 1920x0 --rotate normal")) + (follie/run-in-background "~/.local/bin/X11/monitors.sh") (follie/set-wallpaper) (message "Updated displays: %s" - (string-trim (shell-command-to-string "xrandr | grep \" connected\" | awk '{print $1}' | sed '$!N;s/\\n/ /'")))) + (string-trim (shell-command-to-string "xrandr | grep \" connected\" | awk '{print $1}' | sed 's/^/ /' | tr -d '\\n'")))) (defun follie/exwm-rename-buffer () (exwm-workspace-rename-buffer diff --git a/home/.config/spectrwm/autostart b/home/.config/spectrwm/autostart index 7d7ddd6..5a9b5d7 100755 --- a/home/.config/spectrwm/autostart +++ b/home/.config/spectrwm/autostart @@ -5,7 +5,7 @@ dunst & ibus-daemon -drx & greenclip daemon & # emacs --daemon & -# xrandr --output eDP-1 --primary --auto --output DP-2 --left-of eDP-1 --auto --output HDMI-2 --right-of eDP-1 --auto & +# $HOME/.local/bin/X11/monitors.sh # animatedwall --full ~/Pictures/Animated/fubuki.mp4 & feh --no-fehbg --bg-fill --randomize ~/Pictures/Wallpapers/* & mpDris2 & diff --git a/home/.local/bin/X11/monitors.sh b/home/.local/bin/X11/monitors.sh new file mode 100755 index 0000000..8448e7c --- /dev/null +++ b/home/.local/bin/X11/monitors.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +status=$(xrandr | grep " connected") + +# Built-int monitor +xrandr --output eDP-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal + +if echo "$status" | grep "HDMI-1"; then + xrandr --output HDMI-1 --mode 1920x1080 --pos 1920x0 --rotate normal +else + xrandr --output HDMI-1 --off +fi + +if echo "$status" | grep "DP-2"; then + xrandr --output DP-2 --mode 1920x1080 --pos -1920x0 --rotate normal +else + xrandr --output DP-2 --off +fi