First commit
This commit is contained in:
commit
1808168211
7 changed files with 396 additions and 0 deletions
37
README.md
Normal file
37
README.md
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
Waybar Ansible Role
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
Install and configure [Waybar](https://github.com/Alexays/Waybar/)
|
||||||
|
|
||||||
|
|
||||||
|
## Variables
|
||||||
|
|
||||||
|
You can define 2 variables for this role
|
||||||
|
|
||||||
|
`waybar_option` represent the Waybar configuration file in `yaml` format. The
|
||||||
|
default values give you the provided configuration given on the Waybar
|
||||||
|
repository.
|
||||||
|
|
||||||
|
`waybar_style` is a list of element to render `style.css` template provide in
|
||||||
|
this role. Here is the defaut values:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
waybar_style:
|
||||||
|
colors:
|
||||||
|
bg: '#323232'
|
||||||
|
fg: '#ddd'
|
||||||
|
hover: '#f268b3'
|
||||||
|
selected: '#1cd180'
|
||||||
|
ok: '#1cd180'
|
||||||
|
warning: '#f2b768'
|
||||||
|
critical: '#f268b3'
|
||||||
|
fonts:
|
||||||
|
bar:
|
||||||
|
family: 'Fira Code Nerd Font'
|
||||||
|
size: '12px'
|
||||||
|
tray:
|
||||||
|
family: 'DejaVu sans'
|
||||||
|
size: '12px'
|
||||||
|
```
|
||||||
|
|
||||||
|
I choose to provide a custom `style.css` template for my need.
|
166
defaults/main.yml
Normal file
166
defaults/main.yml
Normal file
|
@ -0,0 +1,166 @@
|
||||||
|
---
|
||||||
|
waybar_options:
|
||||||
|
height: 3
|
||||||
|
spacing: 4
|
||||||
|
modules-left:
|
||||||
|
- "sway/workspaces"
|
||||||
|
- "sway/mode"
|
||||||
|
- "sway/scratchpad"
|
||||||
|
- "custom/media"
|
||||||
|
modules-center:
|
||||||
|
- "sway/window"
|
||||||
|
modules-right:
|
||||||
|
- "mpd"
|
||||||
|
- "idle_inhibitor"
|
||||||
|
- "pulseaudio"
|
||||||
|
- "network"
|
||||||
|
- "cpu"
|
||||||
|
- "memory"
|
||||||
|
- "temperature"
|
||||||
|
- "backlight"
|
||||||
|
- "keyboard-state"
|
||||||
|
- "sway/language"
|
||||||
|
- "battery"
|
||||||
|
- "battery#bat2"
|
||||||
|
- "clock"
|
||||||
|
- "tray"
|
||||||
|
keyboard-state:
|
||||||
|
numlock: true
|
||||||
|
capslock: true
|
||||||
|
format: "{name} {icon}"
|
||||||
|
format-icons:
|
||||||
|
locked: ""
|
||||||
|
unlocked: ""
|
||||||
|
sway/mode:
|
||||||
|
format: "<span style=\"italic\">{}</span>"
|
||||||
|
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:
|
||||||
|
spacing: 10
|
||||||
|
clock:
|
||||||
|
tooltip-format: "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>"
|
||||||
|
format-alt: "{:%Y-%m-%d}"
|
||||||
|
cpu:
|
||||||
|
format: "{usage}% "
|
||||||
|
tooltip: false
|
||||||
|
memory:
|
||||||
|
format: "{}% "
|
||||||
|
temperature:
|
||||||
|
critical-threshold: 80
|
||||||
|
format: "{temperatureC}°C {icon}"
|
||||||
|
format-icons:
|
||||||
|
- ""
|
||||||
|
- ""
|
||||||
|
- ""
|
||||||
|
backlight:
|
||||||
|
format: "{percent}% {icon}"
|
||||||
|
format-icons:
|
||||||
|
- ""
|
||||||
|
- ""
|
||||||
|
- ""
|
||||||
|
- ""
|
||||||
|
- ""
|
||||||
|
- ""
|
||||||
|
- ""
|
||||||
|
- ""
|
||||||
|
- ""
|
||||||
|
battery:
|
||||||
|
states:
|
||||||
|
warning: 30
|
||||||
|
critical: 15
|
||||||
|
format: "{capacity}% {icon}"
|
||||||
|
format-charging: "{capacity}% "
|
||||||
|
format-plugged: "{capacity}% "
|
||||||
|
format-alt: "{time} {icon}"
|
||||||
|
format-icons:
|
||||||
|
- ""
|
||||||
|
- ""
|
||||||
|
- ""
|
||||||
|
- ""
|
||||||
|
- ""
|
||||||
|
battery#bat2:
|
||||||
|
bat: "BAT2"
|
||||||
|
network:
|
||||||
|
format-wifi: "{essid} ({signalStrength}%) "
|
||||||
|
format-ethernet: "{ipaddr}/{cidr} "
|
||||||
|
tooltip-format: "{ifname} via {gwaddr} "
|
||||||
|
format-linked: "{ifname} (No IP) "
|
||||||
|
format-disconnected: "Disconnected ⚠"
|
||||||
|
format-alt: "{ifname}: {ipaddr}/{cidr}"
|
||||||
|
pulseaudio:
|
||||||
|
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"
|
||||||
|
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"
|
||||||
|
|
||||||
|
waybar_style:
|
||||||
|
colors:
|
||||||
|
bg: '#323232'
|
||||||
|
fg: '#ddd'
|
||||||
|
hover: '#f268b3'
|
||||||
|
selected: '#1cd180'
|
||||||
|
ok: '#1cd180'
|
||||||
|
warning: '#f2b768'
|
||||||
|
critical: '#f268b3'
|
||||||
|
fonts:
|
||||||
|
bar:
|
||||||
|
family: 'Fira Code Nerd Font'
|
||||||
|
size: '12px'
|
||||||
|
tray:
|
||||||
|
family: 'DejaVu sans'
|
||||||
|
size: '12px'
|
||||||
|
|
14
files/waybar.service
Normal file
14
files/waybar.service
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Highly customizable Wayland bar for Sway and Wlroots based compositors.
|
||||||
|
Documentation=https://github.com/Alexays/Waybar/wiki/
|
||||||
|
PartOf=graphical-session.target
|
||||||
|
After=graphical-session.target
|
||||||
|
Requisite=sway-session.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/bin/waybar
|
||||||
|
ExecReload=kill -SIGUSR2 $MAINPID
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=sway-session.target
|
8
meta/main.yml
Normal file
8
meta/main.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
galaxy_info:
|
||||||
|
role_name: ansible_swaylock
|
||||||
|
author: ephase
|
||||||
|
description: install and configure Swaylock
|
||||||
|
issue_tracker_url: https://git.epha.se/ephase/ansible-swaylock
|
||||||
|
license: MIT
|
||||||
|
min_ansible_version: '1.4'
|
56
tasks/main.yml
Normal file
56
tasks/main.yml
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
---
|
||||||
|
- name: Install Waybar package
|
||||||
|
ansible.builtin.package:
|
||||||
|
name: waybar
|
||||||
|
state: present
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Create Waybar config dirs
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: '{{ ansible_user_dir ~ "/.config/waybar" }}'
|
||||||
|
state: directory
|
||||||
|
mode: 0750
|
||||||
|
owner: '{{ ansible_user_uid }}'
|
||||||
|
group: '{{ ansible_user_gid }}'
|
||||||
|
|
||||||
|
- name: Render templates for Waybar config file
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: '{{ item }}.j2'
|
||||||
|
dest: '{{ ansible_user_dir}}/.config/waybar/{{ item }}'
|
||||||
|
owner: '{{ ansible_user_uid }}'
|
||||||
|
group: '{{ ansible_user_gid }}'
|
||||||
|
lstrip_blocks: yes
|
||||||
|
trim_blocks: yes
|
||||||
|
mode: 0640
|
||||||
|
loop:
|
||||||
|
- config
|
||||||
|
- style.css
|
||||||
|
register: config_file
|
||||||
|
|
||||||
|
- name: copy Waybar systemd service file
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: 'waybar.service'
|
||||||
|
dest: '{{ ansible_user_dir }}/.config/systemd/user/'
|
||||||
|
mode: 0640
|
||||||
|
register: service_file
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: Reload Systemd daemon
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
scope: user
|
||||||
|
daemon-reload: true
|
||||||
|
|
||||||
|
- name: Enable Waybar service
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: 'waybar.service'
|
||||||
|
scope: user
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
when: service_file is changed and not ansible_check_mode
|
||||||
|
|
||||||
|
- name: Restart Waybar service
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: waybar.service
|
||||||
|
state: restarted
|
||||||
|
scope: user
|
||||||
|
when: config_file is changed and not service_file is changed
|
1
templates/config.j2
Normal file
1
templates/config.j2
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{{ waybar_options | to_nice_json(ensure_ascii=False) }}
|
114
templates/style.css.j2
Normal file
114
templates/style.css.j2
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
|
||||||
|
@define-color color-base-bg {{ waybar_style.colors.bg }};
|
||||||
|
@define-color color-base-fg {{ waybar_style.colors.fg }};
|
||||||
|
|
||||||
|
@define-color color-hover {{ waybar_style.colors.hover }};
|
||||||
|
@define-color color-selected {{ waybar_style.colors.selected }};
|
||||||
|
|
||||||
|
@define-color color-ok {{ waybar_style.colors.ok }};
|
||||||
|
@define-color color-warning {{ waybar_style.colors.warning }};
|
||||||
|
@define-color color-critical {{ waybar_style.colors.critical }};
|
||||||
|
|
||||||
|
* {
|
||||||
|
border: none;
|
||||||
|
border-radius: 0;
|
||||||
|
min-height:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
window#waybar {
|
||||||
|
background: @color-base-bg ;
|
||||||
|
color: @color-base-fg;
|
||||||
|
font-family: "{{ waybar_style.fonts.bar.family }}";
|
||||||
|
font-size: {{ waybar_style.fonts.bar.size }};
|
||||||
|
}
|
||||||
|
|
||||||
|
button,
|
||||||
|
button:disabled,label:disabled{
|
||||||
|
color:inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover{
|
||||||
|
background:none;
|
||||||
|
box-shadow:inherit;
|
||||||
|
box-shadow:inherit;
|
||||||
|
text-shadow:inherit;
|
||||||
|
text-shadow:inherit;
|
||||||
|
border-top:none;
|
||||||
|
}
|
||||||
|
#workspaces {
|
||||||
|
color:#fff;
|
||||||
|
}
|
||||||
|
#workspaces button {
|
||||||
|
margin:0 3px;
|
||||||
|
padding:4px 4px;
|
||||||
|
color:#9c9c9c;
|
||||||
|
border-bottom: 1px solid transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
#workspaces button:hover {
|
||||||
|
box-shadow:inherit;
|
||||||
|
text-shadow:inherit;
|
||||||
|
color: @color-hover;
|
||||||
|
border-bottom: 1px solid @color-hover;
|
||||||
|
}
|
||||||
|
|
||||||
|
#workspaces button.focused {
|
||||||
|
background:#1cd180 ;
|
||||||
|
color:#000;
|
||||||
|
}
|
||||||
|
#workspaces button.visible:not(.focused) {
|
||||||
|
color: @color-selected;
|
||||||
|
border-color: @color-selected;
|
||||||
|
}
|
||||||
|
|
||||||
|
#clock,
|
||||||
|
#cpu,
|
||||||
|
#memory,
|
||||||
|
#backlight,
|
||||||
|
#network,
|
||||||
|
#tray,
|
||||||
|
#mode,
|
||||||
|
#battery,
|
||||||
|
#idle_inhibitor {
|
||||||
|
padding: 2px 4px;
|
||||||
|
margin: 0;
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
#mode{
|
||||||
|
background:@color-warning;
|
||||||
|
font-weight:bold;
|
||||||
|
}
|
||||||
|
#pulseaudio {}
|
||||||
|
#pulseaudio.muted {
|
||||||
|
color:@color-critical;
|
||||||
|
}
|
||||||
|
|
||||||
|
#battery.discharging {
|
||||||
|
color: @color-base-fg;
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#battery.charging, #battery.plugged {
|
||||||
|
border-bottom: 1px solid @color-ok;
|
||||||
|
color: @color-selected;
|
||||||
|
}
|
||||||
|
|
||||||
|
#battery.critical:not(.charging),
|
||||||
|
#cpu.critical,
|
||||||
|
#memory.critical{
|
||||||
|
border-color: @color-critical;
|
||||||
|
color: @color-critical;
|
||||||
|
}
|
||||||
|
|
||||||
|
#battery.warning:not(.charging),
|
||||||
|
#cpu.warning,
|
||||||
|
#memory.warning{
|
||||||
|
border-color: @color-warning;
|
||||||
|
color: @color-warning;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tray {
|
||||||
|
font-family: "{{ waybar_style.fonts.tray.family }}";
|
||||||
|
font-size: {{ waybar_style.fonts.tray.size }};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue