diff options
author | Camil Staps | 2021-07-08 20:12:23 +0200 |
---|---|---|
committer | Camil Staps | 2021-07-08 20:12:38 +0200 |
commit | 5a44e2aea3a022acd680b962e4fb6e7739afc8d5 (patch) | |
tree | 41297502fc604e91fb3f676cfa9675f83b5232ff /i3/bin/i3status.py | |
parent | Add Gentium fonts (Journal of Hebrew Scriptures) (diff) |
Remove currently playing song from cmus from i3status (causes a lot of logging in .xsession-errors)
Diffstat (limited to 'i3/bin/i3status.py')
-rwxr-xr-x | i3/bin/i3status.py | 49 |
1 files changed, 2 insertions, 47 deletions
diff --git a/i3/bin/i3status.py b/i3/bin/i3status.py index 1a2d166..019637e 100755 --- a/i3/bin/i3status.py +++ b/i3/bin/i3status.py @@ -33,46 +33,6 @@ def parse_kbdlayout(s): color = '#cccccc' return [{'full_text': s, 'color': color}] -def print_album_and_artist(info, parentheses): - if 'album' in info: - if 'artist' in info: - if parentheses: - return info['album'] + ' (' + info['artist'] + ')' - else: - return info['album'] + ', ' + info['artist'] - else: - return info['album'] - elif 'artist' in info: - return info['artist'] - else: - return None - -def get_cmus_song(): - result = check_output(['cmus-remote', '-Q']) - info = {} - for line in result.split('\n'): - if line[:10] == 'tag title ': - info['title'] = line[10:] - elif line[:10] == 'tag album ': - info['album'] = line[10:] - elif line[:11] == 'tag artist ': - info['artist'] = line[11:] - - album_and_artist = print_album_and_artist(info, 'title' not in info) - text = None - if album_and_artist is None: - if 'title' in info: - text = info['title'] - elif 'title' in info: - text = info['title'] + ' (' + album_and_artist + ')' - else: - text = album_and_artist - - if text is None: - return [] - else: - return [{'full_text': text}] - def merge_status_items(*args): return [item for sublist in args for item in sublist] @@ -87,7 +47,7 @@ if __name__ == '__main__': sys.stdout.write(i3stat.stdout.readline()) sys.stdout.write(i3stat.stdout.readline()) - stat, kbd, cmus = [], [], [] + stat, kbd = [], [] try: stdouts = [p.stdout for p in [i3stat, kbdlayout]] while True: @@ -98,13 +58,8 @@ if __name__ == '__main__': kbd = parse_kbdlayout(line) elif f == i3stat.stdout: stat = parse_i3stat(line) - - try: - cmus = get_cmus_song() - except: - cmus = [] - print_i3stat(merge_status_items(kbd, cmus, stat)) + print_i3stat(merge_status_items(kbd, stat)) except Exception, e: print(e) |