I’m working on setting up systemd/timers using home-manager, but I’m facing a command not found
error. It seems like the packages installed by home-manager aren’t available in my system’s $PATH
. Is there a way to include these packages explicitly? I’ve tried using things like ${pkgs.bash}
, ${pkgs.gawk}
, ${pkgs.acpi}
in my setup. But I’m unsure about which package I need for the tr
command in my bash script. Here’s the content of my battery_status.sh
script for reference:
#!/run/current-system/sw/bin/bash
2 │
3 │ # define global variables
4 │ # BATTINFO store full battery info
5 │ BATTINFO=$(acpi -b | grep Battery\ 0)
6 │
7 │ # to store percentage
8 │ percentage=$(echo "$BATTINFO" | awk '{print $4}' | tr -d '%,')
9 │
10 │ # for Command Substitution backticks(`) are depricated instead use this syntax $()
11 │ # if battery is discharging and is between 48% and 30%
12 │ if [[ $(echo $BATTINFO | grep Discharging) && "$percentage" -lt 45 && "$percentage" -gt 15 ]] ; then
13 │
14 │ # to refrence a variable use this syntax $varibale_name
15 │ dunstify "low battery" "$BATTINFO"
16 │
17 │ # if battery is discharging and is less than 30%
18 │ elif [[ $(echo $BATTINFO | grep Discharging) && "$percentage" -lt 15 ]]; then
19 │
20 │ # set the emergency level to critical
21 │ dunstify -u critical "low battery" "$BATTINFO"
22 │ fi
And my battery_status.timer
and battery_status.service
in Home-Manager (home.nix
):
# This timer runs every 5 minutes to run bash script battery_status.sh
101 │ systemd.user.services = {
102 │ battery_status = {
103 │ Unit = {
104 │ Description = "low battery notification service";
105 │ };
106 │ Service = {
107 │ Type = "oneshot";
108 │ ExecStart = toString (
109 │ pkgs.writeShellScript "battery-status-script" ''
110 │ set -eou pipefail
111 │
112 │ ${pkgs.bash}/bin/bash "/home/sukhman/Documents/sway_related/battery_status.sh";
113 │ ''
114 │ );
115 │ };
116 │ Install.WantedBy = [ "default.target" ];
117 │ };
118 │ };
119 │
120 │ systemd.user.timers = {
121 │ battery_status = {
122 │ Unit.Description = "timer for battery_status service";
123 │ Timer = {
124 │ Unit = "battery_status";
125 │ OnBootSec = "1m";
126 │ OnUnitActiveSec = "1m";
127 │ };
128 │ Install.WantedBy = [ "timers.target" ];
129 │ };
130 │ };
Error: i am getting command not found
for acpi
, awk
, and tr
. Thank you.