-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ccd06dc
commit bd70de5
Showing
9 changed files
with
54 additions
and
8 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
etc/systemd/system/default.target.wants/power-sources-monitor.service
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
etc/systemd/user/default.target.wants/power-sources-monitor.service
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env bash | ||
|
||
FROM=/usr/local/share/power-sources-monitor/systemd | ||
TO=/etc/systemd | ||
|
||
link_unit() { | ||
if [[ -z "$1" ]]; then | ||
echo "Specify {system|user} units kind" | ||
exit 1 | ||
fi | ||
if [[ -z "$2" ]]; then | ||
echo "Specify units list" | ||
exit 1 | ||
fi | ||
for UNITFILE in $2; do | ||
ln -svf "${FROM}/${UNITFILE}" "${TO}/$1/${UNITFILE}" | ||
done | ||
} | ||
|
||
install_unit_system() { | ||
if [[ -z "$1" ]]; then | ||
echo "Specify units list" | ||
exit 1 | ||
fi | ||
for UNITFILE in $1; do | ||
systemctl enable "${UNITFILE}" | ||
done | ||
} | ||
|
||
install_unit_user() { | ||
if [[ -z "$1" ]]; then | ||
echo "Specify units list" | ||
exit 1 | ||
fi | ||
for UNITFILE in $1; do | ||
systemctl enable --global "${UNITFILE}" | ||
done | ||
} | ||
|
||
link_unit system "\ | ||
power-source-ac.target \ | ||
power-source-battery.target \ | ||
power-sources-monitor.service" | ||
|
||
link_unit user "\ | ||
power-source-ac.target \ | ||
power-source-battery.target \ | ||
power-sources-monitor.service" | ||
|
||
systemctl daemon-reload | ||
|
||
install_unit_system "power-sources-monitor.service" | ||
|
||
install_unit_user "power-sources-monitor.service" |