46 lines
9.1 KiB
HTML
Executable File
46 lines
9.1 KiB
HTML
Executable File
<meta name="fediverse:creator" content="@DeaDvey@mastodon.social">
|
|
<!DOCTYPE html>
|
|
<head>
|
|
<meta charset="UTF-8"/>
|
|
<title>DeaDveys Domain</title>
|
|
<link rel="icon" href="/images/favicon.png">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
</head>
|
|
<div id="header"><head>
|
|
<style>
|
|
@media (prefers-color-scheme: dark) {
|
|
body {
|
|
background-color: black;
|
|
color: white;
|
|
}
|
|
a:visited {
|
|
color: violet;
|
|
}
|
|
}
|
|
</style>WELCOME TO DEADVEY'S DOMAIN!!!<br/>
|
|
<a href="/" onclick="history.back()"><img src="/images/return.png" width="20" />Return</a> / <a href="/">Home page</a> / <a href="/blogs/index.html">Blogs</a> <a href="/blogs/feed.xml"><img width="16" src="/images/feedIcon.png" class="feedicon" alt="Feed image"/></a> / <a href="/board/index.html">Boards</a><hr/></div><!--header-->
|
|
<div id="main">
|
|
<body>
|
|
<div id="main">
|
|
<h3 class="blog-date">c730 15b/7e8</h3>
|
|
<h1 class="blog-title">Home Manager automatically changing dark/light mode at sunrise/set</h1>
|
|
<p class="blog-content">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' = {<br> text = ''<br> run_a_command() {<br> if [[ "$light" == "DAY" ]]; then<br> sed -i 's/MODE = ".*"/MODE = "light"/' $HOME/.config/home/home.nix<br> home-manager switch<br> else<br> sed -i 's/MODE = ".*"/MODE = "dark"/' $HOME/.config/home/home.nix<br> home-manager switch<br> fi<br> };<br> #!/bin/bash<br> # Set your latitude and longitude<br> LATITUDE="53.43N"<br> LONGITUDE="-1.89E"<br><br> # Calculate the sunrise and sunset times for today using sunwait<br> light=$(sunwait poll $LATITUDE $LONGITUDE)<br><br> run_a_command<br> while sleep 5; do<br> new_light=$(sunwait poll $LATITUDE $LONGITUDE)<br> if [[ "$new_light" != "$light" ]]; then<br> run_a_command<br> fi<br> done<br> '';<br> executable = true;<br> };</div><br/><br><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/><br><div class="indent code"><br> {config, pkgs, lib, ...}:<br> let <br> MODE = "light";<br> in<br> {<br> # Home config<br> }<br></div><br/><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</p>
|
|
<div class="blog-images">
|
|
|
|
</div><br/>
|
|
<sub><i><small>nixos,home manager,customisation,guide,dark mode,light mode,sunrise,sunset</small></i></sub><hr/>
|
|
<h3>Comments section:</h3><br/>
|
|
<form action="/blog/submit-comment" id="commentForm" method="post">
|
|
<input name="name" class="form-control" id="name" placeholder="Enter your name"><br/>
|
|
<textarea height="40px" name="comment" class="form-control input-comment" id="comment" placeholder="Enter your Comment..."></textarea>
|
|
<input type="hidden" name="pageID" value="76">
|
|
<button type="submit">Submit</button>
|
|
</form>
|
|
|
|
<div class="76" id="comments"></div></div><p class="previous"><a href="75.html"><-- Previous</a></p><p class="next"><a href="77.html">Next --></a></p>
|
|
<div id="links">
|
|
</div><script src="/blogs/comments.js"></script><script src="/blogs/displayComments.js"></script></body>
|
|
</div>
|
|
<div id="footer"><hr/><ul> Internal pages: <li><a href="/experiments" >Experiments <img height="30" src="/images/experience-green-liquid.gif" /></a></li> <li><a href="/isthistheyearofthelinuxdesktop" >Is this the year of the Linux Desktop? <img src="/images/penguin-dance-pengu.gif" height="20" alt="penguin dancing" /></a></li> <li><a href="/theunderland" >theunderland wiki <img src="/images/flashlight.gif" alt="torch scanning" height="30" class="rotate" /></a></li><li><a href="/maths">Maths Quiz</a> </li> <li><a href="http://deadvey.com:3000">Invidious <img src="/images/invidious.png" height="15"/></a></li> <li><a href="http://deadvey.com:8096">Jellyfin <img src="/images/jellyfin.png" height="15"/></a></li><a href="http://deadvey.com:7993">Monkeytype</a> <img src="/images/monkeytype.png" height="15"></li><li><a href="/search">Search blogs</a></li><br/><br/>External sites: <li><a href="https://git.javalsai.dynv6.net/deadvey" >Gitea</a></li><li><a href="https://javalsai.dynv6.net">Javlsai</a></li><li><a rel="me" href="https://mastodon.social/@DeaDvey">Mastodon</a></li> </ul><br/> <small width="300px">© DeaDvey 2023 - 2024<br/>This work is licensed under the terms of the <a href="/LICENSE">GNU General Public License, version 3.0</a>. You are free to copy, distribute, and modify this work under the terms of the <a href="/LICENSE">GPL 3.0 License</a>. Please see the full license text for details.</small></div><!--footer-->
|
|
</body>
|
|
</html> |