Upload from GitHub
This commit is contained in:
137
laptop/configs/waybar/config.jsonc
Executable file
137
laptop/configs/waybar/config.jsonc
Executable file
@@ -0,0 +1,137 @@
|
||||
{
|
||||
"layer": "top",
|
||||
"position": "top",
|
||||
"mod": "dock",
|
||||
"exclusive": true,
|
||||
"passthrough": false,
|
||||
"gtk-layer-shell": true,
|
||||
"height": 0,
|
||||
"modules-left": [
|
||||
"clock",
|
||||
"cpu",
|
||||
"memory",
|
||||
"battery",
|
||||
"backlight",
|
||||
"hyprland/workspaces"
|
||||
],
|
||||
"modules-center": ["hyprland/window"],
|
||||
"modules-right": [
|
||||
"tray",
|
||||
"network",
|
||||
"pulseaudio",
|
||||
"pulseaudio#microphone",
|
||||
"custom/powerMenu"
|
||||
],
|
||||
"hyprland/window": {
|
||||
"format": "{}"
|
||||
},
|
||||
"tray": {
|
||||
"icon-size": 14,
|
||||
"spacing": 8
|
||||
},
|
||||
"custom/powerMenu": {
|
||||
"format": "⏻",
|
||||
"on-click": "rofi -show p -modi p:rofi-power-menu -theme ~/.config/rofi/themes/power.rasi"
|
||||
},
|
||||
"network": {
|
||||
"format-disconnected": " Net",
|
||||
"format-wifi": "{icon} {essid}",
|
||||
"format-ethernet": " Wired",
|
||||
"tooltip-format-ethernet": "<big>Ethernet</big>\nInterface: {ifname}\nIP: {ipaddr}\nUp/Down (bps): {bandwidthUpBits}/{bandwidthDownBits}",
|
||||
"tooltip-format-wifi": "<big>Wi-Fi</big>\nSSID: {essid}\nIP: {ipaddr}\nSignal strength: {signalStrength}%\nUp/Down (bps): {bandwidthUpBits}/{bandwidthDownBits}\nFrequency: {frequency}GHz",
|
||||
"tooltip-format-disconnected": "<big>Networking</big>\n{ifname} disconnected",
|
||||
"on-click": "terminator -x nmtui",
|
||||
"format-icons": ["", "", "", ""]
|
||||
},
|
||||
"battery":{
|
||||
"states": {
|
||||
"95": 100,
|
||||
"85": 90,
|
||||
"75": 80,
|
||||
"65": 70,
|
||||
"55": 60,
|
||||
"45": 50,
|
||||
"35": 40,
|
||||
"25": 30,
|
||||
"15": 20,
|
||||
"5": 10,
|
||||
"critical": 0,
|
||||
},
|
||||
"format":" {capacity}",
|
||||
"format-95": " {capacity}",
|
||||
"format-85": " {capacity}",
|
||||
"format-75": " {capacity}",
|
||||
"format-65": " {capacity}",
|
||||
"format-55": " {capacity}",
|
||||
"format-45": " {capacity}",
|
||||
"format-35": " {capacity}",
|
||||
"format-25": " {capacity}",
|
||||
"format-15": " {capacity}",
|
||||
"format-15": " {capacity}",
|
||||
"format-critical": " {capacity}",
|
||||
"format-charging":" {capacity}",
|
||||
"format-plugged": " ",
|
||||
"format-full": " 100",
|
||||
"format-empty": " ({capacity}%)",
|
||||
"tooltip-format":"<big>Battery</big>\nCurrently {timeTo}\nCurrently drawing: {power}W\nBattery status: {capacity}%"
|
||||
},
|
||||
"backlight": {
|
||||
"stages": {
|
||||
"high": 50,
|
||||
"low": 0,
|
||||
},
|
||||
"format": "🌣 {percent}",
|
||||
"format-high": " {percent}",
|
||||
"format-low": " {percent}",
|
||||
"tooltip-format": "<big>Brightness</big>\n🌣 {percent}",
|
||||
"on-scroll-up": "light -A 1",
|
||||
"on-scroll-down": "light -U 1"
|
||||
},
|
||||
"clock": {
|
||||
"format": "{:%a, %d.%m %H:%M:%S}",
|
||||
"tooltip-format": "<big>Calendar</big>\n<tt><small>{calendar}</small></tt>",
|
||||
"interval": 1
|
||||
},
|
||||
"hyprland/workspaces": {
|
||||
"disable-scroll": true,
|
||||
"all-outputs": true,
|
||||
"on-click": "activate",
|
||||
"format": "{icon}"
|
||||
},
|
||||
"cpu": {
|
||||
"tooltip-format": "<big>CPU</big>\n<tt>Total: {usage}</tt>",
|
||||
"format": " {usage}",
|
||||
"interval": 5
|
||||
},
|
||||
"memory": {
|
||||
"format": " {percentage}",
|
||||
"interval": 5
|
||||
},
|
||||
"pulseaudio": {
|
||||
"format": "{icon} {volume}",
|
||||
"tooltip": true,
|
||||
"format-muted": " Off",
|
||||
"on-click": "pamixer -t",
|
||||
"on-scroll-up": "pamixer -i 5",
|
||||
"on-scroll-down": "pamixer -d 5",
|
||||
"scroll-step": 5,
|
||||
"format-icons": {
|
||||
"headphone": "",
|
||||
"hands-free": "",
|
||||
"headset": "",
|
||||
"phone": "",
|
||||
"portable": "",
|
||||
"car": "🏎",
|
||||
"default": ["", "", ""]
|
||||
}
|
||||
},
|
||||
"pulseaudio#microphone": {
|
||||
"format": "{format_source}",
|
||||
"format-source": " {volume}",
|
||||
"format-source-muted": " 0",
|
||||
"on-click": "pamixer --default-source -t",
|
||||
"on-scroll-up": "pamixer --default-source -i 5",
|
||||
"on-scroll-down": "pamixer --default-source -d 5",
|
||||
"scroll-step": 5
|
||||
}
|
||||
}
|
196
laptop/configs/waybar/scripts/supower.py
Executable file
196
laptop/configs/waybar/scripts/supower.py
Executable file
@@ -0,0 +1,196 @@
|
||||
#!/usr/bin/python
|
||||
# pylint: disable=missing-module-docstring
|
||||
import json
|
||||
import sys
|
||||
import time
|
||||
import dbus
|
||||
import click
|
||||
|
||||
FBOOL = ('no', 'yes')
|
||||
PROPERTIES = {
|
||||
'BatteryLevel': ('unknown', 'none', 'low', 'critical', 'normal', 'high', 'full'),
|
||||
'Capacity': None,
|
||||
'Energy': None,
|
||||
'EnergyEmpty': None,
|
||||
'EnergyFull': None,
|
||||
'EnergyFullDesign': None,
|
||||
'EnergyRate': None,
|
||||
'HasHistory': FBOOL,
|
||||
'HasStatistics': FBOOL,
|
||||
'IconName': None,
|
||||
'IsPresent': FBOOL,
|
||||
'IsRechargeable': FBOOL,
|
||||
'Luminosity': None,
|
||||
'Model': None,
|
||||
'NativePath': None,
|
||||
'Online': FBOOL,
|
||||
'Percentage': None,
|
||||
'PowerSupply': FBOOL,
|
||||
'Serial': None,
|
||||
'State': ('unknown', 'charging', 'discharging', 'empty', 'fully charged',
|
||||
'pending charge','pending discharge'),
|
||||
'Technology': ('unknown', 'lithium ion', 'lithium polymer', 'lithium iron phosphate',
|
||||
'lead acid', 'nickel cadmium', 'nickel metal hydride'),
|
||||
'Temperature': None,
|
||||
'TimeToEmpty': None,
|
||||
'TimeToFull': None,
|
||||
'Type': ('unknown', 'line-power', 'battery', 'ups', 'monitor', 'mouse', 'keyboard',
|
||||
'pda', 'phone', 'media-player', 'tablet', 'computer', 'gaming_input',
|
||||
'pen', 'touchpad', 'modem', 'network', 'headset', 'speakers',
|
||||
'headphones', 'video', 'other_audio', 'remote_control', 'printer', 'scanner',
|
||||
'camera', 'wearable', 'toy', 'bluetooth-generic'),
|
||||
'UpdateTime': None,
|
||||
'Vendor': None,
|
||||
'Voltage': None,
|
||||
'WarningLevel': ('unknown', 'none', 'discharging', 'low', 'critical', 'action')
|
||||
}
|
||||
|
||||
|
||||
def get_tooltip(_type):
|
||||
#TOOLTIP_OTHER=""" luminosity: {Luminosity}""" I don't have a way to test this property
|
||||
header = ('native-path: {NativePath}'
|
||||
'\npower supply: {PowerSupply}'
|
||||
'\nupdated: {UpdateTime}'
|
||||
'\nhas history: {HasHistory}'
|
||||
'\nhas statistics: {HasStatistics}')
|
||||
|
||||
body = ('\n{Type}'
|
||||
'\n warning-level: {WarningLevel}'
|
||||
'\n icon-name: {IconName}')
|
||||
|
||||
if _type == 'line-power':
|
||||
body += '\n online: {Online}'
|
||||
|
||||
else:
|
||||
header += ('\nmodel: {Model}'
|
||||
'\nserial: {Serial}')
|
||||
|
||||
body += ('\n percentage: {Percentage}%'
|
||||
'\n present: {IsPresent}')
|
||||
|
||||
if _type == "battery":
|
||||
header += ('\nvendor: {Vendor}')
|
||||
body += ('\n state: {State}'
|
||||
'\n rechargeable: {IsRechargeable}'
|
||||
'\n energy: {Energy} Wh'
|
||||
'\n energy-empty: {EnergyEmpty} Wh'
|
||||
'\n energy-full: {EnergyFull} Wh'
|
||||
'\n energy-full-design: {EnergyFullDesign} Wh'
|
||||
'\n energy-rate: {EnergyRate} W'
|
||||
'\n voltage: {Voltage} V'
|
||||
'\n capacity: {Capacity}%'
|
||||
'\n technology: {Technology}'
|
||||
'\n temperature: {Temperature}'
|
||||
'\n time-to-empty: {TimeToEmpty}'
|
||||
'\n time-to-full: {TimeToFull}'
|
||||
'\n battery-level: {BatteryLevel}')
|
||||
|
||||
return f'{header}{body}'
|
||||
|
||||
|
||||
def device_info(bus, device):
|
||||
"""Lookup device properties"""
|
||||
result = {}
|
||||
device_proxy = bus.get_object('org.freedesktop.UPower', device)
|
||||
device_interface = dbus.Interface(device_proxy, 'org.freedesktop.DBus.Properties')
|
||||
for _property, friendly_name in PROPERTIES.items():
|
||||
try:
|
||||
data = device_interface.Get('org.freedesktop.UPower.Device', _property)
|
||||
if _property == 'UpdateTime':
|
||||
result[_property] = time.ctime(data)
|
||||
else:
|
||||
result[_property] = friendly_name[data] if friendly_name else data
|
||||
except (dbus.exceptions.DBusException, IndexError):
|
||||
result[_property] = 'none'
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def get_devices(bus):
|
||||
"""Retrieve list of Upower devices"""
|
||||
devices_proxy = bus.get_object('org.freedesktop.UPower', '/org/freedesktop/UPower')
|
||||
devices_interface = dbus.Interface(devices_proxy, 'org.freedesktop.UPower')
|
||||
devices = devices_interface.EnumerateDevices()
|
||||
|
||||
return devices
|
||||
|
||||
|
||||
def get_device(bus, devices, device):
|
||||
"""Retrieve Upower device using path or model"""
|
||||
|
||||
if device in devices:
|
||||
return device
|
||||
|
||||
for path in devices:
|
||||
inspect = device_info(bus, path)
|
||||
if inspect.get('Model') == device:
|
||||
return path
|
||||
|
||||
raise Exception("Device Not Found")
|
||||
|
||||
|
||||
def output_devices(bus, devices):
|
||||
"""Output device list"""
|
||||
for device in devices:
|
||||
print(f'{device}\t{device_info(bus, device).get("Model")}')
|
||||
sys.exit(0)
|
||||
|
||||
def check_device(key, info):
|
||||
sys.exit(FBOOL.index(info.get(key.replace('{','').replace('}', ''))))
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option('--list-devices', is_flag=True, help='List devices and models')
|
||||
@click.option('--check', help='Exists using boolean values for device')
|
||||
@click.option('--device', '--model', help='Path or Model')
|
||||
@click.option('--text', show_default=True, default="{Model}")
|
||||
@click.option('--alt', show_default=True, default="{BatteryLevel}")
|
||||
@click.option('--tooltip', default=None, help="Similar to upower -i <device>")
|
||||
@click.option('--class', '_class', show_default=True, default="{BatteryLevel}")
|
||||
@click.option('--percentage', show_default=True, default="{Percentage:.0f}")
|
||||
def main(list_devices, check, device, text, alt, tooltip, _class, percentage):
|
||||
"""
|
||||
TEXT can be replaced using one or more {KEY}\n
|
||||
{BatteryLevel} {Capacity} {Energy} {EnergyEmpty} {EnergyFull}
|
||||
{EnergyFullDesign} {EnergyRate} {HasHistory} {HasStatistics}
|
||||
{IconName} {IsPresent} {IsRechargeable} {Luminosity}
|
||||
{Model} {NativePath} {Online} {Percentage} {PowerSupply}
|
||||
{Serial} {State} {Technology} {Temperature} {TimeToEmpty}
|
||||
{TimeToFull} {Type} {UpdateTime} {Vendor} {Voltage}
|
||||
{WarningLevel}
|
||||
|
||||
Example: supower.py --model 'MX Master 2S' --tooltip '{State}'
|
||||
supower.py --model '/org/freedesktop/UPower/devices/line_power_AC' --check Online
|
||||
|
||||
"""
|
||||
exit = 0
|
||||
bus = dbus.SystemBus()
|
||||
devices = get_devices(bus)
|
||||
|
||||
if list_devices:
|
||||
output_devices(bus, devices)
|
||||
|
||||
try:
|
||||
device = get_device(bus, devices, device)
|
||||
info = device_info(bus, device)
|
||||
if check:
|
||||
check_device(check, info)
|
||||
|
||||
output = {
|
||||
"text": text.format(**info),
|
||||
"alt": alt.format(**info),
|
||||
"tooltip": (tooltip if tooltip else get_tooltip(info['Type'])).format(**info),
|
||||
"class": _class.format(**info),
|
||||
"percentage": float(percentage.format(**info))
|
||||
}
|
||||
except Exception as error:
|
||||
output = {"text": f'Error {device.split("/")[-1]} {error}', 'tooltip': f'{error}'}
|
||||
exit = 2
|
||||
|
||||
print(json.dumps(output))
|
||||
sys.exit(exit)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# pylint: disable=no-value-for-parameter
|
||||
main()
|
135
laptop/configs/waybar/style.css
Executable file
135
laptop/configs/waybar/style.css
Executable file
@@ -0,0 +1,135 @@
|
||||
* {
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
font-family: 'FluentSystemIcons-Regular,Comfortaa', monospace;
|
||||
font-weight: 600;
|
||||
font-size: 16px;
|
||||
min-height: 0;
|
||||
margin-left: 3px;
|
||||
margin-right: 3px;
|
||||
}
|
||||
|
||||
window#waybar {
|
||||
background: rgba(0, 0, 0, 0);
|
||||
color: #cdd6f4;
|
||||
}
|
||||
|
||||
tooltip {
|
||||
background: #1e1e2e;
|
||||
border-radius: 10px;
|
||||
border-width: 2px;
|
||||
border-style: solid;
|
||||
border-color: #11111b;
|
||||
}
|
||||
|
||||
#workspaces button {
|
||||
padding: 3px;
|
||||
color: #313244;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
#workspaces button.active {
|
||||
color: #a6adc8;
|
||||
}
|
||||
|
||||
#workspaces button.focused {
|
||||
color: #a6adc8;
|
||||
background: #eba0ac;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
#workspaces button.urgent {
|
||||
color: #11111b;
|
||||
background: #a6e3a1;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
#workspaces button:hover {
|
||||
background: #11111b;
|
||||
color: #cdd6f4;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
#workspaces {
|
||||
background: #1e1e2e;
|
||||
border-radius: 10px;
|
||||
margin-left: 10px;
|
||||
padding-right: 0px;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
#window,
|
||||
#clock,
|
||||
#custom-powerMenu,
|
||||
#pulseaudio,
|
||||
#memory,
|
||||
#battery,
|
||||
#backlight,
|
||||
#tray,
|
||||
#network,
|
||||
#workspaces,
|
||||
#cpu {
|
||||
background: #000024;
|
||||
padding: 2px 12px;
|
||||
margin: 3px 2px;
|
||||
margin-top: 9px;
|
||||
border: 1px solid #181825;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
#tray {
|
||||
border-radius: 10px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
#cpu {
|
||||
margin-right: 0;
|
||||
border-radius: 10px 0px 0px 10px;
|
||||
background-color: #222244;
|
||||
}
|
||||
|
||||
#memory, #battery {
|
||||
color: #89b4fa;
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
border-radius: 0px;
|
||||
background-color: #222244;
|
||||
}
|
||||
|
||||
#backlight {
|
||||
color: #89b4fa;
|
||||
margin-left: 0;
|
||||
border-radius: 0px 10px 10px 0px;
|
||||
background-color: #222244;
|
||||
}
|
||||
|
||||
#battery.critical {
|
||||
color: orange;
|
||||
}
|
||||
|
||||
#battery.empty {
|
||||
color: red;
|
||||
}
|
||||
|
||||
#window {
|
||||
border-radius: 10px;
|
||||
margin-left: 60px;
|
||||
margin-right: 60px;
|
||||
}
|
||||
|
||||
#clock {
|
||||
color: #a6f7ad;
|
||||
min-width: 145px;
|
||||
}
|
||||
|
||||
#pulseaudio {
|
||||
color: #89b4fa;
|
||||
border-left: 0px;
|
||||
border-right: 0px;
|
||||
}
|
||||
|
||||
#pulseaudio.microphone {
|
||||
color: #a6f7ad;
|
||||
border-left: 0px;
|
||||
border-right: 0px;
|
||||
}
|
Reference in New Issue
Block a user