Just some personal Waybar modules written in GO. Just to learn some GO.
Currently you can use make
to build, the binary will be in the build
folder.
A Waybar "module" to display number of merge requests the user has to review
It needs a Gitlab personal access token with api read only access. It needs to be set using the GITLAB_TOKEN
environment variable.
You can control how often it will poll the Gitlab API, by default it will poll every 60
seconds. Use the CLI option -interval X
to change.
The command will output JSON that Waybar can use to update a module. The fields outputted are:
- text - the number of merge requests found, 0 or more.
- tooltip - outputs merge request titles separated with linefeed.
- class - For usage in
style.css
, outputsnone
orfound
depending on if there is a merge request or not. - alt - use this to pick an icon using
format-icons
Add this to your Waybar configuration file, usually ~/.config/waybar/config
:
"custom/gitlab": {
"format": "{} {icon}",
"return-type": "json",
"format-icons": {
"found": "",
"none": ""
},
"exec-if": "which waybar-gitlab-mr",
"exec": "GITLAB_TOKEN=<token-with-read-api> waybar-gitlab-mr"
}
Here is an example of how to style it using the ~/.config/waybar/style.css
file, remember that class
outputted in the JSON from the command will have none
or found
set so you can use that here. You can also just skip the class part of the style, and just have one block.
#custom-gitlab.none {
margin-top: 6px;
margin-left: 8px;
padding-left: 10px;
margin-bottom: 0px;
padding-right: 10px;
border-radius: 10px;
transition: none;
color: #514112;
background: #d4ab30;
}
#custom-gitlab.found {
margin-top: 6px;
margin-left: 8px;
padding-left: 10px;
margin-bottom: 0px;
padding-right: 10px;
border-radius: 10px;
transition: none;
color: #78611a;
background: #fecf48;
}