70 lines
2.7 KiB
HTML
70 lines
2.7 KiB
HTML
|
|
|
|
<!DOCTYPE html>
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<style>
|
|
pre {
|
|
white-space: pre-wrap;
|
|
}
|
|
</style>
|
|
</head>
|
|
<h1>DeaDvey's domain</h1>
|
|
<pre>
|
|
<a href="/">Home</a> <a href="/blog/">Blogs</a> <a href="/projects/">Projects</a>
|
|
<hr/>
|
|
<b>Home Manager automatically changing dark/light mode at sunrise/set:</b>
|
|
Firstly, to do this you need pkgs.sunwait (though other options would work with a bit of changing). Make a script like this, I put mine in my home.file, but you can also just make it a file on it's own.<br/><div class="indent code">'scripts/mode-switcher-based-on-sunlight.sh' = {
|
|
text = ''
|
|
run_a_command() {
|
|
if [[ "$light" == "DAY" ]]; then
|
|
sed -i 's/MODE\ =\ ".*"/MODE\ =\ "light"/' $HOME/.config/home/home.nix
|
|
home-manager switch
|
|
else
|
|
sed -i 's/MODE\ =\ ".*"/MODE\ =\ "dark"/' $HOME/.config/home/home.nix
|
|
home-manager switch
|
|
fi
|
|
};
|
|
#!/bin/bash
|
|
# Set your latitude and longitude
|
|
LATITUDE="53.43N"
|
|
LONGITUDE="-1.89E"
|
|
|
|
# Calculate the sunrise and sunset times for today using sunwait
|
|
light=$(sunwait poll $LATITUDE $LONGITUDE)
|
|
|
|
run_a_command
|
|
while sleep 5; do
|
|
new_light=$(sunwait poll $LATITUDE $LONGITUDE)
|
|
if [[ "$new_light" != "$light" ]]; then
|
|
run_a_command
|
|
fi
|
|
done
|
|
'';
|
|
executable = true;
|
|
};</div><br/>
|
|
|
|
I have this to autorun on startup in Hyprland with <div class="code">exec-once="$HOME/scripts/mode-switcher-based-on-sunlight.sh";</div> then in the home.nix, I of course have a variable defined called MODE as either "dark" or "light"<br/>
|
|
<div class="indent code">
|
|
{config, pkgs, lib, ...}:
|
|
let
|
|
MODE = "light";
|
|
in
|
|
{
|
|
# Home config
|
|
}
|
|
</div><br/>
|
|
And then that should be it, of course you'll want to make to make gtk follow this theme, I do that by having different theme files which each define a set of GTK themes and then those are assigned as variables on rebuild <div class="code"> inherit (import ./themes/\${THEME}_\${MODE}.nix) GTK_THEME GTK_THEME_NAME;</div><br/>You can see my full nix configurations <a href="https://git.javalsai.dynv6.net/deadvey/nixos">here</a><br/>Fly You High - DeaDvey
|
|
|
|
<i>Published: 15b/7e8 at c730</i>
|
|
<a href='/blog/75.html'><-- Conclave (2024) - 4/5</a> <a href='/blog/77.html'>Waybar theme switcher for home manager--></a>
|
|
|
|
<a href="/blog/nixos.html">nixos</a><br/><a href="/blog/home manager.html">home manager</a><br/><a href="/blog/customisation.html">customisation</a><br/><a href="/blog/guide.html">guide</a><br/><a href="/blog/dark mode.html">dark mode</a><br/><a href="/blog/light mode.html">light mode</a><br/><a href="/blog/sunrise.html">sunrise</a><br/><a href="/blog/sunset.html">sunset</a><br/>
|
|
|
|
</pre>
|
|
<style>
|
|
pre {
|
|
white-space: pre-wrap;
|
|
}
|
|
</style>
|