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