From 5bb0014265536ee59a9d63625f716257bdd2785c Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sun, 26 Apr 2020 21:01:48 -0700 Subject: [PATCH] Reorganize xsession and Xresources MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add xsession. Instead of requiring each of my machines to setup their own ‘.xsession’ add one that should work for all of them. - Use M4 for the Xresources database. I didn’t want the X11 project to be aware of all the configuration files that could be added in there and I was able to figure out how to have it load all of the configuration files in the ‘Xresources.d’ directory. Now each configuration can inject properties into the X resources database. - Have ‘.xsession’ load all of the scripts in ‘.config/X11/Xsession.d’. Each configuration can now inject some script to run when X starts. - Have ‘.xsession’ load a machine-specific script so that each machine can override what it does when X starts. --- GNUmakefile | 1 + fonts/.config/X11/Xresources.d/xft.conf | 6 ++ lib/usr/lib/sh/loading.sh | 23 +++++ picom/.config/Xsession.d/picom.sh | 3 + redshift/.config/Xsession.d/redshift-gtk.sh | 3 + rofi/.config/X11/Xresources.d/Rofi.conf | 38 ++++++++ rofi/.config/Xresources/Rofi.conf | 18 ---- .../Xresources.d}/URxvt.conf | 0 x11/.Xresources | 4 - x11/.config/X11/Xresources | 35 ++++++++ .../Xresources.d}/Xcursor.conf | 0 x11/.config/X11/machines/drd.sh | 4 + x11/.config/Xresources/theme.conf | 89 ------------------- x11/.xsession | 20 +++++ 14 files changed, 133 insertions(+), 111 deletions(-) create mode 100644 fonts/.config/X11/Xresources.d/xft.conf create mode 100644 lib/usr/lib/sh/loading.sh create mode 100644 picom/.config/Xsession.d/picom.sh create mode 100644 redshift/.config/Xsession.d/redshift-gtk.sh create mode 100644 rofi/.config/X11/Xresources.d/Rofi.conf delete mode 100644 rofi/.config/Xresources/Rofi.conf rename urxvt/.config/{Xresources => X11/Xresources.d}/URxvt.conf (100%) delete mode 100644 x11/.Xresources create mode 100644 x11/.config/X11/Xresources rename x11/.config/{Xresources => X11/Xresources.d}/Xcursor.conf (100%) create mode 100644 x11/.config/X11/machines/drd.sh delete mode 100644 x11/.config/Xresources/theme.conf create mode 100755 x11/.xsession diff --git a/GNUmakefile b/GNUmakefile index 1cd6768..9e66133 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -12,6 +12,7 @@ clean: $(addsuffix -clean,$(MODULES)) zsh: $(MAKE) -C $@ +x11-install: lib-install %-install: % $(STOW) $< diff --git a/fonts/.config/X11/Xresources.d/xft.conf b/fonts/.config/X11/Xresources.d/xft.conf new file mode 100644 index 0000000..e722898 --- /dev/null +++ b/fonts/.config/X11/Xresources.d/xft.conf @@ -0,0 +1,6 @@ +Xft.autohint: 0 +Xft.lcdfilter: lcddefault +Xft.hintstyle: hintslight +Xft.hinting: 1 +Xft.antialias: 0 +Xft.rgba: rgb diff --git a/lib/usr/lib/sh/loading.sh b/lib/usr/lib/sh/loading.sh new file mode 100644 index 0000000..47c396a --- /dev/null +++ b/lib/usr/lib/sh/loading.sh @@ -0,0 +1,23 @@ +load_machine_config() { + directory="$1" + path="${HOME}/${directory}/$(hostname).sh" + + # shellcheck source=/dev/null + [ -x "$path" ] && . "$path" + + unset directory + unset path +} + +load_config_directory() { + directory="$1" + path="${HOME}/${directory}" + + if [ -d "${path}" ]; then + for f in "${path}/"?*.sh; do + # shellcheck source=/dev/null + [ -x "$f" ] && . "$f" + done + unset f + fi +} diff --git a/picom/.config/Xsession.d/picom.sh b/picom/.config/Xsession.d/picom.sh new file mode 100644 index 0000000..1a095e8 --- /dev/null +++ b/picom/.config/Xsession.d/picom.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +pgrep picom || picom --daemon diff --git a/redshift/.config/Xsession.d/redshift-gtk.sh b/redshift/.config/Xsession.d/redshift-gtk.sh new file mode 100644 index 0000000..72898b0 --- /dev/null +++ b/redshift/.config/Xsession.d/redshift-gtk.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +pgrep redshift-gtk || { redshift-gtk & } diff --git a/rofi/.config/X11/Xresources.d/Rofi.conf b/rofi/.config/X11/Xresources.d/Rofi.conf new file mode 100644 index 0000000..6eedca2 --- /dev/null +++ b/rofi/.config/X11/Xresources.d/Rofi.conf @@ -0,0 +1,38 @@ +dnl Rofi colors +define(`Rofi_normal_bg', `bgdim')dnl +define(`Rofi_normal_fg', `fgdefault')dnl +define(`Rofi_normal_bgalt', `Rofi_normal_bg')dnl +define(`Rofi_normal_hlbg', `bgblue')dnl +define(`Rofi_normal_hlfg', `fgdefault')dnl +define(`Rofi_urgent_bg', `bgdefault')dnl +define(`Rofi_urgent_fg', `fgred')dnl +define(`Rofi_urgent_bgalt', `Rofi_urgent_bg')dnl +define(`Rofi_urgent_hlbg', `Rofi_normal_hlbg')dnl +define(`Rofi_urgent_hlfg', `Rofi_urgent_fg')dnl +define(`Rofi_active_bg', `bgdefault')dnl +define(`Rofi_active_fg', `fgcyan')dnl +define(`Rofi_active_bgalt', `Rofi_active_bg')dnl +define(`Rofi_active_hlbg', `Rofi_normal_hlbg')dnl +define(`Rofi_active_hlfg', `Rofi_active_fg')dnl +define(`Rofi_window_bg', `Rofi_normal_bg')dnl +define(`Rofi_window_border', `Rofi_normal_bg')dnl +define(`Rofi_window_separator', `Rofi_normal_bg')dnl +dnl +! Use a nice font. +rofi.font: Fantasque Sans Mono 15 + +! Add C-g to the keys used to cancel an action in Rofi. I am used to +! this from Emacs and I always press it before I press ESC. +rofi.kb-cancel: Escape,Control+bracketleft,Control+g + +! Hide the scrollbar +rofi.hide-scrollbar: true + +! Show a thick border around Rofi +rofi.bw: 15 + +! Theme +rofi.color-normal: Rofi_normal_bg, Rofi_normal_fg, Rofi_normal_bgalt, Rofi_normal_hlbg, Rofi_normal_hlfg +rofi.color-urgent: Rofi_urgent_bg, Rofi_urgent_fg, Rofi_urgent_bgalt, Rofi_urgent_hlbg, Rofi_urgent_hlfg +rofi.color-active: Rofi_active_bg, Rofi_active_fg, Rofi_active_bgalt, Rofi_active_hlbg, Rofi_active_hlfg +rofi.color-window: Rofi_window_bg, Rofi_window_border, Rofi_window_separator diff --git a/rofi/.config/Xresources/Rofi.conf b/rofi/.config/Xresources/Rofi.conf deleted file mode 100644 index c4098b6..0000000 --- a/rofi/.config/Xresources/Rofi.conf +++ /dev/null @@ -1,18 +0,0 @@ -! Use a nice font. -rofi.font: Fantasque Sans Mono 15 - -! Add C-g to the keys used to cancel an action in Rofi. I am used to -! this from Emacs and I always press it before I press ESC. -rofi.kb-cancel: Escape,Control+bracketleft,Control+g - -! Hide the scrollbar -rofi.hide-scrollbar: true - -! Show a thick border around Rofi -rofi.bw: 15 - -! Theme -rofi.color-normal: Rofi_normal_bg, Rofi_normal_fg, Rofi_normal_bgalt, Rofi_normal_hlbg, Rofi_normal_hlfg -rofi.color-urgent: Rofi_urgent_bg, Rofi_urgent_fg, Rofi_urgent_bgalt, Rofi_urgent_hlbg, Rofi_urgent_hlfg -rofi.color-active: Rofi_active_bg, Rofi_active_fg, Rofi_active_bgalt, Rofi_active_hlbg, Rofi_active_hlfg -rofi.color-window: Rofi_window_bg, Rofi_window_border, Rofi_window_separator diff --git a/urxvt/.config/Xresources/URxvt.conf b/urxvt/.config/X11/Xresources.d/URxvt.conf similarity index 100% rename from urxvt/.config/Xresources/URxvt.conf rename to urxvt/.config/X11/Xresources.d/URxvt.conf diff --git a/x11/.Xresources b/x11/.Xresources deleted file mode 100644 index 9c8304f..0000000 --- a/x11/.Xresources +++ /dev/null @@ -1,4 +0,0 @@ -#include ".config/Xresources/theme.conf" -#include ".config/Xresources/Xcursor.conf" -#include ".config/Xresources/Rofi.conf" -#include ".config/Xresources/URxvt.conf" diff --git a/x11/.config/X11/Xresources b/x11/.config/X11/Xresources new file mode 100644 index 0000000..a3f34cb --- /dev/null +++ b/x11/.config/X11/Xresources @@ -0,0 +1,35 @@ +define(`prefix', `$HOME/.config/X11/Xresources.d/')dnl +define(`resources', `esyscmd(`ls -m ' prefix ` | tr -d \\n')')dnl +define(`includeall', `ifelse($1, `', `', `include($1)includeall(shift($@))')')dnl +dnl +dnl Background colors +define(`bgdefault', `#111414')dnl +define(`bgbright', `#3d3d3d')dnl +define(`bgdim', `#222222')dnl +define(`bgred', `#3f1a1a')dnl +define(`bgorange', `#3f321f')dnl +define(`bgyellow', `#343922')dnl +define(`bggreen', `#263f1f')dnl +define(`bgturquoise', `#1f3f2c')dnl +define(`bgcyan', `#1f3f3f')dnl +define(`bgblue', `#1f2c3f')dnl +define(`bgpurple', `#2f2a3f')dnl +define(`bgmagenta', `#381f3f')dnl +define(`bgpink', `#3f1f32')dnl +dnl +dnl Foreground colors +define(`fgdefault', `#bfbfbf')dnl +define(`fgbright', `#ededed')dnl +define(`fgdim', `#969696')dnl +define(`fgred', `#a85454')dnl +define(`fgorange', `#a88654')dnl +define(`fgyellow', `#8d995c')dnl +define(`fggreen', `#65a854')dnl +define(`fgturquoise', `#54a875')dnl +define(`fgcyan', `#54a8a8')dnl +define(`fgblue', `#5476a8')dnl +define(`fgpurple', `#7d71a8')dnl +define(`fgmagenta', `#9754a8')dnl +define(`fgpink', `#a85487')dnl +dnl +includeall(resources) diff --git a/x11/.config/Xresources/Xcursor.conf b/x11/.config/X11/Xresources.d/Xcursor.conf similarity index 100% rename from x11/.config/Xresources/Xcursor.conf rename to x11/.config/X11/Xresources.d/Xcursor.conf diff --git a/x11/.config/X11/machines/drd.sh b/x11/.config/X11/machines/drd.sh new file mode 100644 index 0000000..72eeb2e --- /dev/null +++ b/x11/.config/X11/machines/drd.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh + +xrandr --output HDMI-0 --auto --primary \ + --output DVI-I-1 --auto --right-of HDMI-0 --rotate left diff --git a/x11/.config/Xresources/theme.conf b/x11/.config/Xresources/theme.conf deleted file mode 100644 index 51f4031..0000000 --- a/x11/.config/Xresources/theme.conf +++ /dev/null @@ -1,89 +0,0 @@ -!! Background colors -#define bgdefault #111414 -#define bgbright #3d3d3d -#define bgdim #222222 -#define bgred #3f1a1a -#define bgorange #3f321f -#define bgyellow #343922 -#define bggreen #263f1f -#define bgturquoise #1f3f2c -#define bgcyan #1f3f3f -#define bgblue #1f2c3f -#define bgpurple #2f2a3f -#define bgmagenta #381f3f -#define bgpink #3f1f32 - -!! Foreground colors -#define fgdefault #bfbfbf -#define fgbright #ededed -#define fgdim #969696 -#define fgred #a85454 -#define fgorange #a88654 -#define fgyellow #8d995c -#define fggreen #65a854 -#define fgturquoise #54a875 -#define fgcyan #54a8a8 -#define fgblue #5476a8 -#define fgpurple #7d71a8 -#define fgmagenta #9754a8 -#define fgpink #a85487 - -!! URxvt colors -#define URxvt_background bgdefault -#define URxvt_foreground fgdefault -#define URXvt_cursorColor fgblue -! BG Black -#define URxvt_color0 bgdim -! BG Red -#define URxvt_color1 fgred -! BG Green -#define URxvt_color2 fggreen -! BG Yellow -#define URxvt_color3 fgyellow -! BG Blue -#define URxvt_color4 fgblue -! BG Magenta -#define URxvt_color5 fgmagenta -! BG Cyan -#define URxvt_color6 fgcyan -! BG White -#define URxvt_color7 fgdim -! FG Black -#define URxvt_color8 bgbright -! FG Red -#define URxvt_color9 #da9d9d -! FG Green -#define URxvt_color10 #a9d39e -! FG Yellow -#define URxvt_color11 #c2ca9e -! FG Blue -#define URxvt_color12 #a2b8d8 -! FG Magenta -#define URxvt_color13 #d0a8da -! FG Cyan -#define URxvt_color14 #abdddd -! FG White -#define URxvt_color15 fgbright -! Selection highlight -#define URxvt_highlightColor bgblue -#define URxvt_highlightTextColor fgdefault - -!! Rofi colors -#define Rofi_normal_bg bgdim -#define Rofi_normal_fg fgdefault -#define Rofi_normal_bgalt Rofi_normal_bg -#define Rofi_normal_hlbg bgblue -#define Rofi_normal_hlfg fgdefault -#define Rofi_urgent_bg bgdefault -#define Rofi_urgent_fg fgred -#define Rofi_urgent_bgalt Rofi_urgent_bg -#define Rofi_urgent_hlbg Rofi_normal_hlbg -#define Rofi_urgent_hlfg Rofi_urgent_fg -#define Rofi_active_bg bgdefault -#define Rofi_active_fg fgcyan -#define Rofi_active_bgalt Rofi_active_bg -#define Rofi_active_hlbg Rofi_normal_hlbg -#define Rofi_active_hlfg Rofi_active_fg -#define Rofi_window_bg Rofi_normal_bg -#define Rofi_window_border Rofi_normal_bg -#define Rofi_window_separator Rofi_normal_bg diff --git a/x11/.xsession b/x11/.xsession new file mode 100755 index 0000000..70efe31 --- /dev/null +++ b/x11/.xsession @@ -0,0 +1,20 @@ +#!/usr/bin/env sh + +# shellcheck source=../lib/usr/lib/sh/loading.sh +. ~/usr/lib/sh/loading.sh + +xrdb -cpp m4 -merge "${HOME}/.config/X11/Xresources" \ + -I"${HOME}/.config/X11/Xresources.d" + +load_machine_config ".config/X11/machines" +load_config_directory ".config/X11/Xsession.d" + +command -v kdeconnect-indicator \ + && (pgrep kdeconnect-indicator \ + || { kdeconnect-indicator & }) + +command -v syncthing-gtk \ + && (pgrep syncthing-gtk \ + || { syncthing-gtk & }) + +command -v unclutter && (pgrep unclutter || unclutter --fork)