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!

  • cfx_4188B
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year 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;