Waybar icon indicating copy to clipboard operation
Waybar copied to clipboard

how to hide one of multiple waybar bars, and then toggle between them

Open aspauldingcode opened this issue 1 year ago • 2 comments
trafficstars

Hello.

I want to:

start_hidden true for the second bar. each is mode dock by config.

bar1 and bar2 have nearly identical configuration.

bar1 will have gaps, and corner radius. bar2 will have no gaps, square corners.

This is so I can toggle gaps script, and it will also affect waybar.

however, I cannot find out how to toggle the mode of a waybar bar.

Using the commandline, how can I do this?

I want to toggle show for bar2, and toggle hide for bar1,

then if I toggle again, I want to hide bar2, show bar1.

aspauldingcode avatar Jul 19 '24 21:07 aspauldingcode

Hey. I have this kind of config myself. Here is my config:

// -*- mode: jsonc -*-
[{
    "name": "minimal_bar",
    "include": "~/.config/waybar/modules.jsonc",
    "layer": "top",
    "mode": "top",
    "exclusive": false,
    "passthrough": false,
    "height": 30,
    "width": 10, // Force minimum width
    "spacing": 2, // Gaps between modules
    "reload_style_on_change": true,
    "modules-center": [
        "clock",
        "custom/notifications",
        "battery"
    ]
}, {
    "name": "full_bar",
    "include": "~/.config/waybar/modules.jsonc",
    "layer": "top",
    "mode": "top",
    "exclusive": false,
    "passthrough": false,
    "height": 30, // Waybar height (to be removed for auto height)
    "width": 750, // Waybar width
    "spacing": 2, // Gaps between modules
    "reload_style_on_change": true,
    "start_hidden": true,
    "ipc": true,
    "modules-left": [
        "hyprland/workspaces"
    ],
    "modules-center": [
        "clock",
        "custom/notifications",
        "battery"
    ],
    "modules-right": [
        "tray",
        "pulseaudio#microphone",
        "pulseaudio",
        "backlight",
        "power-profiles-daemon",
        "custom/power"
    ]
}]

And here is how I toggle between them:

bind = $mainMod, H, exec, killall -SIGUSR1 waybar

So you need to run the following command: killall -SIGUSR1 waybar which will hide minimal_bar and unhide full_bar and the next time the other way around.

cmihail avatar Jul 25 '24 07:07 cmihail

This needs to be documented. I also solved it by creating two bars, one named gaps and the other gapless. Gapless is configured with the start hidden property. Then I toggle them using the SIGUSR1

aspauldingcode avatar Jul 25 '24 20:07 aspauldingcode

I wanted to keep one permently while toggling the other, is there a way to do that?

Vaisakhkm2625 avatar Dec 11 '24 20:12 Vaisakhkm2625

I wanted to keep one permently while toggling the other, is there a way to do that?

Yeah. Make one, then spawn a waybar alias. Then you can toggle the other one off or on.

aspauldingcode avatar Dec 12 '24 14:12 aspauldingcode

Yeah. Make one, then spawn a waybar alias. Then you can toggle the other one off or on.

Can ya elaborate further, please.

SsubezZ avatar Dec 15 '24 16:12 SsubezZ

Yeah. Make one, then spawn a waybar alias. Then you can toggle the other one off or on.

sorry didn't understand... are you saying to run 2 instances for waybar? one permanent and one that i can sent signal to toggle?

Vaisakhkm2625 avatar Dec 15 '24 17:12 Vaisakhkm2625

Yeah. Make one, then spawn a waybar alias. Then you can toggle the other one off or on.

sorry didn't understand... are you saying to run 2 instances for waybar? one permanent and one that i can sent signal to toggle?

Yes if that's what you want. You'll have to define in your config 2 separate bars. In waybar tjey call them an alias bar.

However, this is not the main point of this GitHub issue. I am wanting to document how to toggle between 2 seperate bars. I've achieved it, but damn it was difficult and took trial and error to get here, and it's probably not very good the way it works; we should have a better way to do this in waybar.

aspauldingcode avatar Dec 16 '24 19:12 aspauldingcode