Skip to content

Commit

Permalink
setup (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitriysafronov authored Dec 14, 2023
1 parent ccd06dc commit bd70de5
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 8 deletions.

This file was deleted.

1 change: 0 additions & 1 deletion etc/systemd/system/power-source-ac.target

This file was deleted.

1 change: 0 additions & 1 deletion etc/systemd/system/power-source-battery.target

This file was deleted.

1 change: 0 additions & 1 deletion etc/systemd/system/power-sources-monitor.service

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion etc/systemd/user/power-source-ac.target

This file was deleted.

1 change: 0 additions & 1 deletion etc/systemd/user/power-source-battery.target

This file was deleted.

1 change: 0 additions & 1 deletion etc/systemd/user/power-sources-monitor.service

This file was deleted.

54 changes: 54 additions & 0 deletions usr/local/share/power-sources-monitor/setup
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"

0 comments on commit bd70de5

Please sign in to comment.