Skip to content

Instantly share code, notes, and snippets.

@sulph68
Last active September 7, 2025 11:45
Show Gist options
  • Select an option

  • Save sulph68/1ddb883ada9218e05347c78dfcda3490 to your computer and use it in GitHub Desktop.

Select an option

Save sulph68/1ddb883ada9218e05347c78dfcda3490 to your computer and use it in GitHub Desktop.
uConsole Auto changing battery wallpaper

uConsole Auto rotating battery wallpaper

To automatically change wallpaper on battery level, read the battery level from /sysclass and change the wallpaper setting using gsettings.

my $batt_file = "/sys/class/power_supply/axp20x-battery/capacity";

[...some code...]
chomp(my $current = `gsettings get org.gnome.desktop.background picture-uri`);
$current =~ s/^'file:\/\/\///;
$current =~ s/'$//;

[...some code...]
gsettings set org.gnome.desktop.background picture-uri "${IMG_URI}"
gsettings set org.gnome.desktop.background picture-uri-dark "${IMG_URI}"

Note: In my setup, i have a script battery_wallpaper that calls set_wallpaper.sh when there is need to change the wallpaper depending on the battery level read once every 15 minutes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment