Alexays / Waybar

Highly customizable Wayland bar for Sway and Wlroots based compositors. :v: :tada:
MIT License
6.19k stars 684 forks source link

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

Open aspauldingcode opened 1 month ago

aspauldingcode commented 1 month ago

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.

cmihail commented 1 month ago

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.

aspauldingcode commented 1 month ago

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