Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Plug Switch

Plug in AC power and switch profile automatically.

Quick Start

cargo build --release
cp systemd/plug-switch.service ~/.config/systemd/user/plug-switch.service
cp target/release/plug-switch ~/.local/bin/plug-switch
systemctl --user enable plug-switch
systemctl --user start plug-switch

How it works

It gets power events from UPower and changes power profile via power-profiles-daemon D-Bus.

Motivation

While searching for a tool, I found a GNOME extension, but I couldn't install it due to versioning issues. Since extensions are prone to breaking with GNOME upgrades, I wanted a more robust tool. This led to the systemd service approach, GNOME may provide graphical UI for the tool's settings, but it can work without GNOME.

Another reason is the implementation detail. Other projects check if the battery is actively charging. However, a laptop might be plugged in but not charging if the battery is full or has reached a set threshold. This tool, instead, reacts purely to the AC power connection status, regardless of whether the battery is charging.

Dev Notes

# whether ac is connected
zbus-xmlgen system org.freedesktop.UPower /org/freedesktop/UPower/devices/line_power_ACAD
# switch power profile
zbus-xmlgen system org.freedesktop.UPower.PowerProfiles /org/freedesktop/UPower/PowerProfiles

# whether battery is charging, not needed
zbus-xmlgen system org.freedesktop.UPower /org/freedesktop/UPower/devices/DisplayDevice
# legacy power profile service name
zbus-xmlgen system net.hadess.PowerProfiles /net/hadess/PowerProfiles

Links

related projects

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages