Esempio 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)
Esempio 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
Esempio 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)
Esempio n. 4
0
def get_user():
    '''
    Gets the currently logged in user's username
    '''
    return tools.term('id -u -n')
Esempio n. 5
0
def logout():
    '''
    Logs out of the current user
    '''
    return tools.term('pkill -u $USER')
Esempio n. 6
0
def get_active_window_name():
    '''
    Gets the active window name/title
    '''
    return tools.term('xdotool getwindowfocus getwindowname')
Esempio n. 7
0
def get_battery_state():
    '''
    Gets the battery state (Charging, Not Charging)
    '''
    return tools.term('cat /sys/class/power_supply/BAT0/status')
Esempio 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))
Esempio n. 9
0
def connect(ssid, pswd):
    return tools.term("nmcli device wifi connect '%s' password '%s'" % (ssid, pswd))
Esempio 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)
Esempio n. 11
0
def get_lm_sensors(chip):
    '''
    Gets lm_sensors data for given adapter
    '''
    return json.loads(tools.term('sensors -j'))[chip]
Esempio 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)
Esempio n. 13
0
def get_cpu_percent():
    '''
    Gets the current CPU percent
    '''
    return tools.term("vmstat 1 2 | tail -1 | awk '{print 100-$15}'")
Esempio n. 14
0
def toggle_volume():
    '''
    Toggles the volume (mute/unmute)
    '''
    return tools.term('amixer -q sset DAC1 toggle')
Esempio n. 15
0
def get_network_ssid():
    '''
    Gets the currently connected network SSID
    '''
    return tools.term('iwgetid -r')
Esempio 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))
Esempio 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
Esempio n. 18
0
def listing():
    return parse_listing(tools.term('nmcli dev wifi'))
Esempio 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))