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";;
|
||||
sh|show) _do nix flake show "$@" "$DOTFILES" ;;
|
||||
|
||||
theme) THEME="$1" _rebuild --fast test ;;
|
||||
t|test) _rebuild --fast test "$@" ;;
|
||||
re|rebuild) _rebuild "${@:-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-S 'https://www.duckduckgo.com/'
|
||||
|
||||
source $TMUX_HOME/plugins
|
||||
if '[ -f $TMUX_HOME/theme ]' 'source $TMUX_HOME/theme'
|
||||
source $TMUX_HOME/extraInit
|
||||
if '[ -f ~/.tmux.conf ]' 'source ~/.tmux.conf'
|
||||
|
|
|
@ -15,7 +15,7 @@ with lib.my;
|
|||
# services.gitea.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
|
||||
# teamviewer.enable = true;
|
||||
};
|
||||
themes.fluorescence.enable = true;
|
||||
theme.active = "alucard";
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
# syncthing.enable = true;
|
||||
ssh.enable = true;
|
||||
};
|
||||
themes.fluorescence.enable = true;
|
||||
theme.active = "alucard";
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ rec {
|
|||
modulesDir = "${dotFilesDir}/modules";
|
||||
configDir = "${dotFilesDir}/config";
|
||||
binDir = "${dotFilesDir}/bin";
|
||||
themeDir = "${modulesDir}/themes";
|
||||
themesDir = "${modulesDir}/themes";
|
||||
homeDir = "/home/${let name = getEnv "USERNAME"; in
|
||||
if elem name [ "" "root" ]
|
||||
then "hlissner" else name}";
|
||||
|
|
|
@ -28,7 +28,7 @@ in {
|
|||
# themename=${my.theme.name}
|
||||
# shift
|
||||
# exec rofi \
|
||||
# -theme ${themeDir}/$themename/rofi/$themefile \
|
||||
# -theme ${themesDir}/$themename/rofi/$themefile \
|
||||
# "$@"
|
||||
# '')
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ in {
|
|||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
modules.theme.onReload.bspwm = "${pkgs.bspwm}/bin/bspc wm -r";
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
lightdm
|
||||
dunst
|
||||
|
|
|
@ -115,23 +115,10 @@ in {
|
|||
env.QT_QPA_PLATFORMTHEME = "gtk2";
|
||||
qt5 = { style = "gtk2"; platformTheme = "gtk2"; };
|
||||
|
||||
services.xserver.displayManager.sessionCommands =
|
||||
let cfg = config.services.xserver.desktopManager.wallpaper; in ''
|
||||
# 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"
|
||||
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
|
||||
'';
|
||||
services.xserver.displayManager.sessionCommands = ''
|
||||
# GTK2_RC_FILES must be available to the display manager.
|
||||
export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc"
|
||||
'';
|
||||
|
||||
# Clean up leftovers, as much as we can
|
||||
system.userActivationScripts.cleanupHome = ''
|
||||
|
|
|
@ -3,21 +3,23 @@
|
|||
with lib;
|
||||
with lib.my;
|
||||
let cfg = config.modules.shell.tmux;
|
||||
# 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
|
||||
# implement it myself:
|
||||
tmux = (pkgs.writeScriptBin "tmux" ''
|
||||
#!${pkgs.stdenv.shell}
|
||||
exec ${pkgs.tmux}/bin/tmux -f "$TMUX_HOME/config" "$@"
|
||||
'');
|
||||
in {
|
||||
options.modules.shell.tmux = {
|
||||
options.modules.shell.tmux = with types; {
|
||||
enable = mkBoolOpt false;
|
||||
rcFiles = mkOpt (listOf (either str path)) [];
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
user.packages = with pkgs; [
|
||||
# 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
|
||||
# implement it myself:
|
||||
(writeScriptBin "tmux" ''
|
||||
#!${stdenv.shell}
|
||||
exec ${tmux}/bin/tmux -f "$TMUX_HOME/config" "$@"
|
||||
'')
|
||||
];
|
||||
user.packages = [ tmux ];
|
||||
|
||||
modules.theme.onReload.tmux = "${tmux}/bin/tmux source-file $TMUX_HOME/extraInit";
|
||||
|
||||
modules.shell.zsh = {
|
||||
rcInit = "_cache tmuxifier init -";
|
||||
|
@ -26,10 +28,13 @@ in {
|
|||
|
||||
home.configFile = {
|
||||
"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.prefix-highlight}/share/tmux-plugins/prefix-highlight/prefix_highlight.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
|
||||
home.configFile = mkMerge [
|
||||
home.configFile = with config.modules; mkMerge [
|
||||
{
|
||||
# Sourced from sessionCommands in modules/themes/default.nix
|
||||
"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/theme".source = ./config/bspwmrc;
|
||||
})
|
||||
(mkIf m.desktop.apps.rofi.enable {
|
||||
(mkIf desktop.apps.rofi.enable {
|
||||
"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; };
|
||||
"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;
|
||||
})
|
||||
];
|
||||
|
|
|
@ -39,7 +39,7 @@ in {
|
|||
config = mkIf (cfg.active != null) (mkMerge [
|
||||
# Read xresources files in ~/.config/xtheme/* to allow modular
|
||||
# configuration of Xresources.
|
||||
(let xrdb = ''xrdb -merge "$XDG_CONFIG_HOME"/xtheme/*'';
|
||||
(let xrdb = ''${pkgs.xorg.xrdb}/bin/xrdb -merge "$XDG_CONFIG_HOME"/xtheme/*'';
|
||||
in {
|
||||
services.xserver.displayManager.sessionCommands = xrdb;
|
||||
modules.theme.onReload.xtheme = xrdb;
|
||||
|
@ -104,21 +104,22 @@ in {
|
|||
services.xserver.displayManager.lightdm.background = cfg.loginWallpaper;
|
||||
})
|
||||
|
||||
(mkIf (cfg.onReload != {}) {
|
||||
user.packages = [
|
||||
(pkgs.writeScriptBin "reloadTheme" ''
|
||||
#!${stdenv.shell}
|
||||
echo "Reloading current theme: ${cfg.active}"
|
||||
${concatStrings "\n"
|
||||
(mapAttrsToList (name: script: ''
|
||||
echo "[${name}]"
|
||||
${script}
|
||||
'') cfg.onReload)}
|
||||
'')
|
||||
];
|
||||
system.userActivationScripts.reloadTheme = ''
|
||||
[ -z "$NORELOAD" ] && reloadTheme
|
||||
'';
|
||||
})
|
||||
(mkIf (cfg.onReload != {})
|
||||
(let reloadTheme =
|
||||
with pkgs; (writeScriptBin "reloadTheme" ''
|
||||
#!${stdenv.shell}
|
||||
echo "Reloading current theme: ${cfg.active}"
|
||||
${concatStringsSep "\n"
|
||||
(mapAttrsToList (name: script: ''
|
||||
echo "[${name}]"
|
||||
${script}
|
||||
'') cfg.onReload)}
|
||||
'');
|
||||
in {
|
||||
user.packages = [ reloadTheme ];
|
||||
system.userActivationScripts.reloadTheme = ''
|
||||
[ -z "$NORELOAD" ] && ${reloadTheme}/bin/reloadTheme
|
||||
'';
|
||||
}))
|
||||
]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue