Skip to content

Commit

Permalink
external_script module: allow scripts to specify urgent
Browse files Browse the repository at this point in the history
  • Loading branch information
devkev committed Jan 17, 2025
1 parent 5d73d00 commit cb183fd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions py3status/modules/external_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
two lines of output will be used. The first line is used as the displayed
text. If the output has two or more lines, the second line is set as the text
color (and should hence be a valid hex color code such as #FF0000 for red).
If the second line is `urgent`, or has `!` prefixing the hex color, then the
"urgent" flag will be set.
The script should not have any parameters, but it could work.
Configuration parameters:
Expand Down Expand Up @@ -76,8 +78,14 @@ def external_script(self):
output_lines = self.output.splitlines()
if len(output_lines) > 1:
output_color = output_lines[1]
if re.search(r"^#[0-9a-fA-F]{6}$", output_color):
response["color"] = output_color
if output_color == "urgent":
response["urgent"] = True
elif re.search(r"^!?#[0-9a-fA-F]{6}$", output_color):
if output_color[0] == "!":
response["urgent"] = True
response["color"] = output_color[1:]
else:
response["color"] = output_color
except self.py3.CommandError as e:
# something went wrong show error to user
output = e.output or e.error
Expand Down

0 comments on commit cb183fd

Please sign in to comment.