Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'hide output' method for mpd #641

Open
wants to merge 2 commits into
base: current
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions i3pystatus/mpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class MPD(IntervalModule):
("status", "Dictionary mapping pause, play and stop to output"),
("color", "The color of the text"),
("color_map", "The mapping from state to color of the text"),
("dummy_output", "Text to replace output with in hidden state"),
("max_field_len", "Defines max length for in truncate_fields defined \
fields, if truncated, ellipsis are appended as indicator. It's applied \
*before* max_len. Value of 0 disables this."),
Expand All @@ -91,6 +92,8 @@ class MPD(IntervalModule):
"play": "▶",
"stop": "◾",
}
hidden = True
dummy_output = "###"
color = "#FFFFFF"
color_map = {}
max_field_len = 25
Expand Down Expand Up @@ -129,6 +132,13 @@ def _mpd_command(self, sock, command):
return None

def run(self):
if self.hidden:
self.output = {
"full_text": self.dummy_output,
"color": self.color,
}
return

try:
status = self._mpd_command(self.s, "status")
playback_state = status["state"]
Expand Down Expand Up @@ -215,3 +225,6 @@ def mpd_command(self, command):
self._mpd_command(self.s, command)
except Exception as e:
pass

def toggle_hidden(self):
self.hidden = not self.hidden