Beispiel #1
0
 def toggle(self):
     if not self.win:
         return
     pos = _point(_RE_POS, 'xdotool', 'getmouselocation')
     if self.win == Client('sel'):
         self.pos_nx = pos
         if self.pos_dpy:
             x, y = self.pos_dpy
         else:
             x, y = map(
                 lambda v: v / 2,
                 _point(_RE_DPY_GEO, 'xdotool', 'getdisplaygeometry'))
         call('xdotool', 'mousemove', str(x), str(y), background=True)
     else:
         self.pos_dpy = pos
         if self.pos_nx:
             x, y = self.pos_nx
         else:
             x, y = map(
                 lambda v: v / 2,
                 _point(_RE_WIN_GEO, 'xdotool', 'getwindowgeometry',
                        str(self.win.id)))
         call('xdotool',
              'mousemove',
              '--window',
              str(self.win.id),
              str(x),
              str(y),
              background=True)
 def _toggle_dialog(self, name):
     if check_dialog(name):
         return
     info = call('sensors')
     if self.gpu:
         info += '\n\n' + call(*self.gpu[1:])
     dialog(info, name)
Beispiel #3
0
def _launch(args, background=True, shell=False):
	import os
	if type(args) == str:
		args = ('wmiir', 'setsid', args)
	if shell:
		args = (' '.join(args),)
	call(*args, background=background, shell=shell)
Beispiel #4
0
 def toggle_tz_time_dialog(self, name):
     if check_dialog(name):
         return
     sweden = call('date', env={'TZ': 'Europe/Stockholm'})
     montreal = call('date', env={'TZ': 'America/Montreal'})
     shanghai = call('date', env={'TZ': 'Asia/Shanghai'})
     dialog("  Sweden: %s\n\nMontreal: %s\n\nShanghai: %s"
             % (sweden, montreal, shanghai), name)
Beispiel #5
0
 def action(args=''):
     cmd = pygmi.find_script(name)
     if cmd:
         call(pygmi.shell,
              '-c',
              '$* %s' % args,
              '--',
              cmd,
              background=True)
Beispiel #6
0
 def toggle_calendar(self):
     if self.calendar_process:
         self.calendar_process.terminate()
         self.calendar_process = None
     else:
         self.calendar_process = call('wmiir', 'setsid',
                 'wmii-cal', '-nc', '-fn', wmii['font'],
                 background=True)
Beispiel #7
0
 def __getattr__(self, name):
     if name.startswith('_') or name.endswith('_'):
         raise AttributeError()
     if hasattr(self, name + '_'):
         return getattr(self, name + '_')
     cmd = pygmi.find_script(name)
     if not cmd:
         raise AttributeError()
     return lambda args='': call(pygmi.shell, '-c', '$* %s' % args, '--', cmd,
                                 background=True)
Beispiel #8
0
 def __getattr__(self, name):
     if name.startswith('_') or name.endswith('_'):
         raise AttributeError()
     if hasattr(self, name + '_'):
         return getattr(self, name + '_')
     cmd = pygmi.find_script(name)
     if not cmd:
         raise AttributeError()
     return lambda args='': call(
         pygmi.shell, '-c', '$* %s' % args, '--', cmd, background=True)
Beispiel #9
0
def dialog(message, ref=None, colors=None, font=None, toggle=True):
    if ref and check_dialog(ref, toggle):
        return

    if not colors: colors = wmii.cache['normcolors']
    if not font: font = wmii.cache['font']

    dialog = call('wmiir', 'setsid', 'wmii-dialog',
            '-fn', font,
            '-fg', colors[0],
            '-bg', colors[1],
            '-br', colors[2],
            message, background=True)

    if ref:
        dialogs[ref] = dialog
Beispiel #10
0
    def _mixer(self, *args):
        cmd = ['amixer']
        if self.device:
            cmd.append('-D')
            cmd.append(self.device)
        if args:
            cmd.append('set')
        else:
            cmd.append('get')
        cmd.append(self.channel)
        if args:
            cmd += args

        value = 'ERR'
        for line in call(*cmd).split('\n'):
            m = _RE_VOLUME.search(line)
            if m:
                if m.group(2) == 'off':
                    value = '-'
                else:
                    value = '%2s' % m.group(1)
                break
        return 'V: %s' % value
Beispiel #11
0
 def action(args=''):
     cmd = pygmi.find_script(name)
     if cmd:
         call(pygmi.shell, '-c', '$* %s' % args, '--', cmd,
              background=True)
Beispiel #12
0
 def set_using_menu(self):
     levels = map(str, range(100, -10, -10))
     level = call('wmii9menu', *levels)
     if level:
         self.set(int(level))
Beispiel #13
0
 def _toggle_dialog(self, name):
     if check_dialog(name):
         return
     free = call('free', '-h')
     df = call('df', '-h', '--type=tmpfs')
     dialog('%s\n\n%s' % (free, df), name)
Beispiel #14
0
 def _toggle_dialog(self, name):
     if check_dialog(name):
         return
     dialog(call('top', '-b', '-i', '-n', '1'), name)
 def _gpu_temp(self, pattern, *args):
     for line in call(*args).split('\n'):
         m = pattern.search(line)
         if m:
             return int(m.group(1))
     return -1
Beispiel #16
0
 def toggle_dialog(self):
     name = self.button.name
     if check_dialog(name):
         return
     dialog(call('nm-tool'), name)
Beispiel #17
0
def _point(pattern, *cmd):
    m = pattern.search(call(*cmd))
    return (int(m.group(1)), int(m.group(2)))
Beispiel #18
0
from pygmi import call


def command_exists(command):
    null = open('/dev/null', 'w')
    p = call('which', command, stdout=null, stderr=null, background=True)
    return p.wait() == 0


# Synchronize clipboard and X selection buffer using autocutsel
if command_exists('autocutsel'):
    call('pkill', '-x', 'autocutsel')  # Terminate any previous instances
    call('autocutsel', '-fork', background=True)
    call('autocutsel', '-selection', 'PRIMARY', '-fork', background=True)

# Automounting functionality and ability to mount as user
if command_exists('udiskie'):
    call('pkill', '-x', 'udiskie')  # Terminate any previous instances
    call('udiskie', '-2', '-a', '-N', '-T', background=True)

# Disable touchpad tapping
if command_exists('synclient'):
    call('synclient', 'MaxTapTime=0')

# vim:se sts=4 sw=4 et:
Beispiel #19
0
def command_exists(command):
    null = open('/dev/null', 'w')
    p = call('which', command, stdout=null, stderr=null, background=True)
    return p.wait() == 0
Beispiel #20
0
wmii.rules += (
    (ur'^qemu-system', dict(floating=True)),
    (ur'^Steam:', dict(tags='game')),
)

# Right bar status plugins
volume.Volume()
ps.Cpu()
ps.Memory()
temperature.Temperature()
clock.Clock()

keys.bind('main', (
    "Misc",
    ('%(mod)s-z', "Counting windows app",
     lambda k: call('cwin', background=True)),
))

# Ensure "maximum performance" is enabled
call('nvidia-settings', '-a', '[gpu:0]/GpuPowerMizerMode=1')

# Adjust the color temperature of the screen(s) to be easy on the eye
call('pkill', '-x', 'redshift')  # Terminate any previous instances
call('redshift', '-l57.70:11.94', background=True)

# Enable transparency and nice transitions
call('pkill', '-x', 'compton')  # Terminate any previous instances
# call('compton', background=True)

# vim:se sts=4 sw=4 et: