this post was submitted on 18 Nov 2023
2 points (100.0% liked)

Nix

3 readers
1 users here now

founded 1 year ago
MODERATORS
 

Hi all,

Trying to get a systemd timer script working that would turn off the scree at a set time each day.

This is the script that I am using in default.nix

   systemd.timers.screenoff = {
 	timerConfig = { 
 		Unit = "screenoff.service";
 		OnCalendar = "*-*-* 14:35:00";
 	};
 	wantedBy = ["default.target"]; 
 };
 
 systemd.user.services.screenoff = {
 	script = ''
 	${pkgs.bash}/bin/bash /home/"user"/screen_off.sh
 	'';
	wantedBy = ["default.target"];
	};

The script contains this bit of bash

#!/usr/bin/env

busctl --user set-property org.gnome.Mutter.DisplayConfig /org/gnome/Mutter/DisplayConfig org.gnome.Mutter.DisplayConfig PowerSaveMode i 3

I have tired a few various formats but in this current version I see the time and service listed in systemctl list-timers --all, but typing systemctl enable screenoff.service leads to error stating that service doesn't exist.

โ€‹

Any help would be greatly appreciated! Thank you!

you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] 1 points 10 months ago

Maybe this in configuration.nix:

#sleep when press power button
services.logind.extraConfig = ''
HandlePowerKey = suspend
IdleAction = suspend
IdleActionSec =1m
'';
#screen locker
programs.xss-lock.enable = true;