Last active
May 7, 2021 07:45
-
-
Save inercia/992362757c1f32ada38976de1b5c5431 to your computer and use it in GitHub Desktop.
Enable/disable discrete graphs card on battery/AC
This file contains hidden or 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
# /etc/udev/rules.d/99-powertargets.rules | |
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_NAME}=="AC", ENV{POWER_SUPPLY_ONLINE}=="0", RUN+="/bin/systemctl start battery.target" | |
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_NAME}=="AC", ENV{POWER_SUPPLY_ONLINE}=="1", RUN+="/bin/systemctl start ac.target" | |
# SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_NAME}=="AC", ENV{POWER_SUPPLY_ONLINE}=="0", RUN+="/usr/bin/logger 'on battery'" | |
# SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_NAME}=="AC", ENV{POWER_SUPPLY_ONLINE}=="1", RUN+="/usr/bin/logger 'on AC'" | |
# run: | |
# sudo udevadm control --reload-rules |
This file contains hidden or 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
# /etc/systemd/system/ac.target | |
[Unit] | |
Description=On AC power | |
DefaultDependencies=no | |
StopWhenUnneeded=yes | |
# run: | |
# sudo mkdir /etc/systemd/system/ac.target.wants | |
# sudo systemctl daemon-reload |
This file contains hidden or 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
# /etc/systemd/system/battery.target | |
[Unit] | |
Description=On battery power | |
DefaultDependencies=no | |
StopWhenUnneeded=yes | |
# run: | |
# sudo mkdir /etc/systemd/system/battery.target.wants | |
# sudo systemctl daemon-reload |
This file contains hidden or 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
# /etc/systemd/system/prime-intel.service | |
[Unit] | |
Description=Intel graphics card | |
[Service] | |
Type=oneshot | |
ExecStart=/usr/bin/prime-select intel | |
# run: | |
# cd /etc/systemd/system/battery.target.wants && sudo ln -s ../prime-intel.service | |
# sudo systemctl daemon-reload |
This file contains hidden or 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
# /etc/systemd/system/prime-intel.service | |
[Unit] | |
Description=NVIDIA graphics card | |
[Service] | |
Type=oneshot | |
ExecStart=/usr/bin/prime-select intel | |
# run: | |
# cd /etc/systemd/system/ac.target.wants && sudo ln -s ../prime-nvidia.service | |
# sudo systemctl daemon-reload |
This file contains hidden or 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
# /etc/systemd/system/resilio-disable.service | |
[Unit] | |
Description=Stop resilio | |
[Service] | |
Type=oneshot | |
ExecStart=/bin/su alvaro -c "/bin/systemctl stop --user resilio-sync.service" | |
# run: | |
# cd /etc/systemd/system/battery.target.wants && sudo ln -s ../resilio-disable.service | |
# sudo systemctl daemon-reload |
This file contains hidden or 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
# /etc/systemd/system/resilio-enable.service | |
[Unit] | |
Description=Start resilio | |
[Service] | |
Type=oneshot | |
ExecStart=/bin/su alvaro -c "/bin/systemctl start --user resilio-sync.service" | |
# run: | |
# cd /etc/systemd/system/ac.target.wants && sudo ln -s ../resilio-enable.service | |
# sudo systemctl daemon-reload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment