Exemplo n.º 1
0
def get_volume_level():
    '''
    Gets the current volume level
    '''
    txt = tools.term('amixer sget DAC1 | egrep -o "[0-9]+%" | head -1')
    txt = txt.replace('%', '')
    return int(txt)
Exemplo n.º 2
0
def get_workspace():
    '''
    Gets the current workspace number
    '''
    workspace = tools.term(
        'xprop -root _NET_CURRENT_DESKTOP | grep -o "[0-9]*"')
    return int(workspace) if len(workspace) else 0
Exemplo n.º 3
0
def get_alsa_volume():
    '''
    Gets the volume level reported by alsamixer
    '''
    txt = tools.term('amixer sget Master | egrep -o "[0-9]+%" | head -1')
    txt = txt.replace('%', '')
    return int(txt)
Exemplo n.º 4
0
def get_user():
    '''
    Gets the currently logged in user's username
    '''
    return tools.term('id -u -n')
Exemplo n.º 5
0
def logout():
    '''
    Logs out of the current user
    '''
    return tools.term('pkill -u $USER')
Exemplo n.º 6
0
def get_active_window_name():
    '''
    Gets the active window name/title
    '''
    return tools.term('xdotool getwindowfocus getwindowname')
Exemplo n.º 7
0
def get_battery_state():
    '''
    Gets the battery state (Charging, Not Charging)
    '''
    return tools.term('cat /sys/class/power_supply/BAT0/status')
Exemplo n.º 8
0
def decrement_volume(percent):
    '''
    Decrements the volume level by the given percent
    :param percent: The amount of percent to decrement by
    '''
    return tools.term('amixer -q sset DAC1 %s%%-' % (percent))
Exemplo n.º 9
0
def connect(ssid, pswd):
    return tools.term("nmcli device wifi connect '%s' password '%s'" % (ssid, pswd))
Exemplo n.º 10
0
def get_mem_used():
    '''
    Gets the current amount of memory being used
    '''
    txt = tools.term('vmstat -s | egrep -m2 -o "[0-9]+" | tail -1')
    return int(int(txt) / 1000)
Exemplo n.º 11
0
def get_lm_sensors(chip):
    '''
    Gets lm_sensors data for given adapter
    '''
    return json.loads(tools.term('sensors -j'))[chip]
Exemplo n.º 12
0
def get_cpu_temp():
    '''
    Gets the current CPU temperature
    '''
    temp_str = tools.term('cat /sys/class/thermal/thermal_zone0/temp')
    return int((int(temp_str) if len(temp_str) else -1000) / 1000)
Exemplo n.º 13
0
def get_cpu_percent():
    '''
    Gets the current CPU percent
    '''
    return tools.term("vmstat 1 2 | tail -1 | awk '{print 100-$15}'")
Exemplo n.º 14
0
def toggle_volume():
    '''
    Toggles the volume (mute/unmute)
    '''
    return tools.term('amixer -q sset DAC1 toggle')
Exemplo n.º 15
0
def get_network_ssid():
    '''
    Gets the currently connected network SSID
    '''
    return tools.term('iwgetid -r')
Exemplo n.º 16
0
def set_alsa_volume(percent):
    '''
    Sets the volume level using alsamixer
    :param percent: The volume percent to set to
    '''
    return tools.term("amixer sset 'Master' %s%%" % (percent))
Exemplo n.º 17
0
def get_battery_capacity():
    '''
    Gets the current battery capacity
    '''
    cap_str = tools.term('cat /sys/class/power_supply/BAT0/capacity')
    return int(cap_str) if len(cap_str) else -1
Exemplo n.º 18
0
def listing():
    return parse_listing(tools.term('nmcli dev wifi'))
Exemplo n.º 19
0
def set_volume(percent):
    '''
    Sets the volume level to the given percent
    :param percent: The volume percent to set to
    '''
    return tools.term('amixer -q sset DAC1 %s%%' % (percent))