Esempio n. 1
0
    def set_new_brightness(self, new_brightness: float):
        """
        Requirement: 0 < new_brightness <= 1
        Note that for OLED displays, 0 brightness is pitch black,
        so `new_brightness` must be greater than 0
        """

        if 0 < new_brightness <= 1:
            try:
                sh.xrandr('--output', self.display, '--brightness', new_brightness)
            except sh.CommandNotFound:
                print('[error] missing tool')
            except:
                print('[error] something went wrong')
        else:
            print('[error] invalid new brightness')
Esempio n. 2
0
def cmd_xrandr_on():
    outputs = grep(xrandr(), ' connected')
    outputs = [o.split(' ')[0] for o in outputs
               if not OUTPUT_ACTIVE_REX.match(o)]
    if len(outputs) > 1:
        outputs = output(dmenu(outputs)).split('\n')
    if not outputs:
        return
    selected_output = outputs[0]
    active_outputs = _get_active_outputs()
    if not active_outputs:
        return
    choices = []
    for active_output in active_outputs:
        choices.append('--left-of ' + active_output)
        choices.append('--right-of ' + active_output)
        choices.append('--below ' + active_output)
        choices.append('--above ' + active_output)
        choices.append('--same-as ' + active_output)
    choice = output(dmenu(choices))
    option, active_output = choice.split(' ')
    xrandr('--output', selected_output, option, active_output, '--auto')
Esempio n. 3
0
    def get_current_brightness(self):
        """
        Returns the current brightness (float) set with xrandr;
        if an error occurs returns None
        """

        try:
            xrandr_output = sh.xrandr('--verbose')
            line_with_brightness = sh.grep(xrandr_output, '-im', '1', 'brightness')
            brightness = sh.awk(line_with_brightness, '{print $2}')
            return float(brightness)
        except sh.CommandNotFound:
            print('[error] missing tool')
        except:
            print('[error] something went wrong')
        return None
Esempio n. 4
0
    def get_display_name(self):
        """
        Returns the name (str) of the primary display found via xrandr;
        if an error occurs, returns None
        """

        try:
            xrandr_output = sh.xrandr()
            line_with_display = sh.grep(xrandr_output, '-im', '1', 'primary')
            display = sh.awk(line_with_display, '{print $1}')
            return display.strip()
        except sh.CommandNotFound:
            print('[error] missing tool')
        except:
            print('[error] something went wrong')
        return None
Esempio n. 5
0
#!/usr/bin/env python3

import sh, json, pathlib

# This module defines the geometry of every window assigned to a key binding.
# The four most important parameters are screen_width, screen_height,
# division_width, and division_height.  The rest of the parameters are derived
# from these four.
#
# The screen dimensions are grabbed from GTK.  If the python bindings to GTK
# are not installed, the resolution of the screen can be specified manually.
# The division width and height define the dimensions of the grid that the
# windows fit into.  The default parameters were chosen to fit well with
# 80-character terminals using a 10-point monospace font.

for line in sh.xrandr(_iter=True):
    if '*' in line:
        resolution = line.split()[0].split('x')
        screen_width = int(resolution[0])
        screen_height = int(resolution[1])

onyx = { "top" : 22, "bottom" : 2, "sides" : 2 }
clearlooks  = { "top" : 20, "bottom" : 5, "sides" : 2 }
minimalist = { "top" : 3, "bottom" : 3, "sides" : 3 }
theme = minimalist
vertical_padding = theme["top"] + theme["bottom"]
horizontal_padding = 2 * theme["sides"]

# When using a 10-point monospace font, each column in a gvim window is 8
# pixels wide.  The full width of the window is 10 pixels wider than the sum of
# the columns to account for 5 pixels of padding on each side of the window.
Esempio n. 6
0
def cmd_xrandr_off():
    outputs = _get_active_outputs()
    o = output(dmenu(outputs))
    xrandr('--output', o.split(' ')[0], '--off')
Esempio n. 7
0
def _get_active_outputs():
    outputs = grep(xrandr(), ' connected')
    return [o.split(' ')[0] for o in outputs
            if OUTPUT_ACTIVE_REX.match(o)]
Esempio n. 8
0
cursor_warp = False
floating_layout = layout.Floating()
mouse = ()
auto_fullscreen = True
widget_defaults = {}

def ensure_running(proc_name, run_proc):
  def start_if_required():
    try:
      sh.pidof(proc_name)
    except sh.ErrorReturnCode:
      run_proc()
  return start_if_required

startup_apps = [lambda: sh.wmname("LG3D"),
                lambda: sh.xrandr(s='1920x1080'),
                ensure_running("gnome-settings-daemon",
                               lambda: sh.gnome_settings_daemon(_bg=True)),
                ensure_running("nm-applet", lambda: sh.nm_applet(_bg=True)),
                ensure_running("launchy", lambda: sh.launchy(_bg=True)),
                lambda: sh.dropbox("start", _bg=True)]

def main(qtile):
  for start_app in startup_apps:
    start_app()

@hook.subscribe.client_new
def dialogs(window):
    if(window.window.get_wm_type() == 'dialog'
        or window.window.get_wm_transient_for()):
        window.floating = True
]

touch = [
    "Wacom Intuos PT S Finger touch",
    "Wacom Intuos PT S (WL) Finger touch"
]

pad = [
    "Wacom Intuos PT S Pad pad",
    "Wacom Intuos PT S (WL) Pad pad"
]

all_inputs = stylus + eraser + touch + pad

_active_targets = None
_displays = { line.split()[0] for line in xrandr() if not line.startswith(' ') }
_displays.remove('Screen')

_dir = os.path.dirname(os.path.abspath(__file__))
_profile_store = os.path.join(_dir, ".wacom_profile")


def set(targets, prop, value):
    if SIMULATE:
        return

    print 'active targets:', get_active_targets().intersection(targets)

    for target in get_active_targets().intersection(targets):
        print 'xsetwacom: %s=%r on %s' % (prop, value, target)
        xsetwacom.set(target, prop, value)
Esempio n. 10
0
]

touch = [
    "Wacom Intuos Pro S Finger touch",
    "Wacom Intuos Pro S (WL) Finger touch"
]

pad = [
    "Wacom Intuos Pro S Pad pad",
    "Wacom Intuos Pro S (WL) Pad pad"
]

all_inputs = stylus + eraser + touch + pad

_active_targets = None
_displays = { line.split()[0] for line in xrandr() if not line.startswith(' ') }
_displays.remove('Screen')

_dir = os.path.dirname(os.path.abspath(__file__))
_profile_store = os.path.join(_dir, ".wacom_profile")


def set(targets, prop, value):
    if SIMULATE:
        return

    print 'active targets:', get_active_targets().intersection(targets)

    for target in get_active_targets().intersection(targets):
        print 'xsetwacom: %s=%r on %s' % (prop, value, target)
        xsetwacom.set(target, prop, value)
Esempio n. 11
0
def autostart():
    sh.xrandr('--output', 'HDMI-1', '--primary', '--right-of', 'eDP-1')
Esempio n. 12
0
def num_monitors():
    return int(
        sh.head(sh.xrandr('--listmonitors'), '-1').stdout.decode('utf-8')[-2])