From 72760d3ec63b60aea1db84f147bfeb53a9ab3b1f Mon Sep 17 00:00:00 2001 From: Quentin Duchemin Date: Sun, 24 Feb 2019 21:20:30 +0100 Subject: [PATCH] Manage configuration outside ~/.config --- .config/lightdm/README | 1 - .config/lightdm/dest | 1 + .init_config.sh | 33 ++++++++++++++--- README.md | 81 ++++++++++++++++++++++++++++++------------ 4 files changed, 87 insertions(+), 29 deletions(-) delete mode 100644 .config/lightdm/README create mode 100644 .config/lightdm/dest diff --git a/.config/lightdm/README b/.config/lightdm/README deleted file mode 100644 index 913e7da..0000000 --- a/.config/lightdm/README +++ /dev/null @@ -1 +0,0 @@ -Theses files belong to /etc/lightdm. diff --git a/.config/lightdm/dest b/.config/lightdm/dest new file mode 100644 index 0000000..6d4d80a --- /dev/null +++ b/.config/lightdm/dest @@ -0,0 +1 @@ +/etc/lightdm diff --git a/.init_config.sh b/.init_config.sh index f4d0ac1..52e8560 100755 --- a/.init_config.sh +++ b/.init_config.sh @@ -2,13 +2,18 @@ LAPTOP="laptop" DESKTOP="desk" +DEST_FILENAME="dest" function usage() { - echo "$0: creates symlink for divergent config between laptop and desktop (e.g. battery management...)" + echo "$0: creates symlink for divergent config between laptop and desktop (e.g. battery management...) and copy configuration to external locations" echo "usage: $0 [${LAPTOP}|${DESKTOP}]" exit 0 } +# Use XDG_CONFIG_HOME if defined, default otherwise +CONFIG=${XDG_CONFIG_HOME:-$HOME/.config} + +# Check that there is one matching argument if [ -z "{$1}" ] || [ "$#" -ne 1 ]; then usage fi @@ -17,12 +22,30 @@ if [ "${1}" != "${LAPTOP}" ] && [ "${1}" != "${DESKTOP}" ]; then usage fi -for f in `find ~/.config -type f -name "*.${1}"`; do - echo "Symlinking to ${f}..." +echo "=== Create symlink to *.${1} regular files ===" +# Take all specific files and create a symlink pointing to it without the extension +# This file will be used by applications +for f in `find ${CONFIG} -type f -name "*.${1}"`; do + echo "Create symlink to ${f}..." ln -sf ${f} ${f%.*} done -for f in `find ~ -maxdepth 1 -mindepth 1 -type f -name "*.${1}"`; do - echo "Symlinking to ${f}..." +# Take care of config files at home level, outside ${CONFIG} (e.g. Xresources) +for f in `find ${HOME} -maxdepth 1 -mindepth 1 -type f -name "*.${1}"`; do + echo "Create symlink to ${f}..." ln -sf ${f} ${f%.*} +done + +echo -e "\n=== Copy configuration which resides in outer directory ===" +# Destination files are regular files +for f in `find ${CONFIG} -type f -name ${DEST_FILENAME}`; do + DIR=`dirname "${f}"` + DEST=`cat ${f}` + # Get all files, either regular files or symlinks, which are not the destination file nor specific desktop/laptop files + # This is because if desktop/laptop files exist, they already have a symlink pointing to them at this stage + for config_file in `find ${DIR} -maxdepth 1 -mindepth 1 -not \( -name "*.${LAPTOP}" -o -name "*.${DESKTOP}" -o -name "${DEST_FILENAME}" \)`; do + # Now copy to destination + echo "Copying ${config_file} to ${DEST}..." + sudo cp ${config_file} ${DEST} + done done \ No newline at end of file diff --git a/README.md b/README.md index 3a6b9d8..ed7de96 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,40 @@ # dotfiles -### Contents + + +- [What is this, Chosto ?](#what-is-this-chosto-) +- [Contents](#contents) +- [Requirements](#requirements) +- [Usage](#usage) + - [Bare repository trick](#bare-repository-trick) + - [Divergence betwteen laptop and desktop](#divergence-betwteen-laptop-and-desktop) + - [Configuration outside XDG_CONFIG_HOME, e.g. /etc](#configuration-outside-xdg_config_home-eg-etc) + + + +## What is this, Chosto ? + +I used a lot Debian/Ubuntu with Gnome. So a full Desktop Manager with a stacking Windows Manager. +A friend of mine showed me i3, a great and customizable tiling Windows Manager (i.e. no windows stack, just divide the scren and take all empty space). + +With some customization and additionnal component (in this repo), I managed to get a functional and pleasant yet lightweight environment (for me, no brag). + +So basically, what I like about this setup is that there is no "useless" menu bar anywhere and no border. Just windows with gaps between them when multiple windows are on the same screen, and keybord shortcuts for productivity. + +I added to the classic Arch/i3 : +* A notification daemon (urgency-aware), Dunst, controlled by shortcuts (but possibly with mouse). +* A fancy lock screen, with optionnal suspend-to-RAM, either triggered by hotkey or when there is no activity for X minutes. +* A Display Manager (LightDM), for login and X starting. +* A great File Explorer (SpaceFM), with hotkey / command-line / screen-split / protocol handlers / events support. +* ZSH with Oh My ZSH and excellent community plugins (Git aliases, Docker autocomplete, FASD bindings, cat and man coloration...) +* Some mappings to control ALSA volume from dedicated keyboards buttons, to play/plause players compatible with MPRIS D-Bus Interface spec ; some changes to key speed (X settings) ; Smooth and dark theme for GTK and for Sublime-Text... + +## Contents + Setup for : + * [i3](http://i3wm.org/), a great tiling windows manager - * In fact i3-gaps, to add padding between windows + * In fact i3-gaps, to add margins between windows * And i3-lock-color, an improved lock screen * [LightDM](https://wiki.ubuntu.com/LightDM) with custom GTKTheme and background * Sublime Text 3 @@ -21,9 +52,12 @@ switcher * Ardour, a DAW. * Random things (GTK3+ theme, Redshift, taskwarrior...) -### Requirements +Here is a screenshot of the rendition i3/polybar with this setup (and yeah, I use nano, sorry to disappoint) +![Screenshot of i3/polybar](https://pic.chosty.fr/uploads/big/22c75dc7901223204e0e9c798506b435.png) -Configuration makes use of these things, just to record but not mandatory : +## Requirements + +Configuration makes use of these things, just to record but not exhaustive : * [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) * [fasd](https://github.com/clvv/fasd) @@ -38,26 +72,13 @@ Configuration makes use of these things, just to record but not mandatory : * gnupg * maim, for screenshot -### What is this, Chosto ? +\#todo automatic installation of dependencies -I used a lot Debian/Ubuntu with Gnome. So a full Desktop Manager with a stacking Windows Manager. -A friend of mine showed me i3, a great and customizable tiling Windows Manager (i.e. no windows stack, just divide the scren and take all empty space). +## Usage -With some customization and additionnal component (in this repo), I managed to get a functional and pleasant yet lightweight environment (for me, no brag). +Please note : on my system `XDG_CONFIG_HOME` is empty and default to `$HOME/.config`. -So basically, what I like about this setup is that there is no "useless" menu bar anywhere and no border. Just windows with gaps between them when multiple windows are on the same screen, and keybord shortcuts for productivity. - -I added to the classic Arch/i3WM : -* A notification daemon (urgency-aware), Dunst, controlled by shortcuts (but possibly with mouse). -* A fancy lock screen, with optionnal suspend-to-RAM, either triggered by hotkey or when there is no activity for X minutes. -* A Display Manager (LightDM), for login and X starting. -* A great File Explorer (SpaceFM), with hotkey / command-line / screen-split / protocol handlers / events support. -* ZSH with Oh My ZSH and excellent community plugins (Git aliases, Docker autocomplete, FASD bindings, cat and man coloration...) -* Some mappings to control ALSA volume from dedicated keyboards buttons, to play/plause players compatible with MPRIS D-Bus Interface spec ; some changes to key speed (X settings) ; Smooth and dark theme for GTK and for Sublime-Text... - -### Usage - -Please note : on my system XDG_CONFIG_HOME is $HOME/.config. +### Bare repository trick * Clone in bare repository : `git clone --bare https://github.com/Chostakovitch/dotfiles.git $HOME/.cfg`. A bare repository does not have a working tree (basically it is just `.git` content). So we avoid conflicts with another git repository. * Create a working tree outside `.cfg` : `git --git-dir=$HOME/.cfg/ --work-tree=$HOME checkout`. @@ -66,6 +87,20 @@ Please note : on my system XDG_CONFIG_HOME is $HOME/.config. * Source `~/.zshrc` and use provided `config` alias to pull. * `config config --local status.showUntrackedFiles no` to ignore untracked files in status (better as it is home dir). -Also, as desktop machine and laptop don't have configuration conflicts (e.g. laptop uses PulseAudio and desktop uses ALSA/Jack), some files have `.desk` extension and others `.laptop`. Launch `~/.init_config.sh` to create symlinks (e.g. `~/.config/i3/config` will be symlinked to `~/.config/i3/config.laptop` if I launch `~/.init_config.sh laptop`). - Credits to [this great article](https://developer.atlassian.com/blog/2016/02/best-way-to-store-dotfiles-git-bare-repo/) for the trick. + +### Divergence betwteen laptop and desktop + +As desktop machine and laptop don't have configuration conflicts (e.g. laptop uses PulseAudio and desktop uses ALSA/Jack), some files have `.desk` extension and others `.laptop`. Configuration files that works on both systems have no extension. + +Launch `~/.init_config.sh` to create symlinks (e.g. `~/.config/i3/config` will be symlinked to `~/.config/i3/config.laptop` if I launch `~/.init_config.sh laptop`). + +### Configuration outside XDG_CONFIG_HOME, e.g. /etc + +Some configuration files reside in `/etc` directory, but I want to keep track of them. + +Just create a folder in `XDG_CONFIG_HOME` and a file named `dest`. In this file, write the destination path. Then, copy the configuration files that you want to track and add them to the repository. You can also use `.desk` and `.laptop` extensions for specific configuration. + +The `~/.init_config.sh` script will copy relevant files (laptop or desktop) in the directory specified by `dest` file. + +Note this is a quick and quite dirty solution. \ No newline at end of file