add: theme-switcher

This commit is contained in:
Keisuke Hirata 2025-02-16 14:41:48 +09:00
parent d40fbe7eed
commit a4ff711bc3
8 changed files with 124 additions and 11 deletions

64
flake.lock Normal file
View File

@ -0,0 +1,64 @@
{
"nodes": {
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1738448366,
"narHash": "sha256-4ATtQqBlgsGqkHTemta0ydY6f7JBRXz4Hf574NHQpkg=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "18fa9f323d8adbb0b7b8b98a8488db308210ed93",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nixos-hardware": {
"locked": {
"lastModified": 1738471961,
"narHash": "sha256-cgXDFrplNGs7bCVzXhRofjD8oJYqqXGcmUzXjHmip6Y=",
"owner": "NixOS",
"repo": "nixos-hardware",
"rev": "537286c3c59b40311e5418a180b38034661d2536",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixos-hardware",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1738410390,
"narHash": "sha256-xvTo0Aw0+veek7hvEVLzErmJyQkEcRk6PSR4zsRQFEc=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "3a228057f5b619feb3186e986dbe76278d707b6e",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"home-manager": "home-manager",
"nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

View File

@ -181,7 +181,6 @@
);
};
plugins = [
# pkgs.hyprlandPlugins.
];
};
home.sessionVariables = {

View File

@ -9,13 +9,21 @@
vscode
vivaldi
discord
discord-canary
helvum
obs-studio
superfile
plemoljp
plemoljp-nf
prismlauncher
scrcpy
tetrio-desktop
kicad
blender-hip
gimp
inkscape
obsidian
zed-editor
easyeffects
];
programs.git = {
enable = true;

View File

@ -24,12 +24,13 @@
deno
nodejs
pnpm
scrcpy
tetrio-desktop
# kicad
# blender-hip
gimp
inkscape
qemu
(pkgs.writeShellScriptBin "qemu-system-x86_64-uefi" ''
qemu-system-x86_64 \
-bios ${pkgs.OVMF.fd}/FV/OVMF.fd \
"$@"
'')
];
boot.loader.systemd-boot.enable = true;

View File

@ -38,7 +38,7 @@ let
extraSpecialArgs = {
inherit inputs hostname username;
};
modules = homeModule ++ [
modules = [
{
home = {
inherit username;
@ -47,7 +47,8 @@ let
};
programs.home-manager.enable = true;
}
];
(import ../system/home-manager)
] ++ homeModule;
};
};
in

View File

@ -4,7 +4,7 @@
zip
unzip
ripgrep
btop
btop-rocm
bat
wezterm

View File

@ -0,0 +1,11 @@
{
imports = [
./theme-switcher.nix
];
home.activation = {
makedir = ''
mkdir -p ~/.config/cornflake
'';
};
}

View File

@ -0,0 +1,29 @@
{ pkgs, ... }:
let
apply-theme-script = pkgs.writeScript "apply-theme" ''
curr=$(cat ~/.config/cornflake/current-theme)
if [ "$curr" = "prefer-light" ]; then
dconf write /org/gnome/desktop/interface/color-scheme "'prefer-light'"
else
dconf write /org/gnome/desktop/interface/color-scheme "'prefer-dark'"
fi
'';
desktopEntry = {
name = "Toggle theme";
exec = ''${pkgs.writeScript "theme" ''
curr=$(cat ~/.config/cornflake/current-theme)
if [ "$curr" = "prefer-light" ]; then
echo 'prefer-dark' > ~/.config/cornflake/current-theme
else
echo 'prefer-light' > ~/.config/cornflake/current-theme
fi
${apply-theme-script}
''}'';
};
in
{
xdg.desktopEntries = {
theme-switcher = desktopEntry;
};
}