feat: dark mode sync module
This commit is contained in:
parent
b21b2be135
commit
a2c5d32b97
7 changed files with 102 additions and 27 deletions
56
home/apps/colorscheme-sync.nix
Normal file
56
home/apps/colorscheme-sync.nix
Normal file
|
@ -0,0 +1,56 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
# TODO: de-duplicate across modules
|
||||
lat = 48.210033;
|
||||
lng = 16.363449;
|
||||
in {
|
||||
home.packages = [
|
||||
(pkgs.writeShellApplication {
|
||||
name = "dark-mode-ternary";
|
||||
runtimeInputs = [pkgs.gnugrep];
|
||||
text = let
|
||||
queryCommand =
|
||||
if pkgs.stdenv.isLinux
|
||||
then "dbus-send --session --print-reply=literal --dest=org.freedesktop.portal.Desktop /org/freedesktop/portal/desktop org.freedesktop.portal.Settings.Read string:'org.freedesktop.appearance' string:'color-scheme' | grep -q 'uint32 1'"
|
||||
else if pkgs.stdenv.isDarwin
|
||||
then "defaults read -g AppleInterfaceStyle &>/dev/null"
|
||||
else throw "Unsupported platform";
|
||||
in ''
|
||||
[[ -z "''${1-}" ]] && [[ -z "''${2-}" ]] && echo "Usage: $0 <dark> <light>" && exit 1
|
||||
|
||||
if ${queryCommand}; then
|
||||
echo "$1"
|
||||
else
|
||||
echo "$2"
|
||||
fi
|
||||
'';
|
||||
})
|
||||
];
|
||||
|
||||
services.darkman = {
|
||||
enable = true;
|
||||
config = {
|
||||
inherit lat lng;
|
||||
useGeoclue = false;
|
||||
};
|
||||
activationScript = let
|
||||
starship = lib.getExe config.programs.starship.package;
|
||||
zsh = lib.getExe config.programs.zsh.package;
|
||||
in {
|
||||
dark = ''
|
||||
${starship} config palette catppuccin_mocha
|
||||
${zsh} -ic "fast-theme XDG:catppuccin-mocha"
|
||||
'';
|
||||
light = ''
|
||||
${starship} config palette catppuccin_latte
|
||||
${zsh} -ic "fast-theme XDG:catppuccin-latte"
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
programs.zsh.shellAliases.cat = "bat --theme=$(dark-mode-ternary 'Catppuccin-mocha' 'Catppuccin-latte')";
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
imports = [
|
||||
./browsers.nix
|
||||
./colorscheme-sync.nix
|
||||
./discord.nix
|
||||
./fonts.nix
|
||||
./git.nix
|
||||
|
|
|
@ -37,13 +37,6 @@ in {
|
|||
|
||||
services = lib.mkIf isLinux {
|
||||
clipman.enable = true;
|
||||
darkman = {
|
||||
enable = true;
|
||||
config = {
|
||||
inherit lat lng;
|
||||
useGeoclue = false;
|
||||
};
|
||||
};
|
||||
gnome-keyring = {
|
||||
enable = true;
|
||||
components = ["secrets"];
|
||||
|
|
|
@ -31,6 +31,21 @@ local openUrl = act.QuickSelectArgs({
|
|||
end),
|
||||
})
|
||||
|
||||
local changeCtpFlavor = act.InputSelector({
|
||||
title = "Change Catppuccin flavor",
|
||||
choices = {
|
||||
{ label = "Mocha" },
|
||||
{ label = "Macchiato" },
|
||||
{ label = "Frappe" },
|
||||
{ label = "Latte" },
|
||||
},
|
||||
action = wezterm.action_callback(function(window, _, _, label)
|
||||
if label then
|
||||
window:set_config_overrides({ color_scheme = "Catppuccin " .. label })
|
||||
end
|
||||
end),
|
||||
})
|
||||
|
||||
-- use 'Backslash' to split horizontally
|
||||
map("\\", "LEADER", act.SplitHorizontal({ domain = "CurrentPaneDomain" }))
|
||||
-- and 'Minus' to split vertically
|
||||
|
@ -53,6 +68,7 @@ map("l", "LEADER|SHIFT", act.AdjustPaneSize({ "Right", 5 }))
|
|||
-- spawn & close
|
||||
map("c", "LEADER", act.SpawnTab("CurrentPaneDomain"))
|
||||
map("x", "LEADER", act.CloseCurrentPane({ confirm = true }))
|
||||
map("t", "LEADER", changeCtpFlavor)
|
||||
map("t", { "SHIFT|CTRL", "SUPER" }, act.SpawnTab("CurrentPaneDomain"))
|
||||
map("w", { "SHIFT|CTRL", "SUPER" }, act.CloseCurrentTab({ confirm = true }))
|
||||
map("n", { "SHIFT|CTRL", "SUPER" }, act.SpawnWindow)
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
---@type wezterm
|
||||
local wezterm = require("wezterm")
|
||||
local utils = require("utils")
|
||||
|
||||
local c = {}
|
||||
if wezterm.config_builder then
|
||||
c = wezterm.config_builder()
|
||||
c:set_strict_mode(true)
|
||||
end
|
||||
local c = wezterm.config_builder()
|
||||
|
||||
require("keys").apply(c)
|
||||
|
||||
|
@ -32,13 +26,12 @@ c.launch_menu = {
|
|||
}
|
||||
c.command_palette_font_size = 13.0
|
||||
c.window_frame = { font_size = 13.0 }
|
||||
c.window_background_opacity = 0.9
|
||||
c.window_background_opacity = 0.95
|
||||
|
||||
wezterm.plugin
|
||||
.require("https://github.com/catppuccin/wezterm")
|
||||
.apply_to_config(c, {
|
||||
flavor = "mocha",
|
||||
sync = utils.is_darwin(),
|
||||
sync = true,
|
||||
sync_flavors = { light = "latte", dark = "mocha" },
|
||||
})
|
||||
wezterm.plugin
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (pkgs.stdenv.hostPlatform) isDarwin;
|
||||
symlink = fileName: {recursive ? false}: {
|
||||
source = config.lib.file.mkOutOfStoreSymlink "${flakePath}/${fileName}";
|
||||
recursive = recursive;
|
||||
|
@ -26,7 +25,20 @@ in {
|
|||
sync_frequency = "5m";
|
||||
};
|
||||
};
|
||||
bat.enable = true;
|
||||
bat = let
|
||||
themes = pkgs.fetchFromGitHub {
|
||||
owner = "catppuccin";
|
||||
repo = "bat";
|
||||
rev = "ba4d16880d63e656acced2b7d4e034e4a93f74b1";
|
||||
sha256 = "sha256-6WVKQErGdaqb++oaXnY3i6/GuH2FhTgK0v4TN4Y0Wbw=";
|
||||
};
|
||||
in {
|
||||
enable = true;
|
||||
themes = {
|
||||
"Catppuccin-latte" = builtins.readFile (themes + /Catppuccin-latte.tmTheme);
|
||||
"Catppuccin-mocha" = builtins.readFile (themes + /Catppuccin-mocha.tmTheme);
|
||||
};
|
||||
};
|
||||
btop = {
|
||||
enable = true;
|
||||
settings = {
|
||||
|
@ -120,15 +132,18 @@ in {
|
|||
file = "share/zsh-nix-shell/nix-shell.plugin.zsh";
|
||||
}
|
||||
{
|
||||
src = zsh-fast-syntax-highlighting;
|
||||
src = zsh-fast-syntax-highlighting.overrideAttrs (old: {
|
||||
src = fetchFromGitHub {
|
||||
owner = "zdharma-continuum";
|
||||
repo = "fast-syntax-highlighting";
|
||||
rev = "cf318e06a9b7c9f2219d78f41b46fa6e06011fd9";
|
||||
hash = "sha256-RVX9ZSzjBW3LpFs2W86lKI6vtcvDWP6EPxzeTcRZua4=";
|
||||
};
|
||||
});
|
||||
file = "share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh";
|
||||
}
|
||||
]);
|
||||
shellAliases = {
|
||||
cat =
|
||||
if isDarwin
|
||||
then "bat --theme=\$(defaults read -globalDomain AppleInterfaceStyle &> /dev/null && echo Catppuccin-mocha || echo Catppuccin-latte)"
|
||||
else "bat";
|
||||
cp = "cp -i";
|
||||
mv = "mv -i";
|
||||
rm = "rm -i";
|
||||
|
|
|
@ -40,11 +40,12 @@
|
|||
gtk = true;
|
||||
};
|
||||
};
|
||||
# needed for gnome3 pinentry
|
||||
services.dbus.packages = [pkgs.gcr];
|
||||
|
||||
# gcr needed for gnome3 pinentry
|
||||
services.dbus.packages = with pkgs; [darkman gcr];
|
||||
xdg.portal.enable = true;
|
||||
xdg.portal.wlr.enable = true;
|
||||
xdg.portal.extraPortals = [pkgs.xdg-desktop-portal-gtk];
|
||||
xdg.portal.extraPortals = with pkgs; [darkman xdg-desktop-portal-gtk];
|
||||
|
||||
services = {
|
||||
# mounting
|
||||
|
|
Loading…
Reference in a new issue