Example #1
0
def list_windows():
    WM = WindowManager()
    windows = WM.windows(
        filters.AND(filters.ExcludeType(Type.DESKTOP, Type.SPLASH),
                    filters.ExcludeState(State.SKIP_PAGER,
                                         State.SKIP_TASKBAR)))
    for window in windows:
        state = window.state
        win_desktop = window.desktop
        desktop = [win_desktop, -1][State.STICKY in state or \
                                    win_desktop == Window.ALL_DESKTOPS]
        if State.HIDDEN in state and \
           not State.SHADED in state:
            state_flags = 'i'
        elif State.FULLSCREEN in state:
            state_flags = 'F'
        elif State.MAXIMIZED_HORZ in state and \
             State.MAXIMIZED_VERT in state:
            state_flags = 'M'
        elif State.MAXIMIZED_VERT in state:
            state_flags = 'V'
        elif State.MAXIMIZED_HORZ in state:
            state_flags = 'H'
        else:
            state_flags = ' '
        # TODO: State.ABOVE, State.BELOW
        state_flags += [' ', 's'][State.SHADED in state]  # and \
        #not State.HIDDEN in state]
        print '%s %s %s %s' % (window.id, desktop, state_flags, window.name)
Example #2
0
File: main.py Project: agwells/pywo
def list_windows():
    WM = WindowManager()
    windows = WM.windows(filters.AND(
                filters.ExcludeType(Type.DESKTOP, Type.SPLASH),
                filters.ExcludeState(State.SKIP_PAGER, State.SKIP_TASKBAR)))
    for window in windows:
        state = window.state
        win_desktop = window.desktop
        desktop = [win_desktop, -1][State.STICKY in state or \
                                    win_desktop == Window.ALL_DESKTOPS]
        if State.HIDDEN in state and \
           not State.SHADED in state:
            state_flags = 'i'
        elif State.FULLSCREEN in state:
            state_flags = 'F'
        elif State.MAXIMIZED_HORZ in state and \
             State.MAXIMIZED_VERT in state:
            state_flags = 'M'
        elif State.MAXIMIZED_VERT in state:
            state_flags = 'V'
        elif State.MAXIMIZED_HORZ in state:
            state_flags = 'H'
        else:
            state_flags = ' '
        # TODO: State.ABOVE, State.BELOW
        state_flags += [' ', 's'][State.SHADED in state]# and \
                                  #not State.HIDDEN in state]
        print '%s %s %s %s' % (window.id, desktop, state_flags, window.name)
Example #3
0
def _activate(win):
    """Activate window.
    
    Unshade, unminimize and switch to it's desktop/viewport.
    
    """
    WM = WindowManager()
    desktop = win.desktop
    if desktop != WM.desktop:
        WM.set_desktop(desktop)
    win.activate()
Example #4
0
def _activate(win):
    """Activate window.
    
    Unshade, unminimize and switch to it's desktop/viewport.
    
    """
    wm = WindowManager()
    desktop = win.desktop
    if desktop != wm.desktop:
        wm.set_desktop(desktop)
    win.activate()
Example #5
0
def run():
    """PyWO run function."""
    # parse commandline
    (options, args) = commandline.parse_args()

    # setup loggers
    setup_loggers(options.debug, options.logpath)

    # load config settings
    config = Config(options.config)

    if options.start_daemon:
        log.info('Starting PyWO daemon...')
        daemon.setup(config)
        daemon.start()
    elif options.list_windows:
        WM = WindowManager()
        windows = WM.windows(
            filters.AND(
                filters.ExcludeType(Type.DESKTOP, Type.SPLASH),
                filters.ExcludeState(State.SKIP_PAGER, State.SKIP_TASKBAR)))
        for window in windows:
            state = window.state
            win_desktop = window.desktop
            desktop = [win_desktop, -1][State.STICKY in state or \
                                        win_desktop == Window.ALL_DESKTOPS]
            if State.HIDDEN in state and \
               not State.SHADED in state:
                state_flags = 'i'
            elif State.FULLSCREEN in state:
                state_flags = 'F'
            elif State.MAXIMIZED_HORZ in state and \
                 State.MAXIMIZED_VERT in state:
                state_flags = 'M'
            elif State.MAXIMIZED_VERT in state:
                state_flags = 'V'
            elif State.MAXIMIZED_HORZ in state:
                state_flags = 'H'
            else:
                state_flags = ' '
            # TODO: State.ABOVE, State.BELOW
            state_flags += [' ', 's'][State.SHADED in state]  # and \
            #not State.HIDDEN in state]
            print '%s %s %s %s' % (window.id, desktop, state_flags,
                                   window.name)
    elif options.help_more:
        commandline.print_help_more(config)
    elif args or options.action:
        try:
            actions.perform(options, args, config)
        except actions.ActionException, exc:
            commandline.print_error(exc)
Example #6
0
def run():
    """PyWO run function."""
    # parse commandline
    (options, args) = commandline.parse_args()

    # setup loggers
    setup_loggers(options.debug, options.logpath)

    # load config settings
    config = Config(options.config)

    if options.start_daemon:
        log.info('Starting PyWO daemon...')
        daemon.setup(config)
        daemon.start()
    elif options.list_windows:
        WM = WindowManager()
        windows = WM.windows(filters.AND(
                    filters.ExcludeType(Type.DESKTOP, Type.SPLASH),
                    filters.ExcludeState(State.SKIP_PAGER, State.SKIP_TASKBAR)))
        for window in windows:
            state = window.state
            win_desktop = window.desktop
            desktop = [win_desktop, -1][State.STICKY in state or \
                                        win_desktop == Window.ALL_DESKTOPS]
            if State.HIDDEN in state and \
               not State.SHADED in state:
                state_flags = 'i'
            elif State.FULLSCREEN in state:
                state_flags = 'F'
            elif State.MAXIMIZED_HORZ in state and \
                 State.MAXIMIZED_VERT in state:
                state_flags = 'M'
            elif State.MAXIMIZED_VERT in state:
                state_flags = 'V'
            elif State.MAXIMIZED_HORZ in state:
                state_flags = 'H'
            else:
                state_flags = ' '
            # TODO: State.ABOVE, State.BELOW
            state_flags += [' ', 's'][State.SHADED in state]# and \
                                      #not State.HIDDEN in state]
            print '%s %s %s %s' % (window.id, desktop, state_flags, window.name)
    elif options.help_more:
        commandline.print_help_more(config)
    elif args or options.action:
        try:
            actions.perform(options, args, config)
        except actions.ActionException, exc:
            commandline.print_error(exc)
Example #7
0
 def __call__(self, window):
     if not Desktop.__call__(self, window):
         return False
     workarea = WindowManager().workarea_geometry
     geometry = window.geometry
     return geometry.x < workarea.x2 and \
            geometry.x2 > workarea.x and \
            geometry.y < workarea.y2 and \
            geometry.y2 > workarea.y
Example #8
0
def _debug_info(win):
    """Print debug info about Window Manager, and current Window."""
    WindowManager().debug_info(log)
    win.debug_info(log)
    log.info('-= Move using same geometry =-')
    old_geometry = win.geometry
    win.set_geometry(old_geometry)
    win.sync()
    log.info('Old geometry=%s' % old_geometry)
    log.info('New geometry=%s' % win.geometry)
    log.info('-= End of debug output =-')
Example #9
0
def _sticky(win, mode=Mode.TOGGLE):
    """Change sticky (stay on all desktops/viewports) property."""
    win.sticky(mode)
    win_desktop = win.desktop
    if not win_desktop == win.ALL_DESKTOPS and \
       (mode == Mode.SET or mode == Mode.TOGGLE):
        win.set_desktop(win.ALL_DESKTOPS)
    elif win_desktop == win.ALL_DESKTOPS and \
       (mode == Mode.UNSET or mode == Mode.TOGGLE):
        wm = WindowManager()
        win.set_desktop(wm.desktop)
Example #10
0
def _blink(win, bell_color, bell_width, bell_duration):
    """Blink window (show border around window).
    
    Works only for windows on current desktop.
    
    """
    wm = WindowManager()
    desktop = win.desktop
    if desktop != wm.desktop:
        return
    win.visual_bell(bell_color, bell_width, bell_duration)
Example #11
0
import logging
import signal
import time
import threading

from pywo.core import WindowManager
from pywo import actions
from pywo.services import manager

__author__ = "Wojciech 'KosciaK' Pietrzok"

log = logging.getLogger(__name__)

__CONFIG = None
WM = WindowManager()


def setup(config):
    """Import and setup all services."""
    global __CONFIG
    if not __CONFIG:
        # First time start, we are im main-thread - register signal handlers
        signal.signal(signal.SIGINT, interrupt_handler)
        signal.signal(signal.SIGTERM, interrupt_handler)
        # and required actions
        actions.register(name='exit')(exit_pywo)
        actions.register(name='reload')(reload_pywo)
    __CONFIG = config
    WM.update_type()
    manager.load(__CONFIG)
Example #12
0
# along with PyWO.  If not, see <http://www.gnu.org/licenses/>.
#
"""grid_actions.py - PyWO actions - placing windows on grid."""

import itertools
import logging

from pywo.core import Gravity, Geometry, Size, Position, WindowManager
from pywo.actions import Action, TYPE_FILTER
from pywo.actions.resizer import expand_window

__author__ = "Wojciech 'KosciaK' Pietrzok"

log = logging.getLogger(__name__)

WM = WindowManager()

NO_SIZE = Size(0, 0)

CYCLE_WIDTH = 0
CYCLE_HEIGHT = 1


class DummyWindow(object):
    """Dummy Window object, only geometry information is needed."""

    gravity = Gravity(0.5, 0.5)

    def __init__(self, window, position, size, gravity):
        self.extents = window.extents
        self.desktop = window.desktop
Example #13
0
import time
import threading

from pywo.core import WindowManager
from pywo import actions
from pywo.services import manager


__author__ = "Wojciech 'KosciaK' Pietrzok"


log = logging.getLogger(__name__)


__CONFIG = None
WM = WindowManager()


def setup(config):
    """Import and setup all services."""
    global __CONFIG
    if not __CONFIG:
        # First time start, we are im main-thread - register signal handlers
        signal.signal(signal.SIGINT, interrupt_handler)
        signal.signal(signal.SIGTERM, interrupt_handler)
        # and required actions
        actions.register(name="exit")(exit_pywo)
        actions.register(name="reload")(reload_pywo)
    __CONFIG = config
    WM.update_type()
    manager.load(__CONFIG)
Example #14
0
 def __init__(self, desktop=None):
     self.desktop = desktop or WindowManager().desktop
Example #15
0
 def __init__(self):
     Desktop.__init__(self)
     self.workarea = WindowManager().workarea_geometry
Example #16
0
 def __call__(self, window):
     desktop = self.desktop or WindowManager().desktop
     win_desktop = window.desktop
     return win_desktop == desktop or \
            win_desktop == Window.ALL_DESKTOPS
Example #17
0
 def test_singleton(self):
     self.assertEqual(self.WM, WindowManager())
     self.assertTrue(self.WM == WindowManager())