Created
February 17, 2020 02:39
-
-
Save ephur/9a681cdbec997e9f8f09e6254c601513 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# pylint: disable=invalid-name | |
import os | |
import sys | |
import ConfigParser | |
import Xlib.display | |
import subprocess | |
CONFIG_FILE = os.environ['HOME'] + '/.config/openbox/ob-wp-switcher.ini' | |
TOOL = ["/usr/bin/nitrogen", "--set-scaled"] | |
if __name__ == '__main__': | |
display = Xlib.display.Display() | |
screen = display.screen() | |
names = screen.root.get_full_property(display.get_atom( | |
'_NET_DESKTOP_NAMES'), 0).value.strip('\x00').split('\x00') | |
current = screen.root.get_full_property( | |
display.get_atom('_NET_CURRENT_DESKTOP'), 0).value[0] | |
config = ConfigParser.RawConfigParser() | |
if CONFIG_FILE not in config.read(CONFIG_FILE): | |
print "could not load config" | |
sys.exit(1) | |
wallpaper = config.get("main", "base_dir").rstrip("/") | |
wallpaper += "/" + config.get("wallpapers", names[current]) | |
TOOL.append(wallpaper) | |
subprocess.check_call(TOOL) |
This file contains 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
[main] | |
base_dir = /home/ephur/Pictures/Background/1440span/ | |
[wallpapers] | |
Left = 1.jpg | |
Main = 2.jpg | |
Right = 3.jpg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment