mirror of
https://github.com/kastdeur/dotfiles.git
synced 2024-12-21 16:53:33 +01:00
[X11] Preprocess ./.Xresources when installing
This commit is contained in:
parent
279b135ffe
commit
ccba451d3d
3 changed files with 52 additions and 3 deletions
|
@ -27,7 +27,7 @@
|
|||
~/.vimrc: vim/vimrc
|
||||
~/.xinitrc: X11/xinitrc
|
||||
~/.xprofile: X11/xprofile
|
||||
~/.Xresources: X11/Xresources
|
||||
~/.Xresources.src: X11/Xresources.src
|
||||
~/.Xresources.d/urxvt: urxvt/Xresources
|
||||
~/.config/user-dirs.dirs: X11/user-dirs.dirs
|
||||
~/.config/awesome: awesome
|
||||
|
@ -37,5 +37,9 @@
|
|||
~/.ssh/keys/:
|
||||
mode: 0700
|
||||
|
||||
#- shell:
|
||||
# - git submodules update # after linking ~/.gitconfig
|
||||
- shell:
|
||||
-
|
||||
command: ./bin/Xresources-preprocess
|
||||
description: Preprocess Xresources.src so that xrdb doesn't have to.
|
||||
stderr: true
|
||||
# - git submodules update # after linking ~/.gitconfig
|
||||
|
|
45
bin/Xresources-preprocess
Executable file
45
bin/Xresources-preprocess
Executable file
|
@ -0,0 +1,45 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Use the precompiler to allow for `xrdb -nocpp -merge ~/.Xresources`.
|
||||
# Inspiration from https://github.com/dolmen/Xresources.edit/blob/1be4f5601b3d4e8befa043386288c64e724ed746/Xresources.edit
|
||||
|
||||
fname=.Xresources
|
||||
ext=src
|
||||
force=
|
||||
|
||||
# Initial setup: move $fname to $fname.$ext
|
||||
if [ ! -f "$HOME/$fname.$ext" ]; then
|
||||
cat "$HOME/$fname" > "$HOME/$fname.$ext"
|
||||
|
||||
# Make $fname non-writable to discourage direct editing
|
||||
chmod a-wx "$HOME/$fname"
|
||||
fi
|
||||
|
||||
# Check mtime
|
||||
if [ -f "$HOME/$fname" -a "$HOME/$fname" -nt "$HOME/$fname.$ext" ]; then
|
||||
{
|
||||
echo "~/$fname is more recent than ~/$fname.$ext"
|
||||
echo "You have to fix this manually."
|
||||
echo "e.g. touch ~/$fname.$ext"
|
||||
} >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# Run cpp and save the result as ~/$fname
|
||||
[ -e "$HOME/$fname" ] && chmod u+w "$HOME/$fname"
|
||||
|
||||
{
|
||||
echo '! *************************************************'
|
||||
echo "! Do not edit ~/$fname, but ~/$fname.$ext"
|
||||
echo '! *************************************************'
|
||||
echo '! vim:set ft=xdefaults:'
|
||||
echo '!'
|
||||
} > "$HOME/$fname"
|
||||
|
||||
cpp "$HOME/$fname.$ext" | tee -a "$HOME/$fname"
|
||||
res=$?
|
||||
|
||||
# Make $fname non-writable to discourage direct editing
|
||||
chmod a-wx "$HOME/$fname"
|
||||
exit $res
|
Loading…
Reference in a new issue