Manage configuration outside ~/.config

master
Quentin Duchemin 2019-02-24 21:20:30 +01:00
parent e738fc7b13
commit 72760d3ec6
Signed by: Chosto
GPG Key ID: 0547178FEEDE7D6B
4 changed files with 87 additions and 29 deletions

View File

@ -1 +0,0 @@
Theses files belong to /etc/lightdm.

View File

@ -0,0 +1 @@
/etc/lightdm

View File

@ -2,13 +2,18 @@
LAPTOP="laptop" LAPTOP="laptop"
DESKTOP="desk" DESKTOP="desk"
DEST_FILENAME="dest"
function usage() { 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}]" echo "usage: $0 [${LAPTOP}|${DESKTOP}]"
exit 0 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 if [ -z "{$1}" ] || [ "$#" -ne 1 ]; then
usage usage
fi fi
@ -17,12 +22,30 @@ if [ "${1}" != "${LAPTOP}" ] && [ "${1}" != "${DESKTOP}" ]; then
usage usage
fi fi
for f in `find ~/.config -type f -name "*.${1}"`; do echo "=== Create symlink to *.${1} regular files ==="
echo "Symlinking to ${f}..." # 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%.*} ln -sf ${f} ${f%.*}
done done
for f in `find ~ -maxdepth 1 -mindepth 1 -type f -name "*.${1}"`; do # Take care of config files at home level, outside ${CONFIG} (e.g. Xresources)
echo "Symlinking to ${f}..." for f in `find ${HOME} -maxdepth 1 -mindepth 1 -type f -name "*.${1}"`; do
echo "Create symlink to ${f}..."
ln -sf ${f} ${f%.*} ln -sf ${f} ${f%.*}
done 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

View File

@ -1,9 +1,40 @@
# dotfiles # dotfiles
### Contents <!-- MarkdownTOC autolink="true" -->
- [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)
<!-- /MarkdownTOC -->
## 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 : Setup for :
* [i3](http://i3wm.org/), a great tiling windows manager * [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 * And i3-lock-color, an improved lock screen
* [LightDM](https://wiki.ubuntu.com/LightDM) with custom GTKTheme and background * [LightDM](https://wiki.ubuntu.com/LightDM) with custom GTKTheme and background
* Sublime Text 3 * Sublime Text 3
@ -21,9 +52,12 @@ switcher
* Ardour, a DAW. * Ardour, a DAW.
* Random things (GTK3+ theme, Redshift, taskwarrior...) * 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) * [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh)
* [fasd](https://github.com/clvv/fasd) * [fasd](https://github.com/clvv/fasd)
@ -38,26 +72,13 @@ Configuration makes use of these things, just to record but not mandatory :
* gnupg * gnupg
* maim, for screenshot * 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. ## Usage
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). 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. ### Bare repository trick
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.
* 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. * 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`. * 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. * 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). * `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. 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.