Exemplo n.º 1
0
def main():
    parser = argparse.ArgumentParser(description='Control desktop wallpaper.')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument(
        '--copy-root-window',
        dest='copy_root',
        action='store_true',
        help='Set the background to the contents of the root window.')
    group.add_argument('--image',
                       dest='image',
                       type=str,
                       help='Image to set the brackground to.')
    parser.add_argument(
        '--fade-secs',
        dest='fade_secs',
        type=int,
        default=0,
        help='Number of seconds to fade from current background to new')
    parser.add_argument('--fade-fps',
                        dest='fade_fps',
                        type=int,
                        default=20,
                        help='Number of FPS to aim for during the fade')

    args = parser.parse_args()

    if args.copy_root:
        wrapper = ConnectionWrapper(xcffib.Connection())
        wrapper.set_background_to_root_window_contents()
    elif args.image:
        fade_background_to_image(args.image, args.fade_secs, args.fade_fps)
Exemplo n.º 2
0
    def __init__(self, **kwargs):
        super().__init__(*kwargs)
        self._instances = {}
        self._atom = {}
        self._shm = []

        self.logger = logging.getLogger(__name__ + "." + self.__class__.__name__)
        self.connection = xcffib.Connection()
        self.screen = self.connection.get_screen_pointers()[self.connection.pref_screen]
        self.xcomposite = self.connection(xcffib.composite.key)
        self.xshm = self.connection(xcffib.shm.key)
        self.xinput = self.connection(xcffib.xinput.key)
        self._setup_composite()
        self._setup_overlay()

        self.event_thread = QThread(self)

        self.event_worker = X11EventWorker(self)
        self.event_worker.moveToThread(self.event_thread)
        self.event_thread.started.connect(self.event_worker.run)
        self.event_thread.finished.connect(self.event_worker.deleteLater)
        self.event_worker.create_signal.connect(self.on_game_opened)
        self.event_worker.destroy_signal.connect(self.on_game_closed)

        self.event_thread.start()

        self.get_instances()
Exemplo n.º 3
0
def fade_background_to_image(path, secs, fps):
    # Assume the painting takes 0 seconds for this calculation. In reality
    # this is a crappy assumption, but we're just fading in a wallpaper so
    # who cares.
    steps = max(1, fps * secs)
    step = 1 / steps
    sleep = secs / steps

    image = load_image(path)
    wrapper = ConnectionWrapper(xcffib.Connection())
    pixmap = wrapper.get_current_background()
    surface = wrapper.create_surface_for_pixmap(pixmap)

    with cairocffi.Context(surface) as context:
        context.set_source_surface(image)
        opacity = 0
        for i in range(steps):
            context.paint_with_alpha(i * step)
            wrapper.set_background(pixmap)
            time.sleep(sleep)
Exemplo n.º 4
0
    def __init__(self, **kwargs):
        super().__init__(*kwargs)
        self._instances = {}
        self._atom = {}
        self._shm = []

        self.connection = xcffib.Connection()
        self.screen = self.connection.get_screen_pointers()[self.connection.pref_screen]
        self.xcomposite = self.connection(xcffib.composite.key)
        self.xshm = self.connection(xcffib.shm.key)
        self.xinput = self.connection(xcffib.xinput.key)
        self._setup_composite()
        self._setup_overlay()

        self.event_thread = QThread(self)

        self.event_worker = X11EventWorker(self)
        self.event_worker.moveToThread(self.event_thread)
        self.event_thread.started.connect(self.event_worker.run)
        self.event_thread.finished.connect(self.event_worker.deleteLater)

        self.event_thread.start()
Exemplo n.º 5
0
_ = L10n.get_translation()

#    Standard Library modules
import re
import logging

from PyQt5.QtGui import QWindow

#    Other Library modules
import xcffib, xcffib.xproto

#    FPDB modules
from TableWindow import Table_Window
import Configuration

xconn = xcffib.Connection()
root = xconn.get_setup().roots[xconn.pref_screen].root


def getAtom(name):
    return xconn.core.InternAtom(False, len(name), name).reply().atom


nclatom = getAtom("_NET_CLIENT_LIST")
winatom = getAtom("WINDOW")
wnameatom = getAtom("_NET_WM_NAME")
utf8atom = getAtom("UTF8_STRING")

c = Configuration.Config()
log = logging.getLogger("hud")
Exemplo n.º 6
0
 def test_invalid(self):
     conn = xcffib.Connection('notadisplay')
     conn.invalid()
Exemplo n.º 7
0
 def test_invalid_display(self):
     self.conn = xcffib.Connection('notvalid')
     self.conn.invalid()