rounded windows and waybar edits
This commit is contained in:
@@ -2,12 +2,26 @@
|
||||
{
|
||||
"layer": "top",
|
||||
"height": 30,
|
||||
"modules-left": ["hyprland/workspaces", "custom/lock", "custom/shutdown", "custom/reboot", "custom/temperature", "cpu", "memory"],
|
||||
"modules-left": ["hyprland/workspaces", "custom/temperature", "cpu", "memory"],
|
||||
"modules-center": ["custom/time", "hyprland/window"],
|
||||
"modules-right": ["custom/metar", "battery", "clock"],
|
||||
"modules-right": ["custom/metar", "clock", "tray"],
|
||||
"hyprland/workspaces": {
|
||||
"disable-scroll": true,
|
||||
"show-special": true,
|
||||
"all-outputs": true,
|
||||
"move-to-monitor": true,
|
||||
"wrap-on-scroll": false,
|
||||
"format": "{icon}{name}",
|
||||
"format-active": "[{name}]",
|
||||
"format-icons": {
|
||||
"urgent": "!",
|
||||
"active": "*",
|
||||
"default": ""
|
||||
}
|
||||
},
|
||||
"clock": {
|
||||
"format": "{:%a, %d %b %Y %H:%M:%S}",
|
||||
"inverval": 1
|
||||
"interval": 1
|
||||
},
|
||||
"custom/temperature": {
|
||||
"format": " {}",
|
||||
@@ -36,6 +50,6 @@
|
||||
"custom/reboot": {
|
||||
"on-click": "reboot",
|
||||
"format": "",
|
||||
}
|
||||
},
|
||||
}
|
||||
]
|
||||
|
61
.config/waybar/scripts/waymedia
Executable file
61
.config/waybar/scripts/waymedia
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import json
|
||||
from os.path import expanduser
|
||||
import subprocess
|
||||
import re
|
||||
|
||||
config_path = f"{expanduser('~')}/.config/waybar"
|
||||
|
||||
if os.path.exists(f"{config_path}/config.jsonc"):
|
||||
config_path = f"{config_path}/config.jsonc"
|
||||
else:
|
||||
config_path = f"{config_path}/config"
|
||||
|
||||
def remove_comments(jsonc_str):
|
||||
json_str = re.sub(r'//.*', '', jsonc_str) # remove single-line comments
|
||||
json_str = re.sub(r'/\*.*?\*/', '', json_str, flags=re.DOTALL) # remove multi-line comments
|
||||
return json_str
|
||||
|
||||
with open(config_path, "r", encoding="utf-8") as file:
|
||||
jsonc_content = file.read()
|
||||
|
||||
clean_json_str = remove_comments(jsonc_content)
|
||||
config_json = json.loads(clean_json_str)
|
||||
|
||||
module_configs = config_json.get("custom/waymedia", {})
|
||||
pause_icon = module_configs.get("pause-icon", " ")
|
||||
play_icon = module_configs.get("play-icon", " ")
|
||||
divider = module_configs.get("divider", " - ")
|
||||
format = module_configs.get("format", "{icon}{artist}{divider}{title}")
|
||||
limit = module_configs.get("limit", 60)
|
||||
|
||||
def get_command_result(command) -> str:
|
||||
return subprocess.run(command, shell=True, capture_output=True, text=True).stdout.strip()
|
||||
|
||||
metadata = get_command_result("playerctl metadata")
|
||||
|
||||
players = subprocess.run("playerctl --list-all", shell=True, capture_output=True, text=True).stdout.split("\n")
|
||||
|
||||
for player in players:
|
||||
status = get_command_result(f"playerctl status -p {player}")
|
||||
|
||||
if status != "Stopped" and status != "":
|
||||
icon = play_icon if status == "Paused" else pause_icon
|
||||
artist = get_command_result("playerctl metadata --format '{{artist}}'")
|
||||
title = get_command_result("playerctl metadata --format '{{title}}'")
|
||||
|
||||
if len(artist) == 0:
|
||||
divider = ""
|
||||
|
||||
text = format.replace("{icon}", icon).replace("{title}", title).replace("{divider}", divider).replace("{artist}", artist).strip().replace("&", "&").replace("{}", "")
|
||||
|
||||
if len(text) > limit:
|
||||
text = f"{text[:limit - 3]}..."
|
||||
|
||||
print(text, flush=True)
|
||||
exit(0)
|
||||
|
||||
print("", flush=True)
|
||||
exit(0)
|
58
.config/waybar/scripts/waymedia-buttons
Executable file
58
.config/waybar/scripts/waymedia-buttons
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import json
|
||||
from os.path import expanduser
|
||||
import subprocess
|
||||
import re
|
||||
|
||||
config_path = f"{expanduser("~")}/.config/waybar"
|
||||
|
||||
if os.path.exists(f"{config_path}/config.jsonc"):
|
||||
config_path = f"{config_path}/config.jsonc"
|
||||
else:
|
||||
config_path = f"{config_path}/config"
|
||||
|
||||
def remove_comments(jsonc_str):
|
||||
json_str = re.sub(r'//.*', '', jsonc_str) # remove single-line comments
|
||||
json_str = re.sub(r'/\*.*?\*/', '', json_str, flags=re.DOTALL) # remove multi-line comments
|
||||
return json_str
|
||||
|
||||
with open(config_path, "r", encoding="utf-8") as file:
|
||||
jsonc_content = file.read()
|
||||
|
||||
clean_json_str = remove_comments(jsonc_content)
|
||||
config_json = json.loads(clean_json_str)
|
||||
|
||||
|
||||
module_configs = config_json.get("custom/waymedia-buttons", {})
|
||||
play_icon = module_configs.get("play-icon") if "play-icon" in module_configs else " "
|
||||
pause_icon = module_configs.get("pause-icon") if "pause-icon" in module_configs else " "
|
||||
skip_icon = module_configs.get("skip-icon") if "skip-icon" in module_configs else " "
|
||||
previous_icon = module_configs.get("previous-icon") if "previous-icon" in module_configs else " "
|
||||
|
||||
def get_command_result(command)-> str:
|
||||
return subprocess.run(command, shell=True, capture_output=True, text=True).stdout.strip()
|
||||
|
||||
metadata = get_command_result("playerctl metadata")
|
||||
|
||||
players = subprocess.run("playerctl --list-all", shell=True, capture_output=True, text=True).stdout.split("\n")
|
||||
|
||||
for player in players:
|
||||
status = get_command_result(f"playerctl status -p {player}")
|
||||
|
||||
if status != "Stopped" and status != "":
|
||||
icon = play_icon if status == "Paused" else pause_icon
|
||||
artist = get_command_result("playerctl metadata --format '{{artist}}'")
|
||||
title = get_command_result("playerctl metadata --format '{{title}}'")
|
||||
|
||||
|
||||
if len(artist) == 0:
|
||||
divider = ""
|
||||
|
||||
|
||||
print(f"{previous_icon} {icon} {skip_icon}", flush=True)
|
||||
exit(0)
|
||||
|
||||
print("", flush=True)
|
||||
exit(0)
|
@@ -2,7 +2,7 @@ window#waybar.screenBorder {
|
||||
border: 2px solid #b8bb26;
|
||||
background-color: transparent;
|
||||
box-shadow: 0px 0px 0px 60px black, 0px 0px 0px 0.5px #ebdbb2;
|
||||
border-radius: 0px;
|
||||
border-radius: 10px;
|
||||
margin: 20px;
|
||||
}
|
||||
window#waybar.top,
|
||||
@@ -14,7 +14,6 @@ window#waybar.left {
|
||||
#workspaces button {
|
||||
padding: 0px;
|
||||
color: #ebdbb2;
|
||||
background: #282828;
|
||||
}
|
||||
#workspaces button:hover {
|
||||
color: #b8bb26;
|
||||
@@ -26,15 +25,6 @@ window#waybar.left {
|
||||
color: #282828;
|
||||
background: #ebdbb2;
|
||||
}
|
||||
#workspaces {
|
||||
border: 2px solid #b8bb26;
|
||||
border-radius: 0;
|
||||
box-shadow: 12px 12px 0px 2px #000000;
|
||||
padding: 0px;
|
||||
margin: 6px;
|
||||
padding: 0px 5px 0px 5px;
|
||||
background: #282828;
|
||||
}
|
||||
#custom-caway {
|
||||
color: #ebdbb2;
|
||||
background: #282828;
|
||||
@@ -43,6 +33,7 @@ window#waybar.left {
|
||||
box-shadow: 12px 12px 0px 2px #000000;
|
||||
margin: 6px;
|
||||
}
|
||||
#workspaces,
|
||||
#custom-clock,
|
||||
#clock,
|
||||
#custom-time,
|
||||
@@ -74,12 +65,14 @@ window#waybar.left {
|
||||
#custom-lock,
|
||||
#custom-shutdown,
|
||||
#custom-reboot,
|
||||
#window {
|
||||
#window,
|
||||
#tray {
|
||||
color: #ebdbb2;
|
||||
background: #282828;
|
||||
border: 2px solid #b8bb26;
|
||||
border-radius: 0;
|
||||
box-shadow: 12px 12px 0px 2px #000000;
|
||||
padding: 3px;
|
||||
border-radius: 15;
|
||||
/*box-shadow: 12px 12px 0px 2px #282828;*/
|
||||
padding-left: 3px;
|
||||
padding-right: 3px;
|
||||
margin: 6px;
|
||||
}
|
||||
|
Reference in New Issue
Block a user