dots-hyprland icon indicating copy to clipboard operation
dots-hyprland copied to clipboard

Waybar module does not revert to default state after video player closes

Open ozgilik opened this issue 1 year ago • 1 comments

I have read the Usage and Troubleshooting pages of the wiki:

https://end-4.github.io/dots-hyprland-wiki/en/i-i/03troubleshooting/

I have made sure that both my config and system packages are up to date

Linux distro:

Arch Linux


The issue

When watching videos in a browser, my Waybar module displays the video title and pause/play state. However, when the video is closed or the player vanishes, the Waybar does not return to its previous state (e.g., showing CPU information), and the space reserved for the video details remains empty, resulting in the layout being stuck.

Steps to Reproduce:

  1. Play a video in a browser.
  2. Observe that the video details are displayed on Waybar.
  3. Close the video or the browser.
  4. Notice that the Waybar does not return to its original state, leaving an empty space.

Proposed Solution:

The issue can be resolved by ensuring the Waybar module properly resets to the previous state when the player vanishes. Specifically:

  • Modify the clear_output function to restore the previous module (e.g., CPU information) instead of writing an empty string.
  • Update the on_player_vanished function to check if there are no active players, and if so, call the clear_output to restore the default view.

Code changes:

File

.config/waybar/scripts/mediaplayer.py

  1. Update clear_output to display CPU data:

    def clear_output(self):
        output = {"text": "CPU: <cpu_data>", "class": "default", "alt": "CPU"}
        sys.stdout.write(json.dumps(output) + "\n")
        sys.stdout.flush()
    
  2. Modify on_player_vanished to check for active players and reset if none exist:

    def on_player_vanished(self, _, player):
        logger.info(f"Player {player.props.player_name} has vanished")
        if len(self.get_players()) == 0:
            self.clear_output()
        else:
            self.show_most_important_player()
    

This resolves the issue by resetting the Waybar module back to its previous state when no players are active.

ozgilik avatar Sep 21 '24 09:09 ozgilik

the dotfiles use ags as the bar and not waybar, I think you mistook this repo as someone's else?

shinyPy avatar Sep 21 '24 19:09 shinyPy

bro u need to sleep

PharmaRacist avatar Nov 21 '24 18:11 PharmaRacist