fix: error with date in waybar
This commit is contained in:
parent
b9260488ed
commit
3334866bcb
14
.pnpm-debug.log
Normal file
14
.pnpm-debug.log
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"0 debug pnpm:scope": {
|
||||||
|
"selected": 1
|
||||||
|
},
|
||||||
|
"1 error pnpm": {
|
||||||
|
"code": "ERR_PNPM_NO_IMPORTER_MANIFEST_FOUND",
|
||||||
|
"err": {
|
||||||
|
"name": "pnpm",
|
||||||
|
"message": "No package.json (or package.yaml, or package.json5) was found in \"/home/jim/.dotfiles\".",
|
||||||
|
"code": "ERR_PNPM_NO_IMPORTER_MANIFEST_FOUND",
|
||||||
|
"stack": "pnpm: No package.json (or package.yaml, or package.json5) was found in \"/home/jim/.dotfiles\".\n at readProjectManifest (/home/jim/.asdf/installs/nodejs/16.11.0/pnpm-global/5/node_modules/.pnpm/pnpm@6.17.2/node_modules/pnpm/dist/pnpm.cjs:40641:13)\n at async Object.readProjectManifestOnly (/home/jim/.asdf/installs/nodejs/16.11.0/pnpm-global/5/node_modules/.pnpm/pnpm@6.17.2/node_modules/pnpm/dist/pnpm.cjs:40645:28)\n at async Object.readProjectManifestOnly (/home/jim/.asdf/installs/nodejs/16.11.0/pnpm-global/5/node_modules/.pnpm/pnpm@6.17.2/node_modules/pnpm/dist/pnpm.cjs:40864:24)\n at async Object.handler (/home/jim/.asdf/installs/nodejs/16.11.0/pnpm-global/5/node_modules/.pnpm/pnpm@6.17.2/node_modules/pnpm/dist/pnpm.cjs:129763:24)\n at async /home/jim/.asdf/installs/nodejs/16.11.0/pnpm-global/5/node_modules/.pnpm/pnpm@6.17.2/node_modules/pnpm/dist/pnpm.cjs:133951:20\n at async run (/home/jim/.asdf/installs/nodejs/16.11.0/pnpm-global/5/node_modules/.pnpm/pnpm@6.17.2/node_modules/pnpm/dist/pnpm.cjs:133926:34)\n at async runPnpm (/home/jim/.asdf/installs/nodejs/16.11.0/pnpm-global/5/node_modules/.pnpm/pnpm@6.17.2/node_modules/pnpm/dist/pnpm.cjs:134137:5)\n at async /home/jim/.asdf/installs/nodejs/16.11.0/pnpm-global/5/node_modules/.pnpm/pnpm@6.17.2/node_modules/pnpm/dist/pnpm.cjs:134129:7"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -23,7 +23,6 @@
|
|||||||
# available, otherwise `xterm-256color` is used.
|
# available, otherwise `xterm-256color` is used.
|
||||||
#TERM: alacritty
|
#TERM: alacritty
|
||||||
|
|
||||||
window:
|
|
||||||
# Window dimensions (changes require restart)
|
# Window dimensions (changes require restart)
|
||||||
#
|
#
|
||||||
# Number of lines/columns (not pixels) in the terminal. The number of columns
|
# Number of lines/columns (not pixels) in the terminal. The number of columns
|
||||||
@ -45,13 +44,12 @@ window:
|
|||||||
#
|
#
|
||||||
# Blank space added around the window in pixels. This padding is scaled
|
# Blank space added around the window in pixels. This padding is scaled
|
||||||
# by DPI and the specified value is always added at both opposing sides.
|
# by DPI and the specified value is always added at both opposing sides.
|
||||||
|
window:
|
||||||
padding:
|
padding:
|
||||||
x: 10
|
x: 10
|
||||||
y: 10
|
y: 10
|
||||||
|
dynamic_padding: false
|
||||||
# Spread additional padding evenly around the terminal content.
|
|
||||||
dynamic_padding: true
|
|
||||||
|
|
||||||
# Window decorations
|
# Window decorations
|
||||||
#
|
#
|
||||||
# Values for `decorations`:
|
# Values for `decorations`:
|
||||||
@ -359,9 +357,6 @@ font:
|
|||||||
# The value `0.0` is completely transparent and `1.0` is opaque.
|
# The value `0.0` is completely transparent and `1.0` is opaque.
|
||||||
#background_opacity: 1.0
|
#background_opacity: 1.0
|
||||||
|
|
||||||
window:
|
|
||||||
opacity: 1.0
|
|
||||||
|
|
||||||
#selection:
|
#selection:
|
||||||
# This string contains all characters that are used as separators for
|
# This string contains all characters that are used as separators for
|
||||||
# "semantic words" in Alacritty.
|
# "semantic words" in Alacritty.
|
||||||
|
@ -28,7 +28,7 @@ return require("packer").startup(function()
|
|||||||
use "NTBBloodbath/rest.nvim"
|
use "NTBBloodbath/rest.nvim"
|
||||||
|
|
||||||
-- Obsidian / Roam like features
|
-- Obsidian / Roam like features
|
||||||
use "lervag/wiki.vim"
|
-- use "lervag/wiki.vim"
|
||||||
|
|
||||||
-- Syntax / Autocomplete
|
-- Syntax / Autocomplete
|
||||||
use "preservim/nerdcommenter"
|
use "preservim/nerdcommenter"
|
||||||
|
145
configs/rofi/config.rasi
Normal file
145
configs/rofi/config.rasi
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
configuration {
|
||||||
|
modi: "window,run,ssh";
|
||||||
|
/* width: 50;*/
|
||||||
|
lines: 4;
|
||||||
|
/* columns: 1;*/
|
||||||
|
/* font: "mono 12";*/
|
||||||
|
/* bw: 1;*/
|
||||||
|
/* location: 0;*/
|
||||||
|
padding: 5;
|
||||||
|
/* yoffset: 0;*/
|
||||||
|
/* xoffset: 0;*/
|
||||||
|
/* fixed-num-lines: true;*/
|
||||||
|
show-icons: true;
|
||||||
|
/* terminal: "rofi-sensible-terminal";*/
|
||||||
|
/* ssh-client: "ssh";*/
|
||||||
|
/* ssh-command: "{terminal} -e {ssh-client} {host} [-p {port}]";*/
|
||||||
|
/* run-command: "{cmd}";*/
|
||||||
|
/* run-list-command: "";*/
|
||||||
|
/* run-shell-command: "{terminal} -e {cmd}";*/
|
||||||
|
/* window-command: "wmctrl -i -R {window}";*/
|
||||||
|
/* window-match-fields: "all";*/
|
||||||
|
/* icon-theme: ;*/
|
||||||
|
/* drun-match-fields: "name,generic,exec,categories";*/
|
||||||
|
/* drun-show-actions: false;*/
|
||||||
|
/* drun-display-format: "{name} [<span weight='light' size='small'><i>({generic})</i></span>]";*/
|
||||||
|
/* disable-history: false;*/
|
||||||
|
/* ignored-prefixes: "";*/
|
||||||
|
/* sort: false;*/
|
||||||
|
/* sorting-method: ;*/
|
||||||
|
/* case-sensitive: false;*/
|
||||||
|
/* cycle: true;*/
|
||||||
|
/* sidebar-mode: false;*/
|
||||||
|
eh: 1;
|
||||||
|
/* auto-select: false;*/
|
||||||
|
/* parse-hosts: false;*/
|
||||||
|
/* parse-known-hosts: true;*/
|
||||||
|
/* combi-modi: "window,run";*/
|
||||||
|
/* matching: "normal";*/
|
||||||
|
/* tokenize: true;*/
|
||||||
|
/* m: "-5";*/
|
||||||
|
/* line-margin: 2;*/
|
||||||
|
/* line-padding: 1;*/
|
||||||
|
/* filter: ;*/
|
||||||
|
/* separator-style: "dash";*/
|
||||||
|
/* hide-scrollbar: false;*/
|
||||||
|
/* fullscreen: false;*/
|
||||||
|
/* fake-transparency: false;*/
|
||||||
|
/* dpi: -1;*/
|
||||||
|
/* threads: 0;*/
|
||||||
|
/* scrollbar-width: 8;*/
|
||||||
|
/* scroll-method: 0;*/
|
||||||
|
/* fake-background: "screenshot";*/
|
||||||
|
/* window-format: "{w} {c} {t}";*/
|
||||||
|
/* click-to-exit: true;*/
|
||||||
|
/* show-match: true;*/
|
||||||
|
theme: "slate";
|
||||||
|
/* color-normal: ;*/
|
||||||
|
/* color-urgent: ;*/
|
||||||
|
/* color-active: ;*/
|
||||||
|
/* color-window: ;*/
|
||||||
|
/* max-history-size: 25;*/
|
||||||
|
/* combi-hide-mode-prefix: false;*/
|
||||||
|
/* matching-negate-char: '-' /* unsupported */;*/
|
||||||
|
/* cache-dir: ;*/
|
||||||
|
/* pid: "/run/user/1000/rofi.pid";*/
|
||||||
|
/* display-window: ;*/
|
||||||
|
/* display-windowcd: ;*/
|
||||||
|
/* display-run: ;*/
|
||||||
|
/* display-ssh: ;*/
|
||||||
|
/* display-drun: ;*/
|
||||||
|
/* display-combi: ;*/
|
||||||
|
/* display-keys: ;*/
|
||||||
|
/* kb-primary-paste: "Control+V,Shift+Insert";*/
|
||||||
|
/* kb-secondary-paste: "Control+v,Insert";*/
|
||||||
|
/* kb-clear-line: "Control+w";*/
|
||||||
|
/* kb-move-front: "Control+a";*/
|
||||||
|
/* kb-move-end: "Control+e";*/
|
||||||
|
/* kb-move-word-back: "Alt+b,Control+Left";*/
|
||||||
|
/* kb-move-word-forward: "Alt+f,Control+Right";*/
|
||||||
|
/* kb-move-char-back: "Left,Control+b";*/
|
||||||
|
/* kb-move-char-forward: "Right,Control+f";*/
|
||||||
|
/* kb-remove-word-back: "Control+Alt+h,Control+BackSpace";*/
|
||||||
|
/* kb-remove-word-forward: "Control+Alt+d";*/
|
||||||
|
/* kb-remove-char-forward: "Delete,Control+d";*/
|
||||||
|
/* kb-remove-char-back: "BackSpace,Shift+BackSpace,Control+h";*/
|
||||||
|
/* kb-remove-to-eol: "Control+k";*/
|
||||||
|
/* kb-remove-to-sol: "Control+u";*/
|
||||||
|
/* kb-accept-entry: "Control+j,Control+m,Return,KP_Enter";*/
|
||||||
|
/* kb-accept-custom: "Control+Return";*/
|
||||||
|
/* kb-accept-alt: "Shift+Return";*/
|
||||||
|
/* kb-delete-entry: "Shift+Delete";*/
|
||||||
|
/* kb-mode-next: "Shift+Right,Control+Tab";*/
|
||||||
|
/* kb-mode-previous: "Shift+Left,Control+ISO_Left_Tab";*/
|
||||||
|
/* kb-row-left: "Control+Page_Up";*/
|
||||||
|
/* kb-row-right: "Control+Page_Down";*/
|
||||||
|
/* kb-row-up: "Up,Control+p,ISO_Left_Tab";*/
|
||||||
|
/* kb-row-down: "Down,Control+n";*/
|
||||||
|
/* kb-row-tab: "Tab";*/
|
||||||
|
/* kb-page-prev: "Page_Up";*/
|
||||||
|
/* kb-page-next: "Page_Down";*/
|
||||||
|
/* kb-row-first: "Home,KP_Home";*/
|
||||||
|
/* kb-row-last: "End,KP_End";*/
|
||||||
|
/* kb-row-select: "Control+space";*/
|
||||||
|
/* kb-screenshot: "Alt+S";*/
|
||||||
|
/* kb-ellipsize: "Alt+period";*/
|
||||||
|
/* kb-toggle-case-sensitivity: "grave,dead_grave";*/
|
||||||
|
/* kb-toggle-sort: "Alt+grave";*/
|
||||||
|
/* kb-cancel: "Escape,Control+g,Control+bracketleft";*/
|
||||||
|
/* kb-custom-1: "Alt+1";*/
|
||||||
|
/* kb-custom-2: "Alt+2";*/
|
||||||
|
/* kb-custom-3: "Alt+3";*/
|
||||||
|
/* kb-custom-4: "Alt+4";*/
|
||||||
|
/* kb-custom-5: "Alt+5";*/
|
||||||
|
/* kb-custom-6: "Alt+6";*/
|
||||||
|
/* kb-custom-7: "Alt+7";*/
|
||||||
|
/* kb-custom-8: "Alt+8";*/
|
||||||
|
/* kb-custom-9: "Alt+9";*/
|
||||||
|
/* kb-custom-10: "Alt+0";*/
|
||||||
|
/* kb-custom-11: "Alt+exclam";*/
|
||||||
|
/* kb-custom-12: "Alt+at";*/
|
||||||
|
/* kb-custom-13: "Alt+numbersign";*/
|
||||||
|
/* kb-custom-14: "Alt+dollar";*/
|
||||||
|
/* kb-custom-15: "Alt+percent";*/
|
||||||
|
/* kb-custom-16: "Alt+dead_circumflex";*/
|
||||||
|
/* kb-custom-17: "Alt+ampersand";*/
|
||||||
|
/* kb-custom-18: "Alt+asterisk";*/
|
||||||
|
/* kb-custom-19: "Alt+parenleft";*/
|
||||||
|
/* kb-select-1: "Super+1";*/
|
||||||
|
/* kb-select-2: "Super+2";*/
|
||||||
|
/* kb-select-3: "Super+3";*/
|
||||||
|
/* kb-select-4: "Super+4";*/
|
||||||
|
/* kb-select-5: "Super+5";*/
|
||||||
|
/* kb-select-6: "Super+6";*/
|
||||||
|
/* kb-select-7: "Super+7";*/
|
||||||
|
/* kb-select-8: "Super+8";*/
|
||||||
|
/* kb-select-9: "Super+9";*/
|
||||||
|
/* kb-select-10: "Super+0";*/
|
||||||
|
/* ml-row-left: "ScrollLeft";*/
|
||||||
|
/* ml-row-right: "ScrollRight";*/
|
||||||
|
/* ml-row-up: "ScrollUp";*/
|
||||||
|
/* ml-row-down: "ScrollDown";*/
|
||||||
|
/* me-select-entry: "MousePrimary";*/
|
||||||
|
/* me-accept-entry: "MouseDPrimary";*/
|
||||||
|
/* me-accept-custom: "Control+MouseDPrimary";*/
|
||||||
|
}
|
44
configs/rofi/slate.rasi
Normal file
44
configs/rofi/slate.rasi
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
* {
|
||||||
|
background-color: #2b303b;
|
||||||
|
border-color: #2e343f;
|
||||||
|
text-color: #8ca0aa;
|
||||||
|
border-radius: 5px;
|
||||||
|
spacing: 0;
|
||||||
|
width: 512px;
|
||||||
|
}
|
||||||
|
|
||||||
|
inputbar {
|
||||||
|
border: 0 0 1px 0;
|
||||||
|
children: [prompt,entry];
|
||||||
|
}
|
||||||
|
|
||||||
|
prompt {
|
||||||
|
padding: 16px;
|
||||||
|
border: 0 1px 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
textbox {
|
||||||
|
background-color: #2e343f;
|
||||||
|
border: 0 0 1px 0;
|
||||||
|
border-color: #282C33;
|
||||||
|
padding: 8px 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
entry {
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
listview {
|
||||||
|
cycle: false;
|
||||||
|
margin: 0 0 -1px 0;
|
||||||
|
scrollbar: false;
|
||||||
|
}
|
||||||
|
|
||||||
|
element {
|
||||||
|
border: 0 0 1px 0;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
element selected {
|
||||||
|
background-color: #2e343f;
|
||||||
|
}
|
@ -18,17 +18,20 @@ set $term alacritty
|
|||||||
# Your preferred application launcher
|
# Your preferred application launcher
|
||||||
# Note: pass the final command to swaymsg so that the resulting window can be opened
|
# Note: pass the final command to swaymsg so that the resulting window can be opened
|
||||||
# on the original workspace that the command was run on.
|
# on the original workspace that the command was run on.
|
||||||
set $menu dmenu_path | dmenu | xargs swaymsg exec --
|
set $menu "rofi -combi-modi window,drun,ssh,run -show combi -show-icons"
|
||||||
set $menu rofi -m $(expr $(swaymsg -t get_tree | jq '.nodes | map([recurse(.nodes[]?, .floating_nodes[]?) | .focused] | any) | index(true)') - 1) -show drun -run-command 'swaymsg exec -- {cmd}'
|
|
||||||
set $menu rofi -m $(swaymsg -t get_outputs | jq 'map(select(.active) | .focused) | index(true)') -show drun -run-command 'swaymsg exec -- {cmd}'
|
|
||||||
|
|
||||||
# Input configuration
|
# Input configuration
|
||||||
input * {
|
input * {
|
||||||
xkb_layout de
|
xkb_layout de
|
||||||
xkb_variant nodeadkeys
|
xkb_variant nodeadkeys
|
||||||
xkb_options caps:swapescape
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
smart_gaps off
|
||||||
|
gaps inner 0
|
||||||
|
gaps outer 10
|
||||||
|
|
||||||
|
default_border none
|
||||||
|
|
||||||
### Output configuration
|
### Output configuration
|
||||||
#
|
#
|
||||||
# Default wallpaper (more resolutions are available in @datadir@/backgrounds/sway/)
|
# Default wallpaper (more resolutions are available in @datadir@/backgrounds/sway/)
|
||||||
@ -119,6 +122,7 @@ input * {
|
|||||||
#
|
#
|
||||||
# Workspaces:
|
# Workspaces:
|
||||||
#
|
#
|
||||||
|
|
||||||
# Switch to workspace
|
# Switch to workspace
|
||||||
bindsym $mod+1 workspace number 1
|
bindsym $mod+1 workspace number 1
|
||||||
bindsym $mod+2 workspace number 2
|
bindsym $mod+2 workspace number 2
|
||||||
|
@ -1,29 +1,29 @@
|
|||||||
{
|
{
|
||||||
// "layer": "top", // Waybar at top layer
|
// "layer": "top", // Waybar at top layer
|
||||||
// "position": "bottom", // Waybar position (top|bottom|left|right)
|
// "position": "bottom", // Waybar position (top|bottom|left|right)
|
||||||
"height": 30, // Waybar height (to be removed for auto height)
|
"height": 20, // Waybar height (to be removed for auto height)
|
||||||
// "width": 1280, // Waybar width
|
// "width": 1280, // Waybar width
|
||||||
"spacing": 4, // Gaps between modules (4px)
|
"spacing": 4, // Gaps between modules (4px)
|
||||||
// Choose the order of the modules
|
// Choose the order of the modules
|
||||||
"modules-left": ["sway/workspaces", "sway/mode", "custom/media"],
|
"modules-left": ["sway/workspaces", "sway/mode", "custom/media"],
|
||||||
"modules-center": ["sway/window"],
|
"modules-center": ["custom/clock", "custom/spotify"],
|
||||||
"modules-right": ["mpd", "idle_inhibitor", "pulseaudio", "network", "cpu", "memory", "temperature", "backlight", "keyboard-state", "sway/language", "battery", "battery#bat2", "clock", "tray"],
|
"modules-right": ["pulseaudio", "network", "cpu", "memory", "battery", "battery#bat2"],
|
||||||
// Modules configuration
|
// Modules configuration
|
||||||
// "sway/workspaces": {
|
"sway/workspaces": {
|
||||||
// "disable-scroll": true,
|
"disable-scroll": true,
|
||||||
// "all-outputs": true,
|
"all-outputs": true,
|
||||||
// "format": "{name}: {icon}",
|
"format": "{icon}",
|
||||||
// "format-icons": {
|
"format-icons": {
|
||||||
// "1": "",
|
"1": " Terminal",
|
||||||
// "2": "",
|
"2": " Browser",
|
||||||
// "3": "",
|
"3": "",
|
||||||
// "4": "",
|
"4": "",
|
||||||
// "5": "",
|
"5": "",
|
||||||
// "urgent": "",
|
"urgent": "",
|
||||||
// "focused": "",
|
"focused": "",
|
||||||
// "default": ""
|
"default": ""
|
||||||
// }
|
}
|
||||||
// },
|
},
|
||||||
"keyboard-state": {
|
"keyboard-state": {
|
||||||
"numlock": true,
|
"numlock": true,
|
||||||
"capslock": true,
|
"capslock": true,
|
||||||
@ -33,12 +33,20 @@
|
|||||||
"unlocked": ""
|
"unlocked": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"custom/spotify": {
|
||||||
|
"exec": "/usr/bin/python3 /home/jim/.config/waybar/mediaplayer.py --player spotify",
|
||||||
|
"format": "{} ",
|
||||||
|
"return-type": "json",
|
||||||
|
"on-click": "playerctl play-pause",
|
||||||
|
"on-scroll-up": "playerctl next",
|
||||||
|
"on-scroll-down": "playerctl previous"
|
||||||
|
},
|
||||||
"sway/mode": {
|
"sway/mode": {
|
||||||
"format": "<span style=\"italic\">{}</span>"
|
"format": "<span style=\"italic\">{}</span>"
|
||||||
},
|
},
|
||||||
"mpd": {
|
"mpd": {
|
||||||
"format": "{stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon}{artist} - {album} - {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S}) ⸨{songPosition}|{queueLength}⸩ {volume}% ",
|
"format": "{stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon}{artist} - {album} - {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S}) ⸨{songPosition}|{queueLength}⸩ {volume}% ",
|
||||||
"format-disconnected": "Disconnected ",
|
"format-disconnected": "",
|
||||||
"format-stopped": "{consumeIcon}{randomIcon}{repeatIcon}{singleIcon}Stopped ",
|
"format-stopped": "{consumeIcon}{randomIcon}{repeatIcon}{singleIcon}Stopped ",
|
||||||
"unknown-tag": "N/A",
|
"unknown-tag": "N/A",
|
||||||
"interval": 2,
|
"interval": 2,
|
||||||
@ -73,11 +81,15 @@
|
|||||||
// "icon-size": 21,
|
// "icon-size": 21,
|
||||||
"spacing": 10
|
"spacing": 10
|
||||||
},
|
},
|
||||||
"clock": {
|
"clock": {
|
||||||
// "timezone": "America/New_York",
|
"interval": 60,
|
||||||
"tooltip-format": "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>",
|
"format": "{:%H:%M}",
|
||||||
"format-alt": "{:%Y-%m-%d}"
|
"max-length": 25
|
||||||
},
|
},
|
||||||
|
"custom/clock": {
|
||||||
|
"exec": "date +'%H:%M'",
|
||||||
|
"interval": 10
|
||||||
|
},
|
||||||
"cpu": {
|
"cpu": {
|
||||||
"format": "{usage}% ",
|
"format": "{usage}% ",
|
||||||
"tooltip": false
|
"tooltip": false
|
||||||
|
11
configs/waybar/launch.sh
Executable file
11
configs/waybar/launch.sh
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
CONFIG_FILES="$HOME/.config/waybar/config $HOME/.config/waybar/style.css"
|
||||||
|
|
||||||
|
trap "killall waybar" EXIT
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
waybar &
|
||||||
|
inotifywait -e create,modify $CONFIG_FILES
|
||||||
|
killall waybar
|
||||||
|
done
|
127
configs/waybar/mediaplayer.py
Normal file
127
configs/waybar/mediaplayer.py
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
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)
|
||||||
|
|
||||||
|
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()
|
@ -1,33 +1,45 @@
|
|||||||
* {
|
* {
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 0;
|
border-radius: 5px;
|
||||||
font-family: Font Awesome, Hack Nerd Font;
|
font-family: Font Awesome, Hack Nerd Font;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
box-shadow: none;
|
|
||||||
text-shadow: none;
|
|
||||||
transition-duration: 0s;
|
transition-duration: 0s;
|
||||||
color: #d5c4a1;
|
/*color: #c0c5ce;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
window#waybar {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
window > box {
|
||||||
|
margin: 10px;
|
||||||
|
margin-bottom: 0px;
|
||||||
|
background: #2b303b;
|
||||||
|
padding: 3px;
|
||||||
|
/*border-bottom: 3px solid rgba(100, 114, 125, 0.5);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
window {
|
window {
|
||||||
font-weight: bold;
|
background: #2b303b;
|
||||||
color: #d5c4a1;
|
margin: 0px;
|
||||||
background: #504945;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#workspaces {
|
#workspaces {
|
||||||
margin: 0 5px;
|
margin: 0 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#workspaces button {
|
#workspaces button {
|
||||||
padding: 0 4px;
|
padding: 0px 8px;
|
||||||
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
#workspaces button.visible {
|
#workspaces button:hover{
|
||||||
|
opacity: 0.9;
|
||||||
}
|
}
|
||||||
|
|
||||||
#workspaces button.focused {
|
#workspaces button.focused {
|
||||||
background-color: #458588;
|
background-color: white;
|
||||||
|
color: #2b303b;
|
||||||
}
|
}
|
||||||
|
|
||||||
#battery, #network, #pulseaudio, #clock, #custom-power, #custom-qbitstats {
|
#battery, #network, #pulseaudio, #clock, #custom-power, #custom-qbitstats {
|
||||||
@ -41,6 +53,12 @@ window {
|
|||||||
min-width: 10px;
|
min-width: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.custom-spotify {
|
||||||
|
padding: 0 10px;
|
||||||
|
margin: 0 4px;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
#custom-power {
|
#custom-power {
|
||||||
color: #cc241d;
|
color: #cc241d;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user