i3status → py3status

This commit is contained in:
Théophile Bastian 2016-12-14 18:11:24 +01:00
parent 1ad3818c4d
commit 6b2beaf940
4 changed files with 93 additions and 1 deletions

View file

@ -0,0 +1,17 @@
#!/bin/bash
# Toggles the calendar. If $1=x $2=y, the calendar bottom-right corner is
# placed at x,y.
if ! ps -Ao "%c %u" | grep "orage" | grep -q "$(whoami)"; then
# Orage non lancé
orage > /dev/null 2>/dev/null &
sleep 0.42
fi
orage --toggle
if (( $# >= 2 )); then
# sleep 0.2
i3-msg [class='Orage'] move absolute position "$(($1 - 290))px" \
"$(($2 - 215))px" > /dev/null
fi

View file

@ -199,7 +199,7 @@ bar {
tray_output LVDS1
# position top
font pango:DejaVu Sans Mono, Awesome 8
status_command i3status
status_command py3status -dl /tmp/py3log
# tray_output primary
}

View file

@ -0,0 +1,63 @@
# -*- coding: utf-8 -*-
"""
Displays and controls the mute status of the default microphone.
Displays whether the current microphone is muted or not. A click on the icon
will toggle this status. Relies on pulseaudio.
Configuration parameters:
format_muted: text displayed when muted
(default FontAwesome)
format_unmuted: text displayed when unmuted
(default FontAwesome)
Colors:
color_mute: when muted
color_unmute: when unmuted
"""
import subprocess
class Py3status:
format_muted = '\uf131' # FontAwesome
format_unmuted = '\uf130' # FontAwesome
class Error(Exception):
pass
def microphone(self):
isMute = self.__getMuteStatus__()
color = self.py3.COLOR_MUTE if isMute else self.py3.COLOR_UNMUTE
text = self.format_muted if isMute else self.format_unmuted
return {
'full_text': text,
'color': color,
}
def __getPaList__(self):
try:
paOutput = subprocess.check_output(["pacmd", "list-sources"])
except CalledProcessError:
raise Error()
return paOutput.decode()
def __getMuteStatus__(self):
paList = self.__getPaList__()
fromCurrent = paList[paList.find('* index:'):]
MUTED_STR = 'muted: '
fromMutestat = fromCurrent[fromCurrent.find(MUTED_STR)
+ len(MUTED_STR):]
return fromMutestat[:3] == 'yes'
def __toggleMuteStatus__(self):
isMuted = self.__getMuteStatus__()
paList = self.__getPaList__()
fromCurrent = paList[paList.find('* index: ')+len('* index: '):]
sourceId = int(fromCurrent[:fromCurrent.find('\n')])
subprocess.call(['pacmd', 'set-source-mute', str(sourceId),
str(int(not isMuted))])
def on_click(self, event):
self.__toggleMuteStatus__()

View file

@ -21,11 +21,22 @@ order += "path_exists VPN"
order += "wireless wlo1"
order += "ethernet eno1"
#order += "volume master"
order += "microphone"
order += "battery 1"
order += "arch_updates"
order += "load"
order += "cpu_temperature 0"
order += "tztime local"
arch_updates {
format = "\uf0ed {pacman}"
}
microphone {
color_unmute = "#E73235"
color_mute = "#FFFFFF"
}
volume master {
format = " %volume"
format_muted = " %volume"
@ -68,6 +79,7 @@ run_watch VPN {
tztime local {
format = "%d-%m-%Y %H:%M"
on_click 1 = "exec /home/tobast/.config/i3/bin/calendar-widget $X_POS $Y_POS &"
}
load {