Skip to content

ConnerWithAnE/tailscale-waybar-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tailscale Waybar Module

A simple and sleek Waybar module for Tailscale that shows your current status, toggles on click and allows for quick and easy login when needed image

How it works

This module uses the tailscale cli commands to enable, disable and get the status of aspects of the tailnet. A custom icon is implemented via css and icon images stored in the icons sub directory.

Display Options

- Text

By default the module has text enabled and will display whether you are Connected, Disconnected or Logged Out*.

image image image

- Logos

It is also possible to disable the text and just have the logo, but then you only get the connected and disconnected indicators. (Except for the tooltip)

image image

- Tooltips

Depending on your status the tooltip will display different information.

Connected

The Tailnet IP will be shown

image

Disconnected

The current status is shown

image

Logged Out

A prompt informing the user to 'Click to Login' is shown (This only works if the tailscale set --operator is set, how to permentatnyl enable this is shown in the Configuration section below).

image

Interactions

Really there is only one type of interaction, left click. When a user is logged into Tailscale and clicks on the module their connection state will be toggled, if the user is logged out a browser window will be opened to perform the authentication. Once authentication is complete the module will automatically update to Connected.

The click to login function only works if tailscale set --operator=$USER is set or tailscale is configured to not need it, this is explain in the Configuration section below.

Requirements

Optional

  • A notifier agent

Installation

First ensure that you have all of the dependencies.

Next, to install the module either clone or download the repo to $HOME/.config/waybar/tailscale. You can also set the tailscale operator which will remove the sudo requirement.

sudo tailscale set --operator=$USER

This will need to be done each time you are logged out of tailscale, there is a way to avoid needing to do this and it is explained in the configuration section

Configuration

There are a few different areas which need to be configured all dependent how you want the module to function

Sudo Privileges

To enable the module to login on click Tailscale must be given the ability to run without sudo. This can be done by running

sudo tailscale set --operator=$USER

But this needs to be run EACH time the user is logged out. The module will not crash if this is not set but it will not complete the login. The user will be notified that the operation cannot be completed and the value can either be set and then the login attempted again or the login can be done manually.

The other option is to allow tailscale to execute sudo commands without a password. This can lower your overall system security but this is left up to your own discretion. To do this you need to edit /etc/sudoers. First ensure that you either have vi installed or you have a text editor (vim, nvim, nano) set (export EDITOR=vim).

Find where Tailscale is installed with

which tailscale

It is often installed at /usr/bin/tailscale

Next run sudo visudo to open the sudoers file. This can really be put anywhere but to keep things consistent find the 'User priviledge specification' section. Now enter a new rule

<your-user-name> ALL=(ALL) NOPASSWD: /usr/bin/tailscale

and save the file. Now when you click on the tailscale module to login, the current user will be set to the operator (if it is not already set).

Configuring the Module

The application comes with its own configuration file called config.json located at $HOME/.config/waybar/tailscale/config.json. The location can be altered by changing the config_file variable in tailscale.sh.

key Function
tailscale-up-flags This is a list of flags which will be used when a tailscale connection is made. By default the flag --accept-routes is set (just because this is something I need)
display-status-text This is boolean, if true Connected, Disconnected and Logged Out will be displayed alongside the logo

Adding to the Waybar Config

Finally the module needs to be added to the Waybar config.jsonc file. There is an example configuration provided in waybar-config-example.jsonc but it will also be shown below.

Edit the waybar/config.jsonc file and add the following to the bottom as a custom module

"custom/tailscale": {
  "format" : "{}",
  "return-type": "json",
  "on-click" : "$HOME/.config/waybar/tailscale/tailscale.sh toggle",
  "restart-interval": 0, // Set to 0 for faster updates
  "exec" : "$HOME/.config/waybar/tailscale/tailscale.sh status"
}

ensure it is named custom/tailscale as this is what the custom css looks for. The 'restart-interval` can be increased but it will of course cause there to be a delay when updating.

Now insert the module on the bar

"modules-right": [
  "custom/tailscale"
]

About

A sleek Waybar module for Tailscale. Alter your connection with flair.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published