6

is there any way to integrate a network selection menu(wifi) in polybar? I'm using i3 with polybar and this is the only thing missing in my setup. If you know any programs that can do this please share..

6 Answers 6

11

For other people reading this question, there is a way to make even the built-in modules clickable: you can achieve this using in-text format tags.

~/.config/polybar/config:

;  (...other stuff...)
[module/wlan]
;  (...other stuff...)
label-connected = %{A1:nm-connection-editor:}%essid%%{A}

Now nm-connection-editor will be run every time you click on the text.
You could do the same with label-disconnected or even format-prefix, or every one of ramp-signal-N if you want to be able to also click on the icon.

The syntax is %{A<button>:<command>:}text to make clickable%{A} where <button> is a digit from 1 to 5 standing for left/right/middle click or scroll up/down respectively. (Spaces are allowed in the command, colons must be escaped with \:)

2
  • how would map to different clicks e.g. left and right click?
    – Jamie-505
    Commented Jan 11, 2019 at 7:59
  • %{A1:<command>:A2:<another cmd>} and %{A1:<command>:}%{A2:<another cmd>:} both dont work
    – Jamie-505
    Commented Jan 11, 2019 at 8:04
1

Welcome to StackExchange!

Polybar doesn't have this functionality built-in.

It is possible to realize this with a script module, by writing your own script that does this.

I am not aware of any scripts already being available for this. At first glance this would be quite cumbersome though, as it's not that straight forward to create a script with that much interaction for polybar. It can be done of course.

A way less cumbersome alternative would be to have an icon on the bar which launches your network manager's built-in GUI tool to select the network if you click on it. I believe for NetworkManager that tool is called nm-connection-editor, so for example your module could look like this:

[module/nm-launcher]
type = custom/text
content = YOUR ICON HERE
click-left = nm-connection-editor

Replace nm-connection-editor with whatever the command for your network manager is called.

Source: I maintain polybar.

3
  • I added wicd applet in the bar to realize this. clicking the icon opens up wicd and from there i can choose networks.
    – Zquest
    Commented Sep 17, 2018 at 10:09
  • That's another way to do it. The tray has some fundamental issues so I'm not actively promoting using the tray to solve problems. Commented Sep 17, 2018 at 23:01
  • yeah sometimes wicd does not detect wireless access points at all. first i thought it might be because of network manager applet and wicd applet conflict but its nothing like that and it worked fine in mate and also in i3 after a couple of reboots.
    – Zquest
    Commented Sep 18, 2018 at 10:53
1

You can use the nm-applet package that comes with NetworkManager. Just do a

sudo apt-get install network-manager nm-applet

to install the packages. Then run nm-applet in your terminal. This provides a small icon in your system tray that basically functions as a Wi-Fi menu.

You might get an error that says your NetworkManager service isn't enabled or needs a restart, in that case run sudo service network-manager restart and then try again.

1

Sorry to bring up an old thread, but after a hour of Googling I couldn't find any suitable answer for my use case, so I experimented until I found something that works.

I'm using i3wm with polybar.

To get a WiFi menu (connect, add, modify connections), open up the polybar config file:
gedit ~/.config/polybar/config

Do a search for module/wan

replace the entire line 'label-connected = %essid%' with

label-connected = %{A1:gnome-terminal -e nmtui &:} %essid%%{A}

Uncomment all the lines beginning with format-disconnected and label-disconnected (remove the colon) replace the line 'label-disconnected = disconnected' with

label-connected = %{A1:gnome-terminal -e nmtui &:} %essid%%{A}

save the config file and restart polybar. now when you click on the wifi name on polybar you can modify wifi and ethernet connections.

This fix isn't by any means pretty, but it works well for me.

0

One can either use an icon as Patrick Ziegler said or you can use network manager applet like i am using. Add the following to your i3 config. "exec wicd-gtk -t" Note: you need to install wicd if you do not have it already or you can use applet of whatever network manager you use. I believe it should be considered solved now.

0
0

Add the following configuration in your polybar bar configuration:

[bar/bar]
 tray-position = right 
 tray-padding = 2 
 tray-transparent = true
 true tray-background = #0063ff

then, start the applets as you want (Personally I use both blueman-applet and nm-applet), they should appear at the right (or left, if you configured) of your bar.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .