Bug fixes, custom config

This commit is contained in:
piotr
2021-01-28 03:37:49 +01:00
parent b3701fc60e
commit 7f7ae1132b
7 changed files with 131 additions and 183 deletions

View File

@@ -19,7 +19,7 @@ dependencies = {
"netifaces": False,
}
icons_path = "icons_light" # "icons_light", "icons_dark" or "" (GTK icons)
icons_path = "" # "icons_light", "icons_dark" or "" (GTK icons)
commands = {
"get_battery": "upower -i $(upower -e | grep BAT) | grep --color=never -E 'state|to\\\\ full|to\\\\ empty|percentage'",

View File

@@ -1,158 +1,27 @@
[
{
"output": "eDP-1",
"layer": "bottom",
"position": "bottom",
"width": 1920,
"height": 30,
"margin-top": 0,
"margin-bottom": 0,
"padding-horizontal": 10,
"padding-vertical": 0,
"spacing": 4,
"items-padding": 0,
"css-name": "all-bottom",
"focus": true,
"modules-left": [
"sway-taskbar"
],
"modules-center": [],
"modules-right": [
"executor-cpuav",
"executor-cpubar",
"executor-temp",
"executor-memory",
"executor-drives",
"executor-uptime"
],
"sway-taskbar": {
"workspace-buttons": false,
"show-app-icon": true,
"show-layout": true,
"show-app-name": true,
"name-max-len": 15,
"workspaces-spacing": 0,
"task-spacing": 0,
"all-outputs": false
},
"sway-workspaces": {
"numbers": [3, 4]
},
"executor-cpubar": {
"script": "psuinfo -Cg",
"interval": 2
},
"executor-cpuav": {
"script": "psuinfo -Ca",
"interval": 2
},
"executor-temp": {
"script": "psuinfo -It",
"interval": 5
},
"executor-memory": {
"script": "psuinfo -IM",
"interval": 5
},
"executor-drives": {
"script": "psuinfo -IN",
"interval": 15
},
"executor-uptime": {
"script": "psuinfo -Iu",
"interval": 60
}
},
{
"output": "DP-1",
"layer": "top",
"position": "bottom",
"width": 1920,
"height": 30,
"margin-top": 0,
"margin-bottom": 0,
"padding-horizontal": 4,
"padding-vertical": 0,
"spacing": 6,
"css-name": "all-bottom",
"modules-left": [
"sway-taskbar"
],
"modules-center": [],
"modules-right": ["executor-traffic"],
"sway-taskbar": {
"workspace-buttons": false,
"show-app-icon": true,
"show-layout": true,
"show-app-name": true,
"name-max-len": 20,
"workspaces-spacing": 0,
"task-spacing": 0,
"all-outputs": false
},
"sway-workspaces": {
"numbers": [1, 2]
},
"executor-traffic": {
"script": "psuinfo -Ik",
"interval": 3
}
},
{
"output": "HDMI-A-1",
"layer": "top",
"position": "bottom",
"width": 1920,
"height": 30,
"margin-top": 0,
"margin-bottom": 0,
"padding-horizontal": 4,
"padding-vertical": 0,
"spacing": 6,
"css-name": "all-bottom",
"modules-left": [
"sway-taskbar"
],
"modules-center": [],
"modules-right": [],
"sway-taskbar": {
"workspace-buttons": false,
"show-app-icon": true,
"show-layout": true,
"show-app-name": true,
"name-max-len": 20,
"workspaces-spacing": 0,
"task-spacing": 0,
"all-outputs": false
}
},
{
"output": "eDP-1",
"output": "",
"layer": "bottom",
"position": "top",
"width": 1920,
"height": 30,
"homogeneous": true,
"margin-top": 0,
"margin-bottom": 0,
"padding-horizontal": 0,
"padding-vertical": 0,
"spacing": 4,
"controls": true,
"spacing": 0,
"items-padding": 0,
"css-name": "primary-top",
"icons": "light",
"controls": true,
"modules-left": [
"button-grid",
"playerctl"
"playerctl"
],
"modules-center": [
"executor-weather",
"clock"
],
"modules-right": ["executor-github", "executor-arch"],
"modules-right": [],
"sway-taskbar": {
"workspace-buttons": false,
"show-app-icon": true,
@@ -165,70 +34,136 @@
},
"controls-settings": {
"alignment": "right",
"show-values": false,
"interval": 1,
"icon-size": 16,
"hover-opens": true,
"css-name": "controls-window",
"net-interface": "wlo1",
"components": [
"net",
"brightness",
"volume",
"bluetooth",
"battery"
],
"commands": {
"battery": "",
"net": ""
"net": "",
"bluetooth": "",
"battery": ""
},
"custom-items": [
{ "name": "Wallpapers", "icon": "azote", "cmd": "azote" },
{ "name": "Look & Feel", "icon": "preferences-desktop-theme", "cmd": "lxappearance" }
{
"name": "Wallpapers",
"icon": "azote",
"cmd": "azote"
},
{
"name": "Look & Feel",
"icon": "preferences-desktop-theme",
"cmd": "lxappearance"
}
],
"menu": {
"name": "Exit",
"icon": "system-shutdown-symbolic",
"items": [
{ "name": "Lock", "cmd": "swaylock -f -c 000000" },
{ "name": "Logout", "cmd": "swaymsg exit" },
{ "name": "Reboot", "cmd": "systemctl reboot" },
{ "name": "Shutdown", "cmd": "systemctl -i poweroff" }
]
},
"show-values": false,
"interval": 1,
"icon-size": 16,
"css-name": "controls-window",
"net-interface": "wlo1"
},
"button-grid": {
"icon": "view-grid",
"command": "nwggrid -p",
"css-name": "button-grid"
{
"name": "Lock",
"cmd": "swaylock -f -c 000000"
},
{
"name": "Logout",
"cmd": "swaymsg exit"
},
{
"name": "Reboot",
"cmd": "systemctl reboot"
},
{
"name": "Shutdown",
"cmd": "systemctl -i poweroff"
}
]
}
},
"playerctl": {
"interval": 1,
"buttons": true,
"buttons-position": "left",
"chars": 50,
"css-name": "button-grid"
"label-css-name": "",
"button-css-name": "",
"icon-size": 16
},
"clock": {
"format": "%a, %d. %b %H:%M:%S",
"interval": 1,
"on-right-click": "/home/piotr/PycharmProjects/swayinfo/calendar.py"
"on-left-click": "",
"css-name": "clock",
"tooltip-text": "",
"on-right-click": "",
"on-middle-click": "",
"on-scroll-up": "",
"on-scroll-down": ""
},
"executor-weather": {
"script": "curl https://wttr.in/?format=1 -s",
"interval": 1800,
"css-name": "weather",
"on-right-click": "/home/piotr/PycharmProjects/swayinfo/calendar.py"
},
"executor-arch": {
"script": "/home/piotr/.config/nwg-panel/executors/arch_updates.py",
"interval": 900,
"on-right-click": "",
"icon-size": 16,
"on-left-click": "lxterminal -e \"/home/piotr/PycharmProjects/swayinfo/au.sh; swaymsg reload\""
"show-icon": false,
"tooltip-text": "",
"on-left-click": "",
"on-middle-click": "",
"on-scroll-up": "",
"on-scroll-down": ""
}
},
{
"output": "",
"layer": "bottom",
"position": "bottom",
"height": 30,
"homogeneous": false,
"margin-top": 0,
"margin-bottom": 0,
"padding-horizontal": 6,
"padding-vertical": 0,
"spacing": 0,
"items-padding": 0,
"css-name": "",
"icons": "light",
"controls": false,
"modules-left": [
"sway-taskbar"
],
"modules-center": [],
"modules-right": [
"executor-uptime"
],
"sway-taskbar": {
"workspace-buttons": false,
"show-app-icon": true,
"show-layout": true,
"show-app-name": true,
"name-max-len": 20,
"workspaces-spacing": 0,
"task-spacing": 0,
"all-outputs": true
},
"executor-github": {
"script": "/home/piotr/.config/nwg-panel/executors/github.sh",
"executor-uptime": {
"script": "uname -sr",
"interval": 60,
"css-name": "",
"on-right-click": "",
"icon-size": 16,
"on-left-click": "chromium https://github.com/notifications; swaymsg reload"
"show-icon": false,
"tooltip-text": "",
"on-left-click": "",
"on-middle-click": "",
"on-scroll-up": "",
"on-scroll-down": ""
}
}
]

View File

@@ -2,7 +2,7 @@ button {
margin: 2px;
}
#button-grid {
#button-custom {
background: rgba (255, 255, 255, 0.0);
border: 0
}

View File

@@ -59,7 +59,11 @@ def check_tree():
def instantiate_content(panel, container, content_list):
check_key(panel, "items-padding", 0)
check_key(panel, "icons", "light")
check_key(panel, "icons", "")
if panel["icons"] == "light":
common.icons_path = "icons_light"
elif panel["icons"] == "dark":
common.icons_path = "icons_dark"
for item in content_list:
if item == "sway-taskbar":
@@ -174,10 +178,16 @@ def main():
if panel["css-name"]:
window.set_property("name", panel["css-name"])
if "output" not in panel or not panel["output"]:
display = Gdk.Display.get_default()
monitor = display.get_monitor(0)
for key in common.outputs:
if common.outputs[key]["monitor"] == monitor:
panel["output"] = key
# If not full screen width demanded explicit, let's leave 6 pixel of margin on both sides on multi-headed
# setups. Otherwise moving the pointer between displays over the panels remains undetected,
# and the Controls window may appear on the previous output.
if "output" in panel and "width" not in panel:
if "output" in panel and panel["output"] and "width" not in panel:
panel["width"] = common.outputs[panel["output"]]["width"] - 12
check_key(panel, "width", 0)

View File

@@ -85,11 +85,11 @@ class Clock(Gtk.EventBox):
self.get_style_context().set_state(Gtk.StateFlags.NORMAL)
def on_button_press(self, widget, event):
if event.button == 3 and self.settings["on-left-click"]:
if event.button == 1 and self.settings["on-left-click"]:
self.launch(self.settings["on-left-click"])
elif event.button == 2 and self.settings["on-middle-click"]:
self.launch(self.settings["on-middle-click"])
elif event.button == 1 and self.settings["on-right-click"]:
elif event.button == 3 and self.settings["on-right-click"]:
self.launch(self.settings["on-right-click"])
def on_scroll(self, widget, event):

View File

@@ -27,20 +27,21 @@ class Playerctl(Gtk.EventBox):
self.label = Gtk.Label("")
self.icon_path = None
self.play_pause_btn = Gtk.Button()
check_key(settings, "button-css-name", "")
if self.settings["button-css-name"]:
self.play_pause_btn.set_property("name", self.settings["button-css-name"])
self.status = ""
self.retries = 2 # to avoid hiding the module on forward / backward btn when playing from the browser
check_key(settings, "interval", 0)
check_key(settings, "css-name", "")
check_key(settings, "label-css-name", "")
check_key(settings, "button-css-name", "")
check_key(settings, "icon-size", 16)
check_key(settings, "buttons", True)
check_key(settings, "buttons-position", "left")
check_key(settings, "chars", 30)
if settings["css-name"]:
self.label.set_property("name", settings["css-name"])
else:
self.label.set_property("name", "executor-label")
if settings["label-css-name"]:
self.label.set_property("name", settings["label-css-name"])
self.build_box()
@@ -90,11 +91,13 @@ class Playerctl(Gtk.EventBox):
def build_box(self):
button_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
img = Gtk.Image()
update_image(img, "media-skip-backward-symbolic", self.settings["icon-size"])
btn = Gtk.Button()
btn.set_image(img)
if self.settings["button-css-name"]:
btn.set_property("name", self.settings["button-css-name"])
btn.connect("clicked", self.launch, "playerctl previous")
button_box.pack_start(btn, False, False, 1)
@@ -108,6 +111,8 @@ class Playerctl(Gtk.EventBox):
update_image(img, "media-skip-forward-symbolic", self.settings["icon-size"])
btn = Gtk.Button()
btn.set_image(img)
if self.settings["button-css-name"]:
btn.set_property("name", self.settings["button-css-name"])
btn.connect("clicked", self.launch, "playerctl next")
button_box.pack_start(btn, False, False, 1)

View File

@@ -174,8 +174,6 @@ def list_outputs():
print("'wlr-randr' command not found, terminating")
sys.exit(1)
display = Gdk.Display.get_default()
for i in range(display.get_n_monitors()):
monitor = display.get_monitor(i)