Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save computercam/eb79ea7853d13e1027be3d6ed542903d to your computer and use it in GitHub Desktop.

Select an option

Save computercam/eb79ea7853d13e1027be3d6ed542903d to your computer and use it in GitHub Desktop.

Revisions

  1. @krishraghuram krishraghuram revised this gist Oct 10, 2018. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions change_desktop_background.py
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,6 @@
    import subprocess
    import re

    proc = subprocess.run(['acpi','-i'], stdout=subprocess.PIPE)
    acpi_info = proc.stdout.decode('utf-8')

    command = ['qdbus', 'org.kde.plasmashell', '/PlasmaShell', 'org.kde.PlasmaShell.evaluateScript']
    command.append("""
    var allDesktops = desktops();
    @@ -16,6 +13,9 @@
    }
    """)

    proc = subprocess.run(['acpi','-i'], stdout=subprocess.PIPE)
    acpi_info = proc.stdout.decode('utf-8')

    if re.search('Discharging',acpi_info):
    command[-1] = command[-1] % '/home/raghuram/Pictures/discharging.png'
    elif re.search('Charging',acpi_info) or re.search('Full',acpi_info):
  2. @krishraghuram krishraghuram revised this gist Jul 3, 2018. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions change_desktop_background.py
    Original file line number Diff line number Diff line change
    @@ -17,10 +17,10 @@
    """)

    if re.search('Discharging',acpi_info):
    command[-1] = command[-1] % '/home/raghuram/Workspace/change_desktop_background/images/discharging.png'
    command[-1] = command[-1] % '/home/raghuram/Pictures/discharging.png'
    elif re.search('Charging',acpi_info) or re.search('Full',acpi_info):
    command[-1] = command[-1] % '/home/raghuram/Workspace/change_desktop_background/images/charging.png'
    command[-1] = command[-1] % '/home/raghuram/Pictures/charging.png'
    else:
    command[-1] = command[-1] % '/home/raghuram/Workspace/change_desktop_background/images/shrug.png'
    command[-1] = command[-1] % '/home/raghuram/Pictures/shrug.png'

    subprocess.run(command)
  3. @krishraghuram krishraghuram created this gist Jul 3, 2018.
    26 changes: 26 additions & 0 deletions change_desktop_background.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    import subprocess
    import re

    proc = subprocess.run(['acpi','-i'], stdout=subprocess.PIPE)
    acpi_info = proc.stdout.decode('utf-8')

    command = ['qdbus', 'org.kde.plasmashell', '/PlasmaShell', 'org.kde.PlasmaShell.evaluateScript']
    command.append("""
    var allDesktops = desktops();
    for (i=0;i<allDesktops.length;i++)
    {
    d = allDesktops[i];
    d.wallpaperPlugin = "org.kde.image";
    d.currentConfigGroup = Array("Wallpaper", "org.kde.image", "General");
    d.writeConfig("Image", "file://%s");
    }
    """)

    if re.search('Discharging',acpi_info):
    command[-1] = command[-1] % '/home/raghuram/Workspace/change_desktop_background/images/discharging.png'
    elif re.search('Charging',acpi_info) or re.search('Full',acpi_info):
    command[-1] = command[-1] % '/home/raghuram/Workspace/change_desktop_background/images/charging.png'
    else:
    command[-1] = command[-1] % '/home/raghuram/Workspace/change_desktop_background/images/shrug.png'

    subprocess.run(command)