diff options
author | Alexander Shabalin <shabalyn.a@gmail.com> | 2015-12-22 01:18:35 +0300 |
---|---|---|
committer | Rok Garbas <rok@garbas.si> | 2015-12-22 02:04:06 +0100 |
commit | a0138e1ed559281c80e728183ebb7c56a0afc54e (patch) | |
tree | 31341b1b70584a15470d2627ad633f1590a89e23 /pkgs/tools/misc/dynamic-colors | |
parent | 842613fb1045a5c31dd32fa80d061d70c0bf52f5 (diff) |
dynamic-colors: init at 2013-12-28, fixes #11874
Diffstat (limited to 'pkgs/tools/misc/dynamic-colors')
-rw-r--r-- | pkgs/tools/misc/dynamic-colors/default.nix | 37 | ||||
-rw-r--r-- | pkgs/tools/misc/dynamic-colors/separate-config-and-dynamic-root-path.patch | 58 |
2 files changed, 95 insertions, 0 deletions
diff --git a/pkgs/tools/misc/dynamic-colors/default.nix b/pkgs/tools/misc/dynamic-colors/default.nix new file mode 100644 index 0000000000000..b587afb645c22 --- /dev/null +++ b/pkgs/tools/misc/dynamic-colors/default.nix @@ -0,0 +1,37 @@ +{ stdenv, fetchFromGitHub, makeWrapper, tmux, vim }: + +stdenv.mkDerivation rec { + name = "dynamic-colors-git-${version}"; + version = "2013-12-28"; + + src = fetchFromGitHub { + owner = "sos4nt"; + repo = "dynamic-colors"; + rev = "35325f43620c5ee11a56db776b8f828bc5ae1ddd"; + sha256 = "1xsjanqyvjlcj1fb8x4qafskxp7aa9b43ba9gyjgzr7yz8hkl4iz"; + }; + + buildInputs = [ makeWrapper ]; + + patches = [ ./separate-config-and-dynamic-root-path.patch ]; + + installPhase = '' + mkdir -p $out/bin $out/etc/bash_completion.d $out/share/dynamic-colors + cp bin/dynamic-colors $out/bin/ + cp completions/dynamic-colors.bash $out/etc/bash_completion.d/ + cp -r colorschemes $out/share/dynamic-colors/ + + sed -e 's|\<tmux\>|${tmux}/bin/tmux|g' \ + -e 's|/usr/bin/vim|${vim}/bin/vim|g' \ + -i "$out/bin/dynamic-colors" + + wrapProgram $out/bin/dynamic-colors --set DYNAMIC_COLORS_ROOT "$out/share/dynamic-colors" + ''; + + meta = { + homepage = https://github.com/sos4nt/dynamic-colors; + license = stdenv.lib.licenses.mit; + description = "Change terminal colors on the fly"; + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/pkgs/tools/misc/dynamic-colors/separate-config-and-dynamic-root-path.patch b/pkgs/tools/misc/dynamic-colors/separate-config-and-dynamic-root-path.patch new file mode 100644 index 0000000000000..7462ed0e3afad --- /dev/null +++ b/pkgs/tools/misc/dynamic-colors/separate-config-and-dynamic-root-path.patch @@ -0,0 +1,58 @@ +From ee44b859003972275d8e469ab41b9900420295e0 Mon Sep 17 00:00:00 2001 +From: Malte Rohde <malte.rohde@flavoursys.com> +Date: Fri, 9 Jan 2015 13:10:41 +0100 +Subject: [PATCH] Store user configuration in appropriate config location. + +So that the dynamic-colors source can live somewhere else +(e.g., /usr/local/dynamic-colors) and multiple users +can use the same script. +--- + bin/dynamic-colors | 21 ++++++++++++++++----- + 1 file changed, 16 insertions(+), 5 deletions(-) + +diff --git a/bin/dynamic-colors b/bin/dynamic-colors +index a669221..5d6bce7 100755 +--- a/bin/dynamic-colors ++++ b/bin/dynamic-colors +@@ -84,16 +84,27 @@ else + fi + COLORSCHEMES="${DYNAMIC_COLORS_ROOT}/colorschemes" + ++if [ -z "${DYNAMIC_COLORS_HOME}" ]; then ++ if [ -d "${HOME}/.dynamic-colors" ] || [ -z "${XDG_CONFIG_HOME}" ]; then ++ DYNAMIC_COLORS_HOME="${HOME}/.dynamic-colors" ++ else ++ DYNAMIC_COLORS_HOME="${XDG_CONFIG_HOME}/dynamic-colors" ++ fi ++else ++ DYNAMIC_COLORS_HOME="${DYNAMIC_COLORS_HOME%/}" ++fi ++ + write_colorscheme_name () { +- echo "$1" > "${DYNAMIC_COLORS_ROOT}/colorscheme" ++ [ ! -d "${DYNAMIC_COLORS_HOME}" ] && mkdir -p "${DYNAMIC_COLORS_HOME}" ++ echo "$1" > "${DYNAMIC_COLORS_HOME}/colorscheme" + } + + load_colorscheme_name () { +- head -1 "${DYNAMIC_COLORS_ROOT}/colorscheme" ++ head -1 "${DYNAMIC_COLORS_HOME}/colorscheme" + } + + init () { +- [ ! -f "${DYNAMIC_COLORS_ROOT}/colorscheme" ] && return ++ [ ! -f "${DYNAMIC_COLORS_HOME}/colorscheme" ] && return + colorscheme_name=$(load_colorscheme_name) + load_colorscheme "$colorscheme_name" + set_colors +@@ -142,8 +153,8 @@ audit () { + } + + cycle() { +- if [ -f "${DYNAMIC_COLORS_ROOT}/colorscheme" ]; then +- current=`head -1 "${DYNAMIC_COLORS_ROOT}/colorscheme"` ++ if [ -f "${DYNAMIC_COLORS_HOME}/colorscheme" ]; then ++ current=$(load_colorscheme_name) + found=false + cd "$COLORSCHEMES" + for file in *.sh; do |