Refactor theme system, add 'hey theme' & reload handlers
Themes can now be swapped with 'hey theme NAME', or reloaded with the reloadTheme script.
This commit is contained in:
parent
c50a51f987
commit
14e2aada30
1
bin/hey
1
bin/hey
|
@ -130,6 +130,7 @@ function main {
|
||||||
ch|check) _do nix flake check "$@" "$DOTFILES";;
|
ch|check) _do nix flake check "$@" "$DOTFILES";;
|
||||||
sh|show) _do nix flake show "$@" "$DOTFILES" ;;
|
sh|show) _do nix flake show "$@" "$DOTFILES" ;;
|
||||||
|
|
||||||
|
theme) THEME="$1" _rebuild --fast test ;;
|
||||||
t|test) _rebuild --fast test "$@" ;;
|
t|test) _rebuild --fast test "$@" ;;
|
||||||
re|rebuild) _rebuild "${@:-switch}" ;;
|
re|rebuild) _rebuild "${@:-switch}" ;;
|
||||||
rollback) _rebuild --rollback switch ;;
|
rollback) _rebuild --rollback switch ;;
|
||||||
|
|
|
@ -120,6 +120,5 @@ bind -T copy-mode-vi L send-keys -X end-of-line
|
||||||
set -g @open-editor 'C-e'
|
set -g @open-editor 'C-e'
|
||||||
set -g @open-S 'https://www.duckduckgo.com/'
|
set -g @open-S 'https://www.duckduckgo.com/'
|
||||||
|
|
||||||
source $TMUX_HOME/plugins
|
source $TMUX_HOME/extraInit
|
||||||
if '[ -f $TMUX_HOME/theme ]' 'source $TMUX_HOME/theme'
|
|
||||||
if '[ -f ~/.tmux.conf ]' 'source ~/.tmux.conf'
|
if '[ -f ~/.tmux.conf ]' 'source ~/.tmux.conf'
|
||||||
|
|
|
@ -15,7 +15,7 @@ with lib.my;
|
||||||
# services.gitea.enable = true;
|
# services.gitea.enable = true;
|
||||||
# services.syncthing.enable = true;
|
# services.syncthing.enable = true;
|
||||||
|
|
||||||
themes.fluorescence.enable = true;
|
theme.active = "alucard";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
# Needed occasionally to help the parental units with PC problems
|
# Needed occasionally to help the parental units with PC problems
|
||||||
# teamviewer.enable = true;
|
# teamviewer.enable = true;
|
||||||
};
|
};
|
||||||
themes.fluorescence.enable = true;
|
theme.active = "alucard";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@
|
||||||
# syncthing.enable = true;
|
# syncthing.enable = true;
|
||||||
ssh.enable = true;
|
ssh.enable = true;
|
||||||
};
|
};
|
||||||
themes.fluorescence.enable = true;
|
theme.active = "alucard";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ rec {
|
||||||
modulesDir = "${dotFilesDir}/modules";
|
modulesDir = "${dotFilesDir}/modules";
|
||||||
configDir = "${dotFilesDir}/config";
|
configDir = "${dotFilesDir}/config";
|
||||||
binDir = "${dotFilesDir}/bin";
|
binDir = "${dotFilesDir}/bin";
|
||||||
themeDir = "${modulesDir}/themes";
|
themesDir = "${modulesDir}/themes";
|
||||||
homeDir = "/home/${let name = getEnv "USERNAME"; in
|
homeDir = "/home/${let name = getEnv "USERNAME"; in
|
||||||
if elem name [ "" "root" ]
|
if elem name [ "" "root" ]
|
||||||
then "hlissner" else name}";
|
then "hlissner" else name}";
|
||||||
|
|
|
@ -28,7 +28,7 @@ in {
|
||||||
# themename=${my.theme.name}
|
# themename=${my.theme.name}
|
||||||
# shift
|
# shift
|
||||||
# exec rofi \
|
# exec rofi \
|
||||||
# -theme ${themeDir}/$themename/rofi/$themefile \
|
# -theme ${themesDir}/$themename/rofi/$themefile \
|
||||||
# "$@"
|
# "$@"
|
||||||
# '')
|
# '')
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
modules.theme.onReload.bspwm = "${pkgs.bspwm}/bin/bspc wm -r";
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
lightdm
|
lightdm
|
||||||
dunst
|
dunst
|
||||||
|
|
|
@ -115,22 +115,9 @@ in {
|
||||||
env.QT_QPA_PLATFORMTHEME = "gtk2";
|
env.QT_QPA_PLATFORMTHEME = "gtk2";
|
||||||
qt5 = { style = "gtk2"; platformTheme = "gtk2"; };
|
qt5 = { style = "gtk2"; platformTheme = "gtk2"; };
|
||||||
|
|
||||||
services.xserver.displayManager.sessionCommands =
|
services.xserver.displayManager.sessionCommands = ''
|
||||||
let cfg = config.services.xserver.desktopManager.wallpaper; in ''
|
# GTK2_RC_FILES must be available to the display manager.
|
||||||
# Also, read xresources files in ~/.config/xtheme/* and init scripts in
|
|
||||||
# ~/.config/xsessions/*, so I can centralize my theme config files.
|
|
||||||
export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc"
|
export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc"
|
||||||
source "$XDG_CONFIG_HOME"/xsession/*.sh
|
|
||||||
xrdb -merge "$XDG_CONFIG_HOME"/xtheme/*
|
|
||||||
|
|
||||||
# Set the wallpaper ourselves so we don't need .background-image and/or
|
|
||||||
# .fehbg polluting $HOME
|
|
||||||
if [ -e "$XDG_DATA_HOME/wallpaper" ]; then
|
|
||||||
${pkgs.feh}/bin/feh --bg-${cfg.mode} \
|
|
||||||
${optionalString cfg.combineScreens "--no-xinerama"} \
|
|
||||||
--no-fehbg \
|
|
||||||
$XDG_DATA_HOME/wallpaper
|
|
||||||
fi
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Clean up leftovers, as much as we can
|
# Clean up leftovers, as much as we can
|
||||||
|
|
|
@ -3,21 +3,23 @@
|
||||||
with lib;
|
with lib;
|
||||||
with lib.my;
|
with lib.my;
|
||||||
let cfg = config.modules.shell.tmux;
|
let cfg = config.modules.shell.tmux;
|
||||||
in {
|
|
||||||
options.modules.shell.tmux = {
|
|
||||||
enable = mkBoolOpt false;
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
|
||||||
user.packages = with pkgs; [
|
|
||||||
# Despite tmux/tmux#142, tmux will support XDG in 3.2. Sadly, only 3.0 is
|
# Despite tmux/tmux#142, tmux will support XDG in 3.2. Sadly, only 3.0 is
|
||||||
# available on nixpkgs, and 3.1b on master (tmux/tmux@15d7e56), so I
|
# available on nixpkgs, and 3.1b on master (tmux/tmux@15d7e56), so I
|
||||||
# implement it myself:
|
# implement it myself:
|
||||||
(writeScriptBin "tmux" ''
|
tmux = (pkgs.writeScriptBin "tmux" ''
|
||||||
#!${stdenv.shell}
|
#!${pkgs.stdenv.shell}
|
||||||
exec ${tmux}/bin/tmux -f "$TMUX_HOME/config" "$@"
|
exec ${pkgs.tmux}/bin/tmux -f "$TMUX_HOME/config" "$@"
|
||||||
'')
|
'');
|
||||||
];
|
in {
|
||||||
|
options.modules.shell.tmux = with types; {
|
||||||
|
enable = mkBoolOpt false;
|
||||||
|
rcFiles = mkOpt (listOf (either str path)) [];
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
user.packages = [ tmux ];
|
||||||
|
|
||||||
|
modules.theme.onReload.tmux = "${tmux}/bin/tmux source-file $TMUX_HOME/extraInit";
|
||||||
|
|
||||||
modules.shell.zsh = {
|
modules.shell.zsh = {
|
||||||
rcInit = "_cache tmuxifier init -";
|
rcInit = "_cache tmuxifier init -";
|
||||||
|
@ -26,10 +28,13 @@ in {
|
||||||
|
|
||||||
home.configFile = {
|
home.configFile = {
|
||||||
"tmux" = { source = "${configDir}/tmux"; recursive = true; };
|
"tmux" = { source = "${configDir}/tmux"; recursive = true; };
|
||||||
"tmux/plugins".text = ''
|
"tmux/extraInit".text = ''
|
||||||
|
# This file is auto-generated by nixos, don't edit by hand!
|
||||||
run-shell ${pkgs.tmuxPlugins.copycat}/share/tmux-plugins/copycat/copycat.tmux
|
run-shell ${pkgs.tmuxPlugins.copycat}/share/tmux-plugins/copycat/copycat.tmux
|
||||||
run-shell ${pkgs.tmuxPlugins.prefix-highlight}/share/tmux-plugins/prefix-highlight/prefix_highlight.tmux
|
run-shell ${pkgs.tmuxPlugins.prefix-highlight}/share/tmux-plugins/prefix-highlight/prefix_highlight.tmux
|
||||||
run-shell ${pkgs.tmuxPlugins.yank}/share/tmux-plugins/yank/yank.tmux
|
run-shell ${pkgs.tmuxPlugins.yank}/share/tmux-plugins/yank/yank.tmux
|
||||||
|
|
||||||
|
${concatMapStrings (path: "source '${path}'\n") cfg.rcFiles}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -74,23 +74,23 @@ in {
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Other dotfiles
|
# Other dotfiles
|
||||||
home.configFile = mkMerge [
|
home.configFile = with config.modules; mkMerge [
|
||||||
{
|
{
|
||||||
# Sourced from sessionCommands in modules/themes/default.nix
|
# Sourced from sessionCommands in modules/themes/default.nix
|
||||||
"xtheme/90-theme".source = ./config/Xresources;
|
"xtheme/90-theme".source = ./config/Xresources;
|
||||||
}
|
}
|
||||||
(mkIf m.desktop.bspwm.enable {
|
(mkIf desktop.bspwm.enable {
|
||||||
"bspwm/rc.d/polybar".source = ./config/polybar/run.sh;
|
"bspwm/rc.d/polybar".source = ./config/polybar/run.sh;
|
||||||
"bspwm/rc.d/theme".source = ./config/bspwmrc;
|
"bspwm/rc.d/theme".source = ./config/bspwmrc;
|
||||||
})
|
})
|
||||||
(mkIf m.desktop.apps.rofi.enable {
|
(mkIf desktop.apps.rofi.enable {
|
||||||
"rofi/theme" = { source = ./config/rofi; recursive = true; };
|
"rofi/theme" = { source = ./config/rofi; recursive = true; };
|
||||||
})
|
})
|
||||||
(mkIf (m.desktop.bspwm.enable || m.desktop.stumpwm.enable) {
|
(mkIf (desktop.bspwm.enable || desktop.stumpwm.enable) {
|
||||||
"polybar" = { source = ./config/polybar; recursive = true; };
|
"polybar" = { source = ./config/polybar; recursive = true; };
|
||||||
"dunst/dunstrc".source = ./config/dunstrc;
|
"dunst/dunstrc".source = ./config/dunstrc;
|
||||||
})
|
})
|
||||||
(mkIf m.desktop.media.graphics.vector.enable {
|
(mkIf desktop.media.graphics.vector.enable {
|
||||||
"inkscape/templates/default.svg".source = ./config/inkscape/default-template.svg;
|
"inkscape/templates/default.svg".source = ./config/inkscape/default-template.svg;
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
|
@ -39,7 +39,7 @@ in {
|
||||||
config = mkIf (cfg.active != null) (mkMerge [
|
config = mkIf (cfg.active != null) (mkMerge [
|
||||||
# Read xresources files in ~/.config/xtheme/* to allow modular
|
# Read xresources files in ~/.config/xtheme/* to allow modular
|
||||||
# configuration of Xresources.
|
# configuration of Xresources.
|
||||||
(let xrdb = ''xrdb -merge "$XDG_CONFIG_HOME"/xtheme/*'';
|
(let xrdb = ''${pkgs.xorg.xrdb}/bin/xrdb -merge "$XDG_CONFIG_HOME"/xtheme/*'';
|
||||||
in {
|
in {
|
||||||
services.xserver.displayManager.sessionCommands = xrdb;
|
services.xserver.displayManager.sessionCommands = xrdb;
|
||||||
modules.theme.onReload.xtheme = xrdb;
|
modules.theme.onReload.xtheme = xrdb;
|
||||||
|
@ -104,21 +104,22 @@ in {
|
||||||
services.xserver.displayManager.lightdm.background = cfg.loginWallpaper;
|
services.xserver.displayManager.lightdm.background = cfg.loginWallpaper;
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf (cfg.onReload != {}) {
|
(mkIf (cfg.onReload != {})
|
||||||
user.packages = [
|
(let reloadTheme =
|
||||||
(pkgs.writeScriptBin "reloadTheme" ''
|
with pkgs; (writeScriptBin "reloadTheme" ''
|
||||||
#!${stdenv.shell}
|
#!${stdenv.shell}
|
||||||
echo "Reloading current theme: ${cfg.active}"
|
echo "Reloading current theme: ${cfg.active}"
|
||||||
${concatStrings "\n"
|
${concatStringsSep "\n"
|
||||||
(mapAttrsToList (name: script: ''
|
(mapAttrsToList (name: script: ''
|
||||||
echo "[${name}]"
|
echo "[${name}]"
|
||||||
${script}
|
${script}
|
||||||
'') cfg.onReload)}
|
'') cfg.onReload)}
|
||||||
'')
|
'');
|
||||||
];
|
in {
|
||||||
|
user.packages = [ reloadTheme ];
|
||||||
system.userActivationScripts.reloadTheme = ''
|
system.userActivationScripts.reloadTheme = ''
|
||||||
[ -z "$NORELOAD" ] && reloadTheme
|
[ -z "$NORELOAD" ] && ${reloadTheme}/bin/reloadTheme
|
||||||
'';
|
'';
|
||||||
})
|
}))
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue