[waybar] Move config

This commit is contained in:
Tibo De Peuter 2023-11-14 22:33:03 +01:00
parent 7dda8086d4
commit 65ef0adf6d
11 changed files with 188 additions and 174 deletions

View file

@ -0,0 +1,41 @@
//
// ~/.config/waybar/config
//
[{
"name": "toggle",
"mode": "hide",
"ipc": true,
"position": "top",
"height": 25,
"spacing": 4,
"margin": "-25px 0 0 0", // Show this bar on top of the other one, seemingly the "same" one.
"custom/sep": {
"format": "\uf142"
},
"include": [
// Import modules (!)
"~/.config/waybar/modules.json",
// "~/.config/waybar/default.json"
"~/.config/waybar/left.json"
],
},
{
"name": "keep",
"position": "top",
"height": 25,
"modules-left": ["sway/mode"],
"modules-center": ["clock"],
"include": [
// Import modules (!)
"~/.config/waybar/modules.json"
],
}]

View file

@ -0,0 +1,23 @@
{
"modules-left": [
"idle_inhibitor",
"custom/media"
],
"modules-center": [
"sway/workspaces"
],
"modules-right": [
"disk",
"memory",
"cpu",
"temperature",
"custom/sep",
"bluetooth",
"network",
"pulseaudio",
"battery",
"custom/sep",
"tray"
]
}

View file

@ -0,0 +1,22 @@
{
"modules-left": [
"sway/workspaces",
"idle_inhibitor",
"custom/light-dark-toggle",
"custom/night-light-toggle",
"custom/toggle-notifications",
"custom/media"
],
"modules-right": [
"memory",
"cpu",
"temperature",
"custom/sep",
"bluetooth",
"network",
"pulseaudio",
"battery",
"custom/sep",
"tray"
]
}

View file

@ -0,0 +1,131 @@
#!/usr/bin/env python3
# From:
# https://github.com/Alexays/Waybar/blob/master/resources/custom_modules/mediaplayer.py
import argparse
import logging
import sys
import signal
import gi
import json
gi.require_version('Playerctl', '2.0')
from gi.repository import Playerctl, GLib
logger = logging.getLogger(__name__)
def write_output(text, player):
logger.info('Writing output')
output = {'text': text,
'class': 'custom-' + player.props.player_name,
'alt': player.props.player_name}
sys.stdout.write(json.dumps(output) + '\n')
sys.stdout.flush()
def on_play(player, status, manager):
logger.info('Received new playback status')
on_metadata(player, player.props.metadata, manager)
def on_metadata(player, metadata, manager):
logger.info('Received new metadata')
track_info = ''
if player.props.player_name == 'spotify' and \
'mpris:trackid' in metadata.keys() and \
':ad:' in player.props.metadata['mpris:trackid']:
track_info = 'AD PLAYING'
elif player.get_artist() != '' and player.get_title() != '':
track_info = '{artist} - {title}'.format(artist=player.get_artist(),
title=player.get_title())
else:
track_info = player.get_title()
if player.props.status != 'Playing' and track_info:
track_info = '' + track_info
write_output(track_info, player)
def on_player_appeared(manager, player, selected_player=None):
if player is not None and (selected_player is None or player.name == selected_player):
init_player(manager, player)
else:
logger.debug("New player appeared, but it's not the selected player, skipping")
def on_player_vanished(manager, player):
logger.info('Player has vanished')
sys.stdout.write('\n')
sys.stdout.flush()
def init_player(manager, name):
logger.debug('Initialize player: {player}'.format(player=name.name))
player = Playerctl.Player.new_from_name(name)
player.connect('playback-status', on_play, manager)
player.connect('metadata', on_metadata, manager)
manager.manage_player(player)
on_metadata(player, player.props.metadata, manager)
def signal_handler(sig, frame):
logger.debug('Received signal to stop, exiting')
sys.stdout.write('\n')
sys.stdout.flush()
# loop.quit()
sys.exit(0)
def parse_arguments():
parser = argparse.ArgumentParser()
# Increase verbosity with every occurrence of -v
parser.add_argument('-v', '--verbose', action='count', default=0)
# Define for which player we're listening
parser.add_argument('--player')
return parser.parse_args()
def main():
arguments = parse_arguments()
# Initialize logging
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG,
format='%(name)s %(levelname)s %(message)s')
# Logging is set by default to WARN and higher.
# With every occurrence of -v it's lowered by one
logger.setLevel(max((3 - arguments.verbose) * 10, 0))
# Log the sent command line arguments
logger.debug('Arguments received {}'.format(vars(arguments)))
manager = Playerctl.PlayerManager()
loop = GLib.MainLoop()
manager.connect('name-appeared', lambda *args: on_player_appeared(*args, arguments.player))
manager.connect('player-vanished', on_player_vanished)
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
for player in manager.props.player_names:
if arguments.player is not None and arguments.player != player.name:
logger.debug('{player} is not the filtered player, skipping it'
.format(player=player.name)
)
continue
init_player(manager, player)
loop.run()
if __name__ == '__main__':
main()

View file

@ -0,0 +1,162 @@
{
"battery": {
"format": "{capacity}% {icon}",
"format-alt": "{time} {icon}",
"format-charging": "{capacity}% \uf0e7 {icon}",
"format-icons": ["\uf244", "\uf243", "\uf242", "\uf241", "\uf240"],
"format-plugged": "{capacity}% \ue55c",
"states": {
"warning": 30,
"critical": 15
}
},
"disk": {
"interval": 30,
"format": "{percentage_used}% \uf0a0",
"on-click": "kitty -e duf /",
"path": "/",
"tooltip-format": "{used} used out of {total} on {path} ({percentage_free}% or {free} free)"
},
"bluetooth": {
"format-disabled": "<big>\uf294</big>",
"format-off": "\uf294",
"format-on": "<big>\uf294</big>",
"format-connected": "<big>\uf294</big>c",
"max-length": 10.3,
"on-click": "bluetoothctl power $( bluetoothctl show | sed -n 's/\\s*Powered: \\(yes\\|no\\)/\\1/p' | sed 's/yes/off/;s/no/on/' )",
"on-click-right": "kitty -e bluetoothctl",
"tooltip-format": "{status}",
"tooltip-format-on": "{status}, no devices connected",
"tooltip-format-connected": "{status} ({num_connections}):\n{device_enumerate}",
"tooltip-format-enumerate-connected": "{device_alias} ({device_address})",
"tooltip-format-enumerate-connected-battery": "{device_alias}\t{device_address}\t{device_battery_percentage}"
},
"clock": {
"format": "{:%H:%M}",
"format-alt": "{:%d/%m/%Y %H:%M}",
"timezone": "Europe/Brussels",
"tooltip-format": "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>"
},
"custom/browser": {
"format": "\uf120",
"on-click": "dmenu_run",
"tooltip-format": "Launch an application"
},
"custom/media": {
"escape": true,
"exec": "~/.config/waybar/mediaplayer.py 2> /dev/null",
"format": "{icon} {}",
"format-icons": {
"default": "\uf51f",
"spotify": "\uf1bc"
},
"max-length": 40,
"on-click": "playerctl play-pause",
"return-type": "json"
},
"custom/light-dark-toggle": {
"on-click": "bash ${SCRIPT_DIR}/toggle-light-dark.sh",
"tooltip-format": "Toggle between light and dark mode",
"format": "\uf042 ",
"tooltip": true
},
"custom/night-light-toggle": {
"on-click": "bash ${SCRIPT_DIR}/sunset.sh",
"tooltip-format": "Toggle night-light on or off",
"format": "\uf0eb ",
"tooltip": true
},
"custom/toggle-notifications": {
"on-click": "bash ${SCRIPT_DIR}/do-not-disturb.sh",
"tooltip-format": "Toggle notifications",
"format": "\uf1f6 ",
"tooltip": true
},
"cpu": {
"format": "{usage}% \uf2db",
"on-click": "kitty -e htop",
"tooltip": true
},
"idle_inhibitor": {
"format": "{icon}",
"format-icons": {
"activated": "\uf06e",
"deactivated": "\uf070"
},
"tooltip": false
},
"memory": {
"format": "{}% \uf1c0",
"on-click": "kitty -e zenith"
},
"network": {
"format-disconnected": "\uf127",
"format-ethernet": "\uf6ff {ifname}: {ipadds}/{cidr}",
"format-wifi": "\uf1eb",
"interval": 5,
"on-click-right": "kitty -e nmtui",
"tooltip-format": "{ifname}: {ipaddr}",
"tooltip-format-disconnected": "Disconnected",
"tooltip-format-wifi": "{essid} ({signalStrength}%)\n{ifname}: {ipaddr}"
},
"sway/window": {
"max-length": 85
},
"sway/workspaces": {
"all-outputs": false,
"disable-scroll": true,
"format": "{icon}{name}",
"format-icons": {
"default": "", // Prevent showing workspace name literal.
"urgent": "\uf071 "
},
// "persistent_workspaces": {
// "0:¯\\_(ツ)_/¯": []
// }
},
"pulseaudio": {
"format": "{volume}% {icon}{format_source}",
"format-muted": "\uf6a9{format_source}",
"format-bluetooth": "{volume}% {icon}\uf294{format_source}",
"format-bluetooth-muted": "\uf6a9 {icon}\uf294{format_source}",
"format-source": " {volume}% \uf130",
"format-source-muted": "",
"format-icons": {
"headphone": "\uf58f",
"hands-free": "\uf590",
"headset": "\uf590",
"phone": "\uf3ce",
"portable": "\uf3ce",
"car": "\uf1b9",
"default": ["\uf026", "\uf027", "\uf028 "]
},
"on-click": "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle",
"on-click-right": "pavucontrol",
"scroll-step": 2
},
"temperature": {
"critical-threshold": 70,
"format": "{temperatureC}°C {icon}",
"format-icons": ["\uf2cb", "\uf2c9", "\uf2c7"]
},
"tray": {
"spacing": 10
}
}

View file

@ -0,0 +1,50 @@
/*
* ~/.config/waybar/round.css
*
* This stylesheet has round modules and titles.
*/
window#waybar {
color: @white;
background-color: transparent;
}
.modules-left {
background-color: @transparent-black;
border-radius: 0 20px 20px 0;
/* Coloured modules must hit the border! */
padding-right: 0;
}
.modules-center {
background-color: @transparent-black;
border-radius: 20px;
}
.keep .modules-center {
background-color: transparent;
padding: 0 10px;
}
.modules-right {
background-color: @transparent-black;
border-radius: 20px 0 0 20px;
padding-left: 10px;
}
#workspaces button {
border-radius: 20px;
}
#workspaces button:hover,
#workspaces button.focused {
background-color: @accent;
border-radius: 20px;
color: @white;
}
#custom-media {
border-radius: 0 20px 20px 0;
padding-right: 10px;
}

View file

@ -0,0 +1,23 @@
/*
* ~/.config/waybar/sharp.css
*
* This stylesheet is a take on a minimal layout.
*/
window#waybar {
color: @white;
background-color: transparent;
}
#mode,
.toggle .modules-left,
.toggle .modules-right {
background-color: @transparent-black;
}
#mode,
#workspaces button.focused,
#workspaces button:hover {
box-shadow: inset 0 2px #ffffff;
}

View file

@ -0,0 +1,138 @@
/*
* ~/.config/waybar/style.css
*
* `otf-font-awesome` is required to be installed for icons.
*
* Pick your stylesheet:
* - sharp.css
* - transparent.css
* - round.css
*/
@define-color transparent-black rgba(23, 23, 23, 0.9);
@define-color white #ecf0f1;
@define-color warning-red #eb4d4b;
@define-color accent #00897b;
window#waybar {
font-family: font-awesome, letter, monospace;
font-size: 13px;
-webkit-font-smoothing: antialiased;
transition-property: background-color;
transition-duration: .5s;
}
#window, #workspaces {
margin: 0 5px;
}
#workspaces button {
border: none;
border-radius: 0;
min-width: 30px;
padding: 0 5px;
}
#workspaces button.focused {
background-color: transparent;
color: @white;
}
#workspaces button:hover {
background-color: transparent;
color: @transparent-black;
}
#workspaces button.urgent {
color: @white;
background-color: @warning-red;
}
/* All modules individually. */
#backlight, #battery, #bluetooth, #clock, #cpu,
#custom-browser, #custom-media, #custom-light-dark-toggle, #custom-night-light-toggle, #custom-toggle-notifications,
#disk, #idle_inhibitor, #memory, #mode, #mpd, #network,
#pulseaudio, #temperature, #tray {
padding: 0 5px;
}
/* If workspaces is the leftmost module, omit left margin */
.modules-left > widget:first-child > #workspaces {
margin-left: 0;
}
/* If workspaces is the rightmost module, omit right margin */
.modules-right > widget:last-child > #workspaces {
margin-right: 0;
}
@keyframes blink {
to {
background-color: #ffffff;
color: #000000;
}
}
label:focus {
background-color: #000000;
}
/* Module specific colours */
#battery.charging, #battery.plugged {
color: #ffffff;
background-color: #26A65B;
}
#battery.critical:not(.charging) {
background-color: #f53c3c;
color: #ffffff;
animation-name: blink;
animation-duration: 0.5s;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
#bluetooth.disabled,
#bluetooth.off,
#network.disconnected,
#pulseaudio.muted {
opacity: 0.6;
}
#custom-media {
color: #2a5c45;
background-color: #66cc99;
min-width: 100px;
}
#custom-media.custom-spotify {
background-color: #66cc99;
}
#custom-media.custom-vlc {
background-color: #ffa000;
}
#temperature.critical {
background-color: #eb4d4b;
}
#custom_light-dark-toggle.activated,
#idle_inhibitor.activated {
background-color: #ecf0f1;
color: #2d3436;
}
#tray > .passive {
-gtk-icon-effect: dim;
}
#tray > .needs-attention {
-gtk-icon-effect: highlight;
background-color: #eb4d4b;
}
@import "sharp.css";

View file

@ -0,0 +1,24 @@
/*
* ~/.config/waybar/transparent.css
*
* This stylesheet is a minimalistic, transparent style.
*/
@define-color transparent-black-light rgba(23, 23, 23, 0.7);
window#waybar {
color: @white;
background-color: transparent;
}
.toggle .modules-right,
.toggle .modules-left {
background-color: @transparent-black-light;
}
#workspaces button:hover,
#workspaces button.focused,
#mode {
box-shadow: inset 0 2px #ffffff;
}