summaryrefslogtreecommitdiffstats
path: root/roles/waybar
diff options
context:
space:
mode:
authorAhmed Abdelhalim <[email protected]>2026-01-08 23:28:39 +0100
committerAhmed Abdelhalim <[email protected]>2026-01-08 23:28:39 +0100
commitcf444228b10a4398638d330f1394e846c85f2abb (patch)
tree81df75d6b2b03e57ce0fc4934ef396e40ae61e7c /roles/waybar
parent636353ce0e02db63dce14ea6be45da951db289b0 (diff)
Add waybar initial role with dependencies and configuration in hyprland
Diffstat (limited to 'roles/waybar')
-rw-r--r--roles/waybar/meta/argument_specs.yml6
-rw-r--r--roles/waybar/meta/main.yml17
-rw-r--r--roles/waybar/tasks/main.yml45
-rw-r--r--roles/waybar/templates/waybar/config.jsonc.j2115
-rw-r--r--roles/waybar/templates/waybar/scripts/kb-layout-cycle8
-rw-r--r--roles/waybar/templates/waybar/scripts/launch-tui3
-rw-r--r--roles/waybar/templates/waybar/scripts/toggle-bt11
-rw-r--r--roles/waybar/templates/waybar/scripts/toggle-wifi11
-rw-r--r--roles/waybar/templates/waybar/style.css.j2115
9 files changed, 331 insertions, 0 deletions
diff --git a/roles/waybar/meta/argument_specs.yml b/roles/waybar/meta/argument_specs.yml
new file mode 100644
index 00000000..0bed67bb
--- /dev/null
+++ b/roles/waybar/meta/argument_specs.yml
@@ -0,0 +1,6 @@
+---
+argument_specs:
+ main:
+ short_description: "Install waybar on ArchLinux"
+ description: "Install waybar on Linux distribution"
+ options: {}
diff --git a/roles/waybar/meta/main.yml b/roles/waybar/meta/main.yml
new file mode 100644
index 00000000..a17e7049
--- /dev/null
+++ b/roles/waybar/meta/main.yml
@@ -0,0 +1,17 @@
+---
+dependencies:
+ - role: "fonts"
+ - role: "alacritty"
+ - role: "btop"
+ - role: "bluetui"
+ - role: "wlctl"
+ - role: "wiremix"
+galaxy_info:
+ author: "a14m"
+ description: "Install waybar"
+ license: "MIT"
+ min_ansible_version: "2.18"
+ platforms:
+ - name: "ArchLinux"
+ versions:
+ - "all"
diff --git a/roles/waybar/tasks/main.yml b/roles/waybar/tasks/main.yml
new file mode 100644
index 00000000..079d5329
--- /dev/null
+++ b/roles/waybar/tasks/main.yml
@@ -0,0 +1,45 @@
+---
+- name: "Ensure waybar packages are installed"
+ become: true
+ ansible.builtin.package:
+ name:
+ - "{{ item }}"
+ state: "present"
+ loop:
+ - "waybar"
+
+- name: "Ensure waybar configuration directory exists"
+ become: true
+ ansible.builtin.file:
+ path: "{{ item }}"
+ state: "directory"
+ mode: "0755"
+ loop:
+ - "/etc/xdg/waybar"
+ - "/etc/xdg/waybar/scripts"
+
+- name: "Configure waybar defaults"
+ become: true
+ ansible.builtin.template:
+ src: "{{ item.src }}"
+ dest: "{{ item.dest }}"
+ mode: "{{ item.mode }}"
+ loop:
+ - src: "waybar/config.jsonc.j2"
+ dest: "/etc/xdg/waybar/config.jsonc"
+ mode: "0644"
+ - src: "waybar/style.css.j2"
+ dest: "/etc/xdg/waybar/style.css"
+ mode: "0644"
+ - src: "waybar/scripts/toggle-bt"
+ dest: "/etc/xdg/waybar/scripts/toggle-bt"
+ mode: "0755"
+ - src: "waybar/scripts/toggle-wifi"
+ dest: "/etc/xdg/waybar/scripts/toggle-wifi"
+ mode: "0755"
+ - src: "waybar/scripts/launch-tui"
+ dest: "/etc/xdg/waybar/scripts/launch-tui"
+ mode: "0755"
+ - src: "waybar/scripts/kb-layout-cycle"
+ dest: "/etc/xdg/waybar/scripts/kb-layout-cycle"
+ mode: "0755"
diff --git a/roles/waybar/templates/waybar/config.jsonc.j2 b/roles/waybar/templates/waybar/config.jsonc.j2
new file mode 100644
index 00000000..bf65a09e
--- /dev/null
+++ b/roles/waybar/templates/waybar/config.jsonc.j2
@@ -0,0 +1,115 @@
+/* vim: set filetype=jsonc : */
+{
+ "reload_style_on_change": true,
+ "layer": "top",
+ "position": "top",
+ "spacing": 0,
+ "height": 30,
+ "margin-left": 10,
+ "margin-right": 10,
+ "margin-top": 5,
+ "margin-bottom": 0,
+ "modules-left": ["hyprland/workspaces"],
+ "modules-center": ["clock"],
+ "modules-right": [
+ "network",
+ "bluetooth",
+ "pulseaudio",
+ "backlight",
+ "hyprland/language",
+ "cpu",
+ "battery"
+ ],
+ "hyprland/workspaces": {
+ "on-click": "activate",
+ "format": "{icon}",
+ "format-icons": {
+ // "1": "1",
+ // "2": "2",
+ // "3": "3",
+ // "4": "4",
+ "default": "",
+ "active": ""
+ },
+ "persistent-workspaces": {
+ "1": [],
+ "2": [],
+ "3": [],
+ "4": []
+ }
+ },
+ "clock": {
+ "format": "{:L%a %b %d - %H:%M}",
+ "format-alt": "{:L%A %d %B %Y (W%V) - %H:%M}",
+ "tooltip": false
+ },
+ "network": {
+ "format-icons": ["󰤯", "󰤟", "󰤢", "󰤥", "󰤨"],
+ "format": "{icon}",
+ "format-wifi": "{icon}",
+ "format-ethernet": "󰀂",
+ "format-disconnected": "󰤮",
+ "tooltip-format-wifi": "{essid} ({frequency} GHz)\n⇣{bandwidthDownBytes} ⇡{bandwidthUpBytes}",
+ "tooltip-format-ethernet": "⇣{bandwidthDownBytes} ⇡{bandwidthUpBytes}",
+ "tooltip-format-disconnected": "Disconnected",
+ "interval": 5,
+ "spacing": 1,
+ "on-click": "/etc/xdg/waybar/scripts/toggle-wifi",
+ "on-click-right": "/etc/xdg/waybar/scripts/launch-tui wlctl"
+ },
+ "bluetooth": {
+ "format-on": "󰂯",
+ "format-off": "󰂲",
+ "format-disabled": "󰂲",
+ "format-connected": "󰂴",
+ "format-no-controller": "",
+ "tooltip-format-connected": "Devices connected: {num_connections}\n{device_enumerate}",
+ "tooltip-format-enumerate-connected": "- {device_alias}\t{device_battery_percentage}% 󰂁",
+ "on-click": "/etc/xdg/waybar/scripts/toggle-bt",
+ "on-click-right": "/etc/xdg/waybar/scripts/launch-tui bluetui"
+ },
+ "pulseaudio": {
+ "format": "{icon}",
+ "tooltip-format": "Volume: {volume}% {icon}",
+ "scroll-step": 5,
+ "format-muted": "",
+ "format-icons": {
+ "default": ["", "", ""]
+ },
+ "on-click": "pamixer -t",
+ "on-click-right": "/etc/xdg/waybar/scripts/launch-tui wiremix"
+ },
+ "backlight": {
+ "device": "intel_backlight",
+ "format": "{icon}",
+ "tooltip-format": "Brightness: {percent}% {icon}",
+ "format-icons": ["", ""]
+ },
+ "hyprland/language": {
+ "format": "{shortDescription}",
+ "on-click": "/etc/xdg/waybar/scripts/kb-layout-cycle"
+ },
+ "cpu": {
+ "interval": 5,
+ "format": "󰍛",
+ "on-click": "/etc/xdg/waybar/scripts/launch-tui btop"
+ },
+ "battery": {
+ "format": "{capacity}% {icon}",
+ "format-discharging": "{icon}",
+ "format-charging": "{icon}",
+ "format-plugged": "",
+ "format-icons": {
+ "charging": ["󰢜", "󰂆", "󰂇", "󰂈", "󰢝", "󰂉", "󰢞", "󰂊", "󰂋", "󰂅"],
+ "default": ["󰁺", "󰁻", "󰁼", "󰁽", "󰁾", "󰁿", "󰂀", "󰂁", "󰂂", "󰁹"]
+ },
+ "format-full": "󰂅",
+ "tooltip-format-discharging": "{power:>1.0f}W↓ {capacity}%",
+ "tooltip-format-charging": "{power:>1.0f}W↑ {capacity}%",
+ "interval": 5,
+ "states": {
+ "warning": 20,
+ "critical": 10
+ }
+ }
+}
diff --git a/roles/waybar/templates/waybar/scripts/kb-layout-cycle b/roles/waybar/templates/waybar/scripts/kb-layout-cycle
new file mode 100644
index 00000000..45cb8464
--- /dev/null
+++ b/roles/waybar/templates/waybar/scripts/kb-layout-cycle
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# This works on laptops but not sure if on desktops it will have the same name
+# That's why switching all the keyboards layout instead (which is safer)
+# exec hyprctl switchxkblayout at-translated-set-2-keyboard next
+exec hyprctl devices -j \
+ | jq -r '.keyboards[] | select (.name | endswith("keyboard")).name' \
+ | xargs -I {} hyprctl switchxkblayout {} next
diff --git a/roles/waybar/templates/waybar/scripts/launch-tui b/roles/waybar/templates/waybar/scripts/launch-tui
new file mode 100644
index 00000000..16efba9b
--- /dev/null
+++ b/roles/waybar/templates/waybar/scripts/launch-tui
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exec setsid uwsm-app -- alacritty --class="work.kartoffln.$(basename "$1")" -e "$@"
diff --git a/roles/waybar/templates/waybar/scripts/toggle-bt b/roles/waybar/templates/waybar/scripts/toggle-bt
new file mode 100644
index 00000000..1b9d4374
--- /dev/null
+++ b/roles/waybar/templates/waybar/scripts/toggle-bt
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+# Ensure bluetooth is unblocked
+rfkill unblock bluetooth
+
+# Better UI than rfkill toggle bluetooth
+if bluetoothctl show | grep -q "Powered: yes"; then
+ bluetoothctl power off
+else
+ bluetoothctl power on
+fi
diff --git a/roles/waybar/templates/waybar/scripts/toggle-wifi b/roles/waybar/templates/waybar/scripts/toggle-wifi
new file mode 100644
index 00000000..78e0699f
--- /dev/null
+++ b/roles/waybar/templates/waybar/scripts/toggle-wifi
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+# Ensure wifi is unblocked
+rfkill unblock wifi
+
+# Better UI than rfkill toggle wif
+if nmcli radio wifi | grep -q "enabled"; then
+ nmcli radio wifi off
+else
+ nmcli radio wifi on
+fi
diff --git a/roles/waybar/templates/waybar/style.css.j2 b/roles/waybar/templates/waybar/style.css.j2
new file mode 100644
index 00000000..ae633e91
--- /dev/null
+++ b/roles/waybar/templates/waybar/style.css.j2
@@ -0,0 +1,115 @@
+/* vim: set filetype=css : */
+@define-color activeColor rgb(64, 208, 255);
+@define-color inactiveColor rgb(124, 124, 124);
+@define-color background rgb(0, 0, 0);
+@define-color foreground rgb(124, 124, 124);
+
+* {
+ font-family: 'JetBrainsMono Nerd Font';
+ font-size: 14px;
+}
+
+@keyframes blink {
+ to {
+ color: @foreground;
+ }
+}
+
+
+#waybar {
+ all:unset;
+}
+
+window#waybar.hidden {
+ opacity: 0.2;
+}
+
+.modules-left {
+ color: @foreground;
+ padding: 5px 10px;
+ background: alpha(@background,.5);
+ border-radius: 50px;
+}
+.modules-center {
+ color: @foreground;
+ padding: 5px 10px;
+ background: alpha(@background,.5);
+ border-radius: 50px;
+}
+.modules-right {
+ color: @foreground;
+ padding: 5px 10px;
+ background: alpha(@background,.5);
+ border-radius: 50px;
+}
+
+tooltip {
+}
+
+#workspaces {
+ padding: 0px 0px;
+ color: @inactiveColor;
+}
+
+#workspaces button {
+ all:unset;
+ padding: 0px 5px;
+}
+
+#workspaces button.active {
+ border: none;
+ color: @activeColor;
+}
+
+#clock{
+ padding: 0px 5px;
+}
+
+#network,
+#bluetooth,
+#language,
+#battery,
+#cpu,
+#memory,
+#disk,
+#temprature,
+#backlight,
+#pulseaudio,
+#wireplumber {
+ padding: 0px 10px;
+ color: inherit;
+}
+
+#workspaces button:hover,
+#clock:hover,
+#network:hover,
+#bluetooth:hover,
+#language:hover,
+#battery:hover,
+#battery.charging:hover, #battery.plugged:hover, #battery.full:hover,
+#cpu:hover,
+#memory:hover,
+#disk:hover,
+#temprature:hover,
+#backlight:hover,
+#pulseaudio:hover,
+#wireplumber:hover {
+ color: #FFFFFF;
+}
+
+#battery.charging, #battery.plugged, #battery.full {
+ color: #32CD32;
+}
+
+#battery.warning:not(.charging) {
+ color: #F1C40F;
+}
+
+#battery.critical:not(.charging) {
+ color: #DC143C;
+ animation-name: blink;
+ animation-duration: 1s;
+ animation-timing-function: steps(2, end);
+ animation-iteration-count: infinite;
+ animation-direction: alternate;
+}