feat(sway): major appearance upgrades

This commit is contained in:
Price Hiller 2022-08-08 16:42:11 -05:00
parent 9c9eff2a2d
commit 1923c320f5
7 changed files with 142 additions and 233 deletions

View File

@ -4,5 +4,4 @@ gaps outer 10
default_border pixel 2
default_floating_border pixel 2
set $wallpapers_path $HOME/.local/share/wallpapers
output * bg $wallpapers_path/Industrial-Shaded.png fill
output * bg ~/.local/share/wallpapers/TokyoNight.jpg fill

View File

@ -9,13 +9,12 @@
"battery",
"disk",
"pulseaudio",
"custom/cap-left"
"custom/media",
],
"modules-center": [
"sway/workspaces"
],
"modules-right": [
"custom/cap-right",
"custom/weather",
"network",
"clock",
@ -25,7 +24,7 @@
"custom/weather": {
"tooltip": false,
"min-length": 5,
"exec": "curl 'https://wttr.in/Melbourne?m&format='%t''",
"exec": "curl 'https://wttr.in/?format='%t''",
"interval": 3600
},
"battery": {
@ -54,7 +53,7 @@
]
},
"clock": {
"format": " {:%a %b %d %H:%M}",
"format": " {:%a %b %d %I:%M %p}",
"tooltip": false,
"min-length": 18
},
@ -110,9 +109,10 @@
"temperature": {
"tooltip": false,
"min-length": 6,
"thermal-zone": 1,
"critical-threshold": 90,
"format": "{icon} {temperatureC}°C",
"format-critical": "{icon} {temperatureC}°C",
"format": "{icon} {temperatureF}°F",
"format-critical": "{icon} {temperatureF}°F",
"format-icons": {
"default": [
"",
@ -143,14 +143,20 @@
},
"sway/workspaces": {
"tooltip": false,
"disable-scroll": true
"disable-scroll": true,
"persistent_workspaces": {
"1": [],
"2": [],
"3": [],
"4": [],
"5": [],
"6": []
}
},
"custom/cap-left": {
"tooltip": false,
"format": ""
"custom/media": {
"interval": 1,
"return-type": "json",
"exec": "~/.config/waybar/scripts/get-media.bash",
"escape": true
},
"custom/cap-right": {
"tooltip": false,
"format": ""
}
}

View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
main() {
local class
local text=""
class="$(playerctl metadata --format '{{lc(status)}}')"
local player_ctl_info="$(playerctl metadata --format '{{ artist }} | {{ title }} | {{ album }}')"
if [[ "${class}" == "playing" ]]; then
text="${player_ctl_info}"
elif [[ "${class}" == "paused" ]]; then
text="⏸︎ ${player_ctl_info}"
fi
printf '{"class": "%s", "text": "%s"}\n' "${class}" "${text}"
}
main

View File

@ -1,127 +0,0 @@
#!/usr/bin/env python3
from gi.repository import Playerctl, GLib
import argparse
import logging
import sys
import signal
import gi
import json
gi.require_version('Playerctl', '2.0')
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)
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

@ -1,140 +1,150 @@
/* --fujiWhite: #DCD7BA */
/* --oldWhite: #C8C093 */
/* --sumiInk0: #16161D */
/* --sumiInk1: #1F1F28 */
/* --sumiInk2: #2A2A37 */
/* --sumiInk3: #363646 */
/* --sumiInk4: #54546D */
/* --waveBlue1: #223249 */
/* --waveBlue2: #2D4F67 */
/* --winterGreen: #2B3328 */
/* --winterYellow: #49443C */
/* --winterRed: #43242B */
/* --winterBlue: #252535 */
/* --autumnGreen: #76946A */
/* --autumnRed: #C34043 */
/* --autumnYellow: #DCA561 */
/* --samuraiRed: #E82424 */
/* --roninYellow: #FF9E3B */
/* --waveAqua1: #6A9589 */
/* --dragonBlue: #658594 */
/* --fujiGray: #727169 */
/* --springViolet1: #938AA9 */
/* --oniViolet: #957FB8 */
/* --crystalBlue: #7E9CD8 */
/* --springViolet2: #9CABCA */
/* --springBlue: #7FB4CA */
/* --lightBlue: #A3D4D5 */
/* --waveAqua2: #7AA89F */
/* --springGreen: #98BB6C */
/* --boatYellow1: #938056 */
/* --boatYellow2: #C0A36E */
/* --carpYellow: #E6C384 */
/* --sakuraPink: #D27E99 */
/* --waveRed: #E46876 */
/* --peachRed: #FF5D62 */
/* --surimiOrange: #FFA066 */
@define-color fujiWhite #DCD7BA;
@define-color oldWhite #C8C093;
@define-color sumiInk0 #16161D;
@define-color sumiInk1 #1F1F28;
@define-color sumiInk2 #2A2A37;
@define-color sumiInk3 #363646;
@define-color sumiInk4 #54546D;
@define-color waveBlue1 #223249;
@define-color waveBlue2 #2D4F67;
@define-color winterGreen #2B3328;
@define-color winterYellow #49443C;
@define-color winterRed #43242B;
@define-color winterBlue #252535;
@define-color autumnGreen #76946A;
@define-color autumnRed #C34043;
@define-color autumnYellow #DCA561;
@define-color samuraiRed #E82424;
@define-color roninYellow #FF9E3B;
@define-color waveAqua1 #6A9589;
@define-color dragonBlue #658594;
@define-color fujiGray #727169;
@define-color springViolet1 #938AA9;
@define-color oniViolet #957FB8;
@define-color crystalBlue #7E9CD8;
@define-color springViolet2 #9CABCA;
@define-color springBlue #7FB4CA;
@define-color lightBlue #A3D4D5;
@define-color waveAqua2 #7AA89F;
@define-color springGreen #98BB6C;
@define-color boatYellow1 #938056;
@define-color boatYellow2 #C0A36E;
@define-color carpYellow #E6C384;
@define-color sakuraPink #D27E99;
@define-color waveRed #E46876;
@define-color peachRed #FF5D62;
@define-color surimiOrange #FFA066;
/* waybar style.css */
@define-color bgcolor #16161D; /* background color */
@define-color fgcolor #DCD7BA; /* foreground color */
@define-color charging #07fb05; /* battery charging color */
@define-color plugged #acfcad; /* ac plugged color */
@define-color critical #ff0000; /* critical color */
@define-color warning #f3f809; /* warning color */
@define-color hover #94a6e3; /* mouse hover over workspace color */
/* Reset all styles */
* {
border: none;
border-radius: 0;
min-height: 0;
margin: 0;
padding: 0;
padding: 3px;
margin: 3px;
border-radius: 20px;
padding-left: 20px;
padding-right: 20px;
}
#waybar {
background: transparent;
font-family: JetBrainsMono;
font-size: medium;
color: @fgcolor;
color: @fujiWhite;
}
#custom-media {
background: @sumiInk0;
border-top: 2px solid @oniViolet;
border-left: 2px solid @oniViolet;
}
#workspaces {
background: @sumiInk0;
transition: none;
border-top: 2px solid @oniViolet;
border-left: 2px solid @oniViolet;
border-right: 2px solid @oniViolet;
}
#workspaces button {
padding-left: 10px;
padding-right: 10px;
color: @bgcolor;
transition: none;
margin: 0px;
color: @oniViolet;
background: transparent;
border-bottom: 2px solid @oniViolet;
border-radius: 0px;
}
#workspaces button.focused {
background: @bgcolor;
color: @fgcolor;
color: @springGreen;
border-bottom: 2px solid @springGreen;
border-radius: 0px;
}
#workspaces button:hover {
background: @hover;
color: @fgcolor;
transition: none;
box-shadow: inherit;
text-shadow: inherit;
}
#custom-cap-left,
#custom-cap-right {
color: @bgcolor;
font-size: 24px;
border-top: 0px;
border-bottom: 2px solid @peachRed;
color: @sakuraPink;
border-right: 0px;
border-left: 0px;
border-radius: 0px;
}
#idle_inhibitor {
background: @bgcolor;
padding-left: 20px;
padding-right: 10px;
}
#custom-offswitch {
background: @bgcolor;
padding-right: 20px;
padding-left: 10px;
margin-left: 0px;
background: @sumiInk0;
border-top: 2px solid @oniViolet;
border-left: 2px solid @oniViolet;
}
#network,
#custom-weather,
#clock,
#custom-offswitch {
background: @sumiInk0;
border-top: 2px solid @oniViolet;
border-right: 2px solid @oniViolet;
}
#cpu,
#temperature,
#memory,
#pulseaudio,
#disk,
#battery,
#clock,
#network {
background: @bgcolor;
#temperature,
#battery {
background: @sumiInk0;
padding-left: 10px;
padding-right: 10px;
border-top: 2px solid @oniViolet;
border-left: 2px solid @oniViolet;
}
#disk.critical {
color: @critical;
color: @samuraiRed;
}
#temperature.critical {
color: @critical;
color: @samuraiRed;
}
#cpu.critical {
color: @critical;
color: @samuraiRed;
}
#memory.critical {
color: @critical;
color: @samuraiRed;
}
@keyframes blink1 {
to {
color: @plugged;
color: @springGreen;
}
}
#battery.plugged {
background-color: @bgcolor;
background-color: @sumiInk0;
animation-name: blink1;
animation-duration: 0.5s;
animation-timing-function: linear;
@ -144,12 +154,12 @@
@keyframes blink2 {
to {
background-color: @charging;
background-color: @carpYellow;
}
}
#battery.charging {
/* background-color: @bgcolor; */
/* background-color: @sumiInk0; */
animation-name: blink2;
animation-duration: 2s;
animation-timing-function: ease-in-out;
@ -159,12 +169,12 @@
@keyframes blink3 {
to {
background-color: @warning;
background-color: @roninYellow;
}
}
#battery.warning:not(.charging) {
/* background-color: @bgcolor; */
/* background-color: @sumiInk0; */
animation-name: blink3;
animation-duration: 0.7s;
animation-timing-function: ease-in-out;
@ -174,12 +184,12 @@
@keyframes blink4 {
to {
background-color: @critical;
background-color: @samuraiRed;
}
}
#battery.critical:not(.charging) {
/* background-color: @bgcolor; */
/* background-color: @sumiInk0; */
animation-name: blink4;
animation-duration: 0.8s;
animation-timing-function: ease-in-out;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB