Skip to content

Conversation

lasers
Copy link
Contributor

@lasers lasers commented Jul 18, 2025

Just updating this module from scratch. I dunno. Untested.

  • Omit color in the response in favor of more colors via self.py3.safe_format
  • Thresholds added
  • Additional placeholders for extra customizations such as custom names/icons
    • Default format should mimic check_security = True behavior
    • Disable check_security = True behavior by using format = "DNF [\?color=available {available}]
      • I hope this is right. I don't know.
  • For legacy theme, use...
    • format = "[\?if=security&color=bad DNF: {available}|\?color=available DNF: {available}]"

Closes #2290. /cc @girst for testing.

@lasers lasers force-pushed the newmodule-dnf_updates branch from 0d74fe9 to acbcdc9 Compare July 18, 2025 17:53
@girst
Copy link
Contributor

girst commented Jul 18, 2025 via email

@girst
Copy link
Contributor

girst commented Jul 18, 2025 via email

@lasers lasers force-pushed the newmodule-dnf_updates branch from acbcdc9 to b20430d Compare July 18, 2025 19:27
@lasers
Copy link
Contributor Author

lasers commented Jul 18, 2025

Made a tweak to give default 0 values... ie Users see 0 instead of {security} when no available security.

not a fan of the non-colored 'DNF' text and preferred the
previous everything-the-same-color. the latter better matches the other
(both py3status and upstream/i3status) modules.

I heard you. I hadn't used py3status for while now. When I did, I was exposing modules with new color defaults because py3status used to not be able to display them.... and to keep modules in unity with each others. Also, some modules works better with sensible theme/colors such as lm_sensors, nvidia_smi, etc.

I just made the consistency tweaks. Modules like sysdata can benefit from colors too.

requires-python = ">=3.9"

Idk if those old fc are over the new version requirement added not long ago.

EDIT: Users changing global default/good/degraded/bad colors... which would change almost all modules that have this configured correctly (hopefully by default or via custom)... is a welcoming change, imho.

@lasers lasers force-pushed the newmodule-dnf_updates branch from b20430d to 0f2c466 Compare July 19, 2025 06:53
@lasers
Copy link
Contributor Author

lasers commented Jul 20, 2025

(Testers) Do we need to change self.py3.command_output with something else?

@lasers lasers force-pushed the newmodule-dnf_updates branch from 0f2c466 to 7a0c044 Compare July 28, 2025 21:55
@ultrabug
Copy link
Owner

@lasers thanks for your continued efforts

@girst need you to validate this module, I dont have a fedora box, cheers

@lasers lasers force-pushed the newmodule-dnf_updates branch from 7a0c044 to 41e35d0 Compare August 26, 2025 14:37
@girst
Copy link
Contributor

girst commented Sep 1, 2025 via email

@girst
Copy link
Contributor

girst commented Sep 3, 2025 via email

@girst
Copy link
Contributor

girst commented Sep 3, 2025

argh! it seems, github swallows some of my emails sent to this discussion.

one from earlier that did not make it:

Date: Sat, 19 Jul 2025 16:06:18 +0200
Subject: Re: [ultrabug/py3status] dnf_updates: new module from scratch (PR #2291)

you might have misunderstood me. my comment was about how the text 'DNF' does
not get colored in the same color that the number of outstanding updates is,
not about the global color pallette.

the few colored modules i use (ethernet, wifi, battery, imap) all use the same
color for the whole text of the module, not just color part of it. this has
the (positive, imo) effect that more pixels get colored, making it easier to
spot at a glance.

with <white>DNF</white> <yellow>1</yellow>, only 1 of 5 chars is in the
degraded color. what i would've preferred is <yellow>DNF: 1</yellow>.

just now:

Date: Wed, 3 Sep 2025 12:02:22 +0200
Subject: Re: [ultrabug/py3status] dnf_updates: new module from scratch (PR #2291)

module breaks every time after resuming from standby:

2025-09-03 11:59:49 WARNING Instance `dnf_updates`, user method `dnf_updates` failed (CommandError) py3.py line 1021.
2025-09-03 11:59:49 INFO Traceback
CommandError: Command `dnf updateinfo list --json` returned non-zero exit status 1
  File "/home/t/projects/py3status/py3status/module.py", line 952, in run
    response = method()
  File "/home/t/projects/py3status/py3status/modules/dnf_updates.py", line 70, in dnf_updates
    dnf_data = self._get_dnf_data()
  File "/home/t/projects/py3status/py3status/modules/dnf_updates.py", line 61, in _get_dnf_data
    updates = loads(self.py3.command_output("dnf updateinfo list --json"))
                    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/t/projects/py3status/py3status/py3.py", line 1021, in command_output
    raise exceptions.CommandError(
        msg, error_code=retcode, error=error, output=output
    )

@lasers
Copy link
Contributor Author

lasers commented Sep 4, 2025

This is what you want.

# i3status theme
format = "[\?if=security&color=bad DNF: {available}"
format += "|\?color=available DNF: {available}]"

# i3status theme - hide module when no available updates
format = "[\?if=available [\?if=security&color=bad DNF: {available}"
format += "|\?color=available DNF: {available}]]"

This is what I was trying to support in py3status formats.

general {
    # These will be used if not supplied by a module
    color = '#FFFFFF'
    color_good = '#00FF00'
    color_bad = '#FF0000'
    color_degraded = '#FFFF00'
}

Imho, py3status formats should include headers.
Imho, py3status formats should include headers that also can be colorized by color = '#FFFFFF'.

Also, i3status can't colorize. This is customization issue. Py3status could benefit from having theme support... such as users specifying theme = "i3status" in py3status config section that would update default format* configs. This mean we would have to take on few theme files, blah. I would suggest to keep at taking theme files minimal too.

  • 3x imap: it looks like you configured those formats to mimic i3status.
  • old fedora_updates: default format with forced colors.
  • new dnf_updates: it looks like you would configure this format to mimic i3status.
  • wifi, ethernet: it looks like you configured those formats (with trimmed headers) -- Maybe i3status modules.
    -- py3status/wifi.py have legacy code to force colors just in case if \?color=xxx is not in the format.

I can add i3status theme (what you want above) in Examples to make this easy copy/paste. I feel like this would be the easiest way to address your i3status concern.

@lasers lasers force-pushed the newmodule-dnf_updates branch 2 times, most recently from 6b9ea2a to a8a9ca8 Compare September 4, 2025 08:01
@lasers
Copy link
Contributor Author

lasers commented Sep 4, 2025

module breaks every time after resuming from standby:

Addressed. EDIT: If you see None placeholder(s) after resuming from suspend, the module will retry in 10s instead of module breaking right there.

EDIT: Terminal screenshot.

image

@lasers lasers force-pushed the newmodule-dnf_updates branch from a8a9ca8 to fb03ef8 Compare September 4, 2025 08:30
@lasers lasers force-pushed the newmodule-dnf_updates branch from fb03ef8 to f8a3398 Compare September 4, 2025 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fedora_update: output of dnf command changed (fedora 41 / dnf 5.x) - security updates no longer noticed
3 participants