1
0
Fork 0

Improve wallpaper logic

This commit is contained in:
Malte Brandy 2021-07-06 13:04:16 +02:00
parent 5560f21fa2
commit 1025f6466c
No known key found for this signature in database
GPG key ID: 226A2D41EF5378C9
3 changed files with 14 additions and 14 deletions

View file

@ -48,15 +48,15 @@ let
in
{
dconf.settings."org/gnome/settings-daemon/plugins/media-keys" = {
mic-mute = lib.mkForce [ ];
next = lib.mkForce [ ];
play = lib.mkForce [ ];
previous = lib.mkForce [ ];
screensaver = lib.mkForce [ ];
volume-down = lib.mkForce [ ];
volume-up = lib.mkForce [ ];
};
#dconf.settings."org/gnome/settings-daemon/plugins/media-keys" = {
#mic-mute = lib.mkForce [ ];
#next = lib.mkForce [ ];
#play = lib.mkForce [ ];
#previous = lib.mkForce [ ];
#screensaver = lib.mkForce [ ];
#volume-down = lib.mkForce [ ];
#volume-up = lib.mkForce [ ];
#};
home.packages = builtins.attrValues {
#factorio = pkgs.factorio.override {

View file

@ -15,7 +15,6 @@ let
".task"
".vdirsyncer"
".vimhist"
".wallpapers"
"Maildir"
"git"
"media"

View file

@ -1,5 +1,6 @@
{ modeFile }: { pkgs, ... }:
{ modeFile }: { pkgs, config, ... }:
let
wallPapers = "${config.home.homeDirectory}/media/images/wallpapers";
randomWallpaper = pkgs.writeHaskellScript
{
name = "random-wallpaper";
@ -8,10 +9,10 @@ let
} ''
main = do
mode <- cat "${modeFile}" |> captureTrim
(lines . decodeUtf8 -> files) <- ls ([i|/home/maralorn/.wallpapers/#{mode}|] :: String) |> captureTrim
(lines . decodeUtf8 -> files) <- ls ([i|${wallPapers}/#{mode}|] :: String) |> captureTrim
((files Unsafe.!!) -> file) <- getStdRandom $ randomR (0, length files - 1)
(decodeUtf8 -> current) <- gsettings "get" "org.gnome.desktop.background" "picture-uri" |> captureTrim
let new = [i|file:///home/maralorn/.wallpapers/#{mode}/#{file}|] :: String
let new = [i|file:///${wallPapers}/#{mode}/#{file}|] :: String
when (new /= current) $ do
gsettings "set" "org.gnome.desktop.background" "picture-uri" new
gsettings "set" "org.gnome.desktop.screensaver" "picture-uri" new
@ -28,7 +29,7 @@ in
};
};
timers.random-wallpaper = {
Timer = { OnCalendar = "*:00/30:00"; };
Timer = { OnCalendar = "*:00/30:00"; OnActiveSec = 10; };
Install = { WantedBy = [ "timers.target" ]; };
};
};