Advertisement
Guest User

Untitled

a guest
Nov 21st, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. # From configuration.nix
  2. systemd.user.services.batteryMonitor = {
  3. path = [ pkgs.bash pkgs.acpi pkgs.libnotify ];
  4. wantedBy = [ "multi-user.target" ];
  5. description = "Notifies when battery is low and suspends";
  6. serviceConfig = {
  7. Type = "simple";
  8. ExecStart = "${pkgs.bash}/bin/bash %h/.wm-scripts/battery-monitor.sh";
  9. };
  10. };
  11.  
  12. systemd.user.timers.batteryMonitor = {
  13. timerConfig = {
  14. OnUnitInactiveSec = "2s";
  15. AccuracySec = "1s";
  16. };
  17. wantedBy = [ "timers.target" ];
  18. };
  19.  
  20.  
  21. λ systemctl --user cat batteryMonitor
  22. # /nix/store/bbakz8q4wcyhbh43n86f5z07i8jlsadv-unit-batteryMonitor.service/batteryMonitor.service
  23. [Unit]
  24. Description=Notifies when battery is low and suspends
  25.  
  26. [Service]
  27. Environment="LOCALE_ARCHIVE=/nix/store/1xpr86xg998h5acn4zqrx58xjdjqnnds-glibc-locales-2.31/lib/locale/local>
  28. Environment="PATH=/nix/store/2jysm3dfsgby5sw5jgj43qjrb5v79ms9-bash-4.4-p23/bin:/nix/store/891p25c0g3acijh6g>
  29. Environment="TZDIR=/nix/store/xg8nmhp28a5xf6ifgg8n93nrwbp8ghvm-tzdata-2019c/share/zoneinfo"
  30.  
  31. ExecStart=/nix/store/2jysm3dfsgby5sw5jgj43qjrb5v79ms9-bash-4.4-p23/bin/bash %h/.wm-scripts/battery-monitor.>
  32. Type=simple
  33.  
  34. λ systemctl --user enable batteryMonitor
  35. The unit files have no installation config (WantedBy=, RequiredBy=, Also=,
  36. Alias= settings in the [Install] section, and DefaultInstance= for template
  37. units). This means they are not meant to be enabled using systemctl.
  38.  
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement