Is there a way to add app shortcuts to the waybar?

I’m thinking of my most frequently used apps, and wondering if I could save some clicks this way, since I am disabled.

Edit: I’ve found some documentation for config.jsonc, so I can probably do this. How to add app icons is not yet clear.

Isn’t much simpler to use wofi ?
wofi --show drun
or is it
wofi --show=drun
or maybe is
run wofi --show=drun

and you add whatever “shortcuts” you want as *.desktop files in your ~/.local/share/applications
Example:

cp /usr/share/applications/firefox.desktop ~/.local/share/applications/firefox.desktop

Ah, look, something from our friends forum Adding an application to Wofi - #7 by boomvroomshroom - Sway - Garuda Linux Forum :grin:

I already use rofi. Such menus are simpler to program, but if I have to click two keys just to see the menu, that’s what I’m trying to avoid. Dis.A.Bled.

Thanks anyway.

Add custom/icon to waybar config and style.css.

For example :- “modules-left”: [“custom/launcher”, “custom/icon1”, “custom/icon2”, “custom/icon3”],

"custom/icon1": {
    "format": "{}  ",
    "tooltip": false,
    "on-click": "opera",
    "on-click-right": "vivaldi-stable"
},
"custom/icon2": {
    "format": "{} 󰉋 ",
    "tooltip": false,
    "on-click": "nautilus",
    "on-click-right": "kitty -e ranger"
},
"custom/icon3": {
    "format": "{} 󰨇 ",
    "tooltip": false,
    "on-click": "gnome-system-monitor",
    "on-click-right": "kitty -e bashtop"
},

20_grim

Add “custom- icon” to style.css

#custom-icon {
background-color: #FF6347;
}

My waybar config
{
    "layer": "top", // Waybar at top layer
    // "position": "top", // Waybar position (top|bottom|left|right)
    "height": 30, // Waybar height (to be removed for auto height)
    // "width": 1280, // Waybar width
    "spacing": 6, // Gaps between modules (4px)
    "fixed-center": true,
    // Choose the order of the modules
    "modules-left": ["custom/launcher", "custom/icon1", "custom/icon2", "custom/icon3", "custom/icon4", "custom/icon5", "custom/icon6", "custom/icon7", "custom/icon8", "custom/icon9", "custom/icon10", "custom/icon11", "custom/icon12", "custom/icon13", "custom/icon14", "hyprland/workspaces", "custom/media"],
    "modules-center": ["custom/icon15", "wlr/taskbar"],
    "modules-right": ["pulseaudio", "network", "disk", "cpu", "memory", "temperature", "backlight", "keyboard-state", "sway/language", "battery", "battery#bat2", "clock", "custom/weather", "custom/pacman", "custom/power", "tray"],
    // Modules configuration
        "hyprland/workspaces": {
        "disable-scroll": false,
        "active-only": false,
        "on-scroll-up": "hyprctl dispatch workspace +1",
        "on-scroll-doun": "hyprctl dispatch workspace -1",
        "show-special": true,
        "all-outputs": false,
        "on-click": "activate",
        //"format": "{icon}",
        "persistent_workspaces": {
            "1": ["HDMI-A-2"],
            "2": ["HDMI-A-2"],
            "3": ["HDMI-A-2"],
            "4": ["HDMI-A-2"],
            "5": ["HDMI-A-2"],
            "6": ["HDMI-A-2"],
            "7": [""],
            "8": [""],
            "9": [""]
        }
    },
    "keyboard-state": {
        "numlock": true,
        "capslock": true,
        "format": "{name} {icon}",
        "format-icons": {
            "locked": "",
            "unlocked": ""
        }
    },
    "sway/mode": {
        "format": "<span style=\"italic\">{}</span>"
    },
    "wlr/taskbar": {
    "format": "{icon} {app_id}",
    "markup": true,
    "icon-theme": "/usr/share/icons/Papirus-Dark",
    "icon-size": 13,
    "tooltip": true,
    "active-first": true,
    "on-click": "activate",
    "on-click-right": "close",
    "on-scroll-up": "hyprctl dispatch workspace e+1",
    "on-scroll-down": "hyprctl dispatch workspace e-1",
    "ignore-list": [
        "Conky"
    ],
    "app_ids-mapping": {
        "org.gnome.Nautilus": "Files",
        "org.gnome.Meld": "Meld",
        "org.gnome.Gnote": "gnote",
        "org.gnome.Calculator": "Calc",
        "terminal64.exe": "Mt5",
        "metaeditor64.exe": "Mt5edit",
        "vivaldi-stable": "vivaldi",
        "gnome-terminal-server": "Term",
        "gnome-system-monitor": "monitor",
        "org.manjaro.pamac.manager": "pamac",
        "Manjaro.manjaro-settings-manager": "settings"
        
    }
    },
    "sway/scratchpad": {
        "format": "{icon} {count}",
        "show-empty": false,
        "format-icons": ["", ""],
        "tooltip": true,
        "tooltip-format": "{app}: {title}"
    },
    "mpd": {
        "format": "{stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon}{artist} - {album} - {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S}) ⸨{songPosition}|{queueLength}⸩ {volume}% ",
        "format-disconnected": "Disconnected ",
        "format-stopped": "{consumeIcon}{randomIcon}{repeatIcon}{singleIcon}Stopped ",
        "unknown-tag": "N/A",
        "interval": 2,
        "consume-icons": {
            "on": " "
        },
        "random-icons": {
            "off": "<span color=\"#f53c3c\"></span> ",
            "on": " "
        },
        "repeat-icons": {
            "on": " "
        },
        "single-icons": {
            "on": "1 "
        },
        "state-icons": {
            "paused": "",
            "playing": ""
        },
        "tooltip-format": "MPD (connected)",
        "tooltip-format-disconnected": "MPD (disconnected)"
    },
    "idle_inhibitor": {
        "format": "{icon}",
        "format-icons": {
            "activated": "",
            "deactivated": ""
        }
    },
    "tray": {
        // "icon-size": 21,
        "spacing": 10
    },
    "clock": {
        // "timezone": "Asia/Kolkata",
        "interval": 1,
        "tooltip-format": "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>",
        "format-alt": "{:%Y-%m-%d}",
        "format": "{:%e %a %b %I:%M:%S}"
    },
    "cpu": {
        "interval": 1,
        "format": "{usage}% ",
        "on-click": "gnome-system-monitor",
        "min-length": 8,
        "tooltip": false
    },
    "disk": {
        "format": "{used}",
        "format-alt": "󰋊 {used}/{total} GiB",
        "interval": 5,
        "path": "/"
    },
    "custom/launcher": {
        "format": "󰀻",
        "tooltip": false,
        "min-length": 4,
        "on-click": "rofi -combi-modi window,drun,ssh -icon-theme Papirus -show combi -hover-select -me-select-entry '' -me-accept-entry MousePrimary",
//    "on-click": "wofi --show drun -I -a -n -W 500 -H 376 -s ~/.config/wofi/themes/gruvbox.css",
        "on-click-middle": "wtype -k escape",
        "on-click-right": "jgmenu_run"  
    },
    "memory": {
        "on-click-right": "kitty -e bashtop",
        "interval":  2,   
        "format":  "{used:0.1f}G/{total:0.1f}G/{swapUsed:0.1f}G "
    },
    "temperature": {
        //"thermal-zone": 2,
        //"hwmon-path": "/sys/class/hwmon/hwmon1/temp1_input",
        "hwmon-path-abs": "/sys/devices/platform/coretemp.0/hwmon",
        "input-filename": "temp1_input",
        "interval":  1,
        "critical-threshold": 55,
        // "format-critical": "{temperatureC}°C {icon}",
        "format": "{temperatureC}°C {icon}",
        "format-icons": ["", "", ""]
    },
    "backlight": {
        // "device": "acpi_video1",
        "format": "{percent}% {icon}",
        "format-icons": ["", "", "", "", "", "", "", "", ""]
    },
    "battery": {
        "states": {
            // "good": 95,
            "warning": 30,
            "critical": 15
        },
        "format": "{capacity}% {icon}",
        "format-charging": "{capacity}% ",
        "format-plugged": "{capacity}% ",
        "format-alt": "{time} {icon}",
        // "format-good": "", // An empty format will hide the module
        // "format-full": "",
        "format-icons": ["", "", "", "", ""]
    },
    "battery#bat2": {
        "bat": "BAT2"
    },
    "network": {
        // "interface": "wlp2*", // (Optional) To force the use of this interface
        "interval": 1,
        "format-wifi": "{essid} ({signalStrength}%) ",
        "format-ethernet": "{bandwidthDownBytes}/{bandwidthUpBytes} ",
        "tooltip-format": "{ifname} via {gwaddr} ",
        "format-linked": "{ifname} (No IP) ",
        "format-disconnected": "Disconnected ⚠",
        "min-length": 18,
        "format-alt": "{ifname}: {ipaddr}/{cidr}"
    },
    "custom/pacman": {
        "format": "{}  ",
        "min-length": 5,
        "tooltip": false,
        "interval": 3600,
        "exec": "checkupdates | wc -l",
        "exec-if": "exit 0",
        "on-click": "gnome-terminal -e 'sudo pacman -Syu'; pkill -SIGRTMIN+8 waybar",
        "signal": 8
    },
    "custom/weather": {
        "exec": "python ~/.config/waybar/weather.py",
        "return-type": "json",
        "format": "{}",
        "tooltip": true,
        "on-click": "xdg-open https://weather.com/en-IN/weather/today/l/6121c511144d639b3932fe2a28537be31b9be0d714e86f7ca41f69528423c3a8",
        "interval": 600
    },
    "custom/icon1": {
        "format": "{}  ",
        "tooltip": false,
        "on-click": "vivaldi-stable",
        "on-click-right": "opera"
    },
    "custom/icon2": {
        "format": "{} 󰉋 ",
        "tooltip": false,
        "on-click": "nautilus",
        "on-click-right": "kitty -e ranger"
    },
    "custom/icon3": {
        "format": "{} 󰨇 ",
        "tooltip": false,
        "on-click": "gnome-system-monitor",
        "on-click-right": "kitty -e bashtop"
    },
    "custom/icon4": {
        "format": "{}  ",
        "on-click": "gnome-calculator",
        "on-click-right": "kitty -e bc"
    },
    "custom/icon5": {
        "format": "{}  ",
        "tooltip": false,
        "on-click": "gnome-boxes"
    },
    "custom/icon6": {
        "format": "{} 󰕼 ",
        "on-click": "vlc",
        "on-click-right": "lollypop"
    },
    "custom/icon7": {
        "format": "{} 󰌌 ",
        "tooltip": false,
        "on-click": "wf-osk"
    },
    "custom/icon8": {
        "format": "{} 󰈹 ",
        "tooltip": false,
        "on-click": "firefox",
        "on-click-right": "qutebrowser"
    },
    "custom/icon9": {
        "format": "{}  ",
        "on-click": "kitty",
        "on-click-right": "gnome-terminal"
    },
    "custom/icon10": {
        "format": "{} 󰏔 ",
        "tooltip": false,
        "on-click": "pamac-manager",
        "on-click-right": "kitty -e sudo pacman -Scc"
    },
    "custom/icon11": {
        "format": "{}  ",
        "tooltip": false,
        "on-click": "gimp-2.10",
        "on-click-middle": "pkill swaybg | sleep 0.5 && swaybg -i ~/Pictures/wallpapers/$(ls ~/Pictures/wallpapers|shuf -n 1) -m fill",
        "on-click-right": "/home/qtiler/scripts/wayland-color-picker"
    },
    "custom/icon12": {
        "format": "{} 󰆒 ",
        "tooltip": false,
        "on-click": "cliphist list | rofi -dmenu -hover-select -me-select-entry '' -me-accept-entry MousePrimary | cliphist decode | wl-copy",
        "on-click-right": "wtype -k escape"
    },
    "custom/icon13": {
        "format": "{} 󰎚 ",
        "tooltip": false,
        "on-click": "gnote",
        "on-click-right": "kitty -e newsboat"
    },
    "custom/icon14": {
        "format": "{}  ",
        "tooltip": false,
        "on-click": "geany $HOME/.config/hypr/hyprland.conf",
        "on-click-middle": "geany $HOME/.config/waybar/style.css",
        "on-click-right": "geany $HOME/.config/waybar/config"
    },
    "custom/icon15": {
        "format": "{}  ",
        "tooltip": false,
        "on-click": "hyprctl dispatch movetoworkspace -1",
        "on-click-right": "hyprctl dispatch movetoworkspace +1"
    },
    "custom/power": {
        "format": "  ",
        "tooltip": false,
        "on-click": "killall -9 Hyprland",
        "on-click-middle": "systemctl reboot",
        "on-click-right": "systemctl -i poweroff"
    },
    "pulseaudio": {
        // "scroll-step": 1, // %, can be a float
        "format": "{volume}% {icon} {format_source}",
        "format-bluetooth": "{volume}% {icon} {format_source}",
        "format-bluetooth-muted": " {icon} {format_source}",
        "format-muted": " {format_source}",
        "format-source": "{volume}% ",
        "format-source-muted": "",
        "format-icons": {
            "headphone": "",
            "hands-free": "",
            "headset": "",
            "phone": "",
            "portable": "",
            "car": "",
            "default": ["", "", ""]
        },
        "on-click": "pavucontrol",
        "on-click-right": "amixer -q set Master toggle"
    },
//    "custom/media": {
//        "format": "{icon} {}",
//        "return-type": "json",
//        "max-length": 40,
//        "format-icons": {
//            "spotify": "",
//            "default": "🎜"
//        },
//        "escape": true,
//        "exec": "$HOME/.config/waybar/mediaplayer.py 2> /dev/null" // Script in resources folder
//        // "exec": "$HOME/.config/waybar/mediaplayer.py --player spotify 2> /dev/null" // Filter player based on name
    }
}


My waybar style.css
* {
    /* `otf-font-awesome` is required to be installed for icons */
    font-family: FontAwesome, Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
}

window#waybar {
    background-color: rgba(43, 48, 59, 0.6);
    border-bottom: 3px solid rgba(100, 114, 125, 0.5);
    color: #ffffff;
    transition-property: background-color;
    transition-duration: .5s;
}

window#waybar.hidden {
    opacity: 0.2;
}

/*
window#waybar.empty {
    background-color: transparent;
}
window#waybar.solo {
    background-color: #FFFFFF;
}
*/

window#waybar.termite {
    background-color: #3F3F3F;
}

window#waybar.chromium {
    background-color: #000000;
    border: none;
}

button {
    /* Use box-shadow instead of border so the text isn't offset */
    box-shadow: inset 0 -3px transparent;
    /* Avoid rounded borders under each button name */
    border: none;
    border-radius: 0;
}

/* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */
button:hover {
    background: inherit;
    box-shadow: inset 0 -3px #ffffff;
}

#workspaces button {
    padding: 0 5px;
    background: rgba(0, 0, 0, 0.2);  
    color: #ffffff;
}

#workspaces button.persistent {
	background-color: transparent;
}

#workspaces button:hover {
    background: rgba(0, 0, 0, 0.3);
}

#workspaces button.active {
	background-color: #ff0088;
}

#workspaces button.focused {
    background-color: #64727D;
    box-shadow: inset 0 -3px #ffffff;
}

#workspaces button.urgent {
    background-color: #eb4d4b;
}

#mode {
    background-color: #64727D;
    border-bottom: 3px solid #ffffff;
}

#clock,
#battery,
#cpu,
#memory,
#disk,
#temperature,
#backlight,
#network,
#pulseaudio,
#wireplumber,
#custom-weather,
#custom-pacman,
#custom-icon,
#custom-power,
#custom-media,
#tray,
#mode,
#idle_inhibitor,
#scratchpad,
#taskbar {
    border-radius: 8px 8px 8px 8px;
    padding: 0 3px;
    margin: 0 0px;
    color: #ffffff;
    background-color: rgba(120,118,117,0.3);
}
#taskbar button {
    border-radius: 3px 3px 3px 3px;
    padding: 0 0 0 3px;
    margin: 3px;
    color: #ffffff;
    background-color: rgba(120,118,117,0.1);
}
#taskbar button.active {
    background-color: rgba(120,118,117,0.8);
}

#mpd {
    padding: 0 10px;
    color: #ffffff;
}

#window,
#workspaces {
    margin: 0 4px;
}

/* If workspaces is the leftmost module, omit left margin */
.modules-left > widget:first-child > #workspaces {
    margin-left: 0;
}

/* If workspaces is the rightmost module, omit right margin */
.modules-right > widget:last-child > #workspaces {
    margin-right: 0;
}

#clock {
    background-color: #FF6347;
}

#battery {
    background-color: #ffffff;
    color: #000000;
}

#battery.charging, #battery.plugged {
    color: #ffffff;
    background-color: #26A65B;
}

@keyframes blink {
    to {
        background-color: #ffffff;
        color: #000000;
    }
}

#battery.critical:not(.charging) {
    background-color: #f53c3c;
    color: #ffffff;
    animation-name: blink;
    animation-duration: 0.5s;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
    animation-direction: alternate;
}

label:focus {
    background-color: #000000;
}

#cpu {
    background-color: #FD3F92;
    color: #ffffff;
}

#memory {
    background-color: #0080FF;
}

#disk {
    background-color: #FFA500;
}

#backlight {
    background-color: #90b1b1;
}

#network {
    background-color: #008000;
}

#network.disconnected {
    background-color: #f53c3c;
}

#pulseaudio {
    background-color: #BD33A4;
    color: #ffffff;
}

#pulseaudio.muted {
    background-color: #90b1b1;
    color: #2a5c45;
}

#wireplumber {
    background-color: #fff0f5;
    color: #000000;
}

#wireplumber.muted {
    background-color: #f53c3c;
}

#custom-media {
    background-color: #66cc99;
    color: #2a5c45;
    min-width: 100px;
}

#custom-media.custom-spotify {
    background-color: #66cc99;
}

#custom-media.custom-vlc {
    background-color: #ffa000;
}

#temperature {
    background-color: #16A085;
}

#temperature.critical {
    background-color: #eb4d4b;
}

#tray {
    background-color: #2980b9;
}

#tray > .passive {
    -gtk-icon-effect: dim;
}

#tray > .needs-attention {
    -gtk-icon-effect: highlight;
    background-color: #eb4d4b;
}

#idle_inhibitor {
    background-color: #2d3436;
}

#idle_inhibitor.activated {
    background-color: #ecf0f1;
    color: #2d3436;
}

#mpd {
    background-color: #66cc99;
    color: #2a5c45;
}

#mpd.disconnected {
    background-color: #f53c3c;
}

#mpd.stopped {
    background-color: #90b1b1;
}

#mpd.paused {
    background-color: #51a37a;
}

#language {
    background: #00b093;
    color: #740864;
    padding: 0 5px;
    margin: 0 5px;
    min-width: 16px;
}

#keyboard-state {
    background: #97e1ad;
    color: #000000;
    padding: 0 0px;
    margin: 0 5px;
    min-width: 16px;
}

#keyboard-state > label {
    padding: 0 5px;
}

#keyboard-state > label.locked {
    background: rgba(0, 0, 0, 0.2);
}

#custom-weather{
    background-color: #9400D3;
}

#custom-pacman {
    background-color: #00CCCC;
}

#custom-icon {
    background-color: #FF6347;
}

#custom-power {
    background-color: #FF0000;
}

#scratchpad {
    background: rgba(0, 0, 0, 0.2);
}

#scratchpad.empty {
	background-color: transparent;
}

20231221-161828-grim

1 Like

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.