1
0
Fork 0

circle on motd services

This commit is contained in:
Massaki Archambault 2018-05-14 16:06:59 -04:00
parent d779d0fdba
commit 8337f83aa0
2 changed files with 23 additions and 22 deletions

View File

@ -52,7 +52,7 @@ class Termutils:
elif i == math.ceil(length * 0.6):
bar += Termutils.YELLOW
percent_color = Termutils.YELLOW
elif i == math.ceil(length * 0.85):
elif i == math.ceil(length * 0.9):
bar += Termutils.RED
percent_color = Termutils.RED
@ -79,23 +79,6 @@ def print_hostname():
+ '\n'
)
def print_tmux():
try:
check_call(['tmux', 'info'], stdout=DEVNULL, stderr=DEVNULL)
print('tmux:')
tmux_session = os.popen('tmux display-message -p "#S"', 'r').read().strip()
with os.popen('tmux list-sessions', 'r') as tmux_ls:
for line in tmux_ls:
line = line.strip()
if line.startswith(tmux_session) and 'TMUX' in os.environ:
print(Termutils.GREEN, end='')
Termutils.print_padded(
line
+ Termutils.DISABLE)
print('')
except CalledProcessError:
pass
def print_services():
if 'MOTD_SERVICES' in os.environ:
print('Services:')
@ -103,9 +86,9 @@ def print_services():
Termutils.print_padded('{:<15.15}'.format(service), end='')
try:
check_call(['systemctl', 'is-active', service], stdout=DEVNULL, stderr=DEVNULL)
print('{} active{}'.format(Termutils.GREEN, Termutils.DISABLE))
print('{} active{}'.format(Termutils.GREEN, Termutils.DISABLE))
except CalledProcessError:
print('{} inactive{}'.format(Termutils.RED, Termutils.DISABLE))
print('{} inactive{}'.format(Termutils.RED, Termutils.DISABLE))
print('')
@ -143,8 +126,26 @@ def print_fs():
)
print('')
def print_tmux():
try:
check_call(['tmux', 'info'], stdout=DEVNULL, stderr=DEVNULL)
print('tmux:')
tmux_session = os.popen('tmux display-message -p "#S"', 'r').read().strip()
with os.popen('tmux list-sessions', 'r') as tmux_ls:
for line in tmux_ls:
line = line.strip()
if line.startswith(tmux_session) and 'TMUX' in os.environ:
print(Termutils.GREEN, end='')
Termutils.print_padded(
line
+ Termutils.DISABLE)
print('')
except CalledProcessError:
pass
print_hostname()
print_tmux()
print_services()
print_mem()
print_fs()
print_tmux()

View File

@ -9,7 +9,7 @@ export EDITOR=vim
export PAGER=less
# motd
export MOTD_SERVICES="docker $MOTD_SERVICES"
export MOTD_SERVICES="docker.socket $MOTD_SERVICES"
# firefox
export MOZ_USE_XINPUT2=1