Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special workspace support in HyprlandTaskbar #228

Merged
merged 9 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions nwg_panel/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@
"show-layout": True,
"all-outputs": False,
"mark-xwayland": True,
"workspace-clickable": False,
"angle": 0.0
},
"sway-workspaces": {
Expand Down Expand Up @@ -1342,10 +1341,10 @@ def edit_hyprland_taskbar(self, *args):
"client-padding": 0,
"show-app-icon": True,
"show-app-name": True,
"show-app-name-special": False,
"show-layout": True,
"all-outputs": False,
"mark-xwayland": True,
"workspace-clickable": False,
"angle": 0.0
}
for key in defaults:
Expand Down Expand Up @@ -1393,14 +1392,14 @@ def edit_hyprland_taskbar(self, *args):
self.ckb_show_app_name.set_label(voc["show-name"])
self.ckb_show_app_name.set_active(settings["show-app-name"])

self.ckb_show_app_name_special = builder.get_object("show-app-name-special")
self.ckb_show_app_name_special.set_label(voc["show-name-on-special"])
self.ckb_show_app_name_special.set_active(settings["show-app-name-special"])

self.ckb_show_layout = builder.get_object("show-layout")
self.ckb_show_layout.set_label(voc["mark-floating-pinned"])
self.ckb_show_layout.set_active(settings["show-layout"])

self.workspace_clickable = builder.get_object("workspace-clickable")
self.workspace_clickable.set_label(voc["workspaces-clickable"])
self.workspace_clickable.set_active(settings["workspace-clickable"])

self.ckb_mark_xwayland = builder.get_object("mark-xwayland")
self.ckb_mark_xwayland.set_label(voc["mark-xwayland"])
self.ckb_mark_xwayland.set_active(settings["mark-xwayland"])
Expand Down Expand Up @@ -1438,9 +1437,8 @@ def update_hyprland_taskbar(self):

settings["show-app-icon"] = self.ckb_show_app_icon.get_active()
settings["show-app-name"] = self.ckb_show_app_name.get_active()
settings["show-app-name-special"] = self.ckb_show_app_name_special.get_active()
settings["show-layout"] = self.ckb_show_layout.get_active()
settings["workspace-clickable"] = self.workspace_clickable.get_active()
# settings["mark-autotiling"] = self.ckb_mark_autotiling.get_active()
settings["mark-xwayland"] = self.ckb_mark_xwayland.get_active()
settings["all-outputs"] = self.ckb_all_outputs.get_active()

Expand Down
20 changes: 9 additions & 11 deletions nwg_panel/glade/config_hyprland_taskbar.glade
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,16 @@
</packing>
</child>
<child>
<object class="GtkCheckButton" id="workspace-clickable">
<property name="label" translatable="yes">Workspaces clickable</property>
<object class="GtkCheckButton" id="all-outputs">
<property name="label" translatable="yes">All outputs</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="halign">start</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="left-attach">0</property>
<property name="top-attach">7</property>
</packing>
</child>
Expand All @@ -174,21 +174,22 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">6</property>
<property name="top-attach">7</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="all-outputs">
<property name="label" translatable="yes">All outputs</property>
<object class="GtkCheckButton" id="show-app-name-special">
<property name="label" translatable="yes">Show name on special workspace</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="halign">start</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">7</property>
<property name="left-attach">1</property>
<property name="top-attach">6</property>
<property name="width">2</property>
</packing>
</child>
<child>
Expand Down Expand Up @@ -250,9 +251,6 @@ the horizontal, in degrees, measured counterclockwise</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
<child type="label">
Expand Down
1 change: 1 addition & 0 deletions nwg_panel/langs/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@
"show-layout": "Show layout",
"show-location-name": "Show location name",
"show-name": "Show name",
"show-name-on-special": "Show name on special workspace",
"show-precipitation-probability": "Show precipitation probability",
"show-precipitation-volume": "Show precipitation volume",
"show-pressure": "Show pressure",
Expand Down
1 change: 1 addition & 0 deletions nwg_panel/langs/pl_PL.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@
"show-layout": "Pokazuj układ",
"show-location-name": "Pokazuj nazwę lokalizacji",
"show-name": "Pokazuj nazwę",
"show-name-on-special": "Pokazuj nazwę w specjalnym obszarze",
"show-precipitation-probability": "Pokazuj prawdopodobieństwo opadów",
"show-precipitation-volume": "Pokazuj objętość opadów",
"show-pressure": "Pokazuj ciśnienie",
Expand Down
4 changes: 2 additions & 2 deletions nwg_panel/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def hypr_watcher():

event_name = e_full_string.split(">>")[0]

if event_name in ["monitoradded", "openwindow"]:
if event_name in ["monitoradded", "openwindow", "movewindow"]:
monitors, workspaces, clients, activewindow = h_modules_get_all()
for item in common.h_taskbars_list:
GLib.timeout_add(0, item.refresh, monitors, workspaces, clients, activewindow)
Expand All @@ -185,7 +185,7 @@ def hypr_watcher():
last_client_addr = client_addr
continue

if event_name == "activewindow" and client_title != last_client_title:
if event_name == "activewindow":
monitors, workspaces, clients, activewindow = h_modules_get_all()
for item in common.h_taskbars_list:
GLib.timeout_add(0, item.refresh, monitors, workspaces, clients, activewindow)
Expand Down
52 changes: 30 additions & 22 deletions nwg_panel/modules/hyprland_taskbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
class HyprlandTaskbar(Gtk.Box):
def __init__(self, settings, position, monitors, workspaces, clients, activewindow, display_name="", icons_path=""):
defaults = {
"workspace-clickable": False,
"name-max-len": 24,
"image-size": 16,
"workspaces-spacing": 0,
"client-padding": 0,
"show-app-icon": True,
"show-app-name": True,
"show-app-name-special": False,
"show-layout": True,
"all-outputs": False,
"mark-xwayland": True,
Expand Down Expand Up @@ -58,17 +58,19 @@ def parse_workspaces(self, ws):
self.workspaces[item["id"]] = item
self.ws_nums.sort()

def parse_clients(self, all_clients):
self.clients = []
for c in all_clients:
if c["monitor"] >= 0:
if (self.mon_id2name[c["monitor"]] == self.display_name) or self.settings["all-outputs"]:
self.clients.append(c)
# def parse_clients(self, all_clients):
# self.clients = []
# for c in all_clients:
# if c["monitor"] >= 0:
# if (self.mon_id2name[c["monitor"]] == self.display_name) or self.settings["all-outputs"]:
# self.clients.append(c)

def refresh(self, monitors, workspaces, clients, activewindow):
self.parse_monitors(monitors)
self.parse_workspaces(workspaces)
self.parse_clients(clients)
# Turned off due to https://github.com/hyprwm/Hyprland/issues/2413
# self.parse_clients(clients)
self.clients = clients
self.activewindow = activewindow
for item in self.get_children():
item.destroy()
Expand All @@ -83,10 +85,10 @@ def build_box(self):
self.pack_start(ws_box, False, False, 0)
if self.workspaces[ws_num]["monitor"] == self.display_name or self.settings["all-outputs"]:
eb = Gtk.EventBox()
if self.settings["workspace-clickable"]:
eb.connect('enter-notify-event', on_enter_notify_event)
eb.connect('leave-notify-event', on_leave_notify_event)
eb.connect('button-press-event', self.on_ws_click, ws_num)
# if self.settings["workspace-clickable"]:
# eb.connect('enter-notify-event', on_enter_notify_event)
# eb.connect('leave-notify-event', on_leave_notify_event)
# eb.connect('button-press-event', self.on_ws_click, ws_num)

ws_box.pack_start(eb, False, False, 6)
lbl = Gtk.Label()
Expand All @@ -110,7 +112,7 @@ def build_box(self):
self.show_all()

def on_ws_click(self, widget, event, ws_num):
hyprctl("dispatch workspace {}".format(ws_num))
hyprctl("dispatch workspace name:{}".format(ws_num))


def on_enter_notify_event(widget, event):
Expand All @@ -137,23 +139,26 @@ def __init__(self, settings, client, position, icons_path):

self.connect('enter-notify-event', on_enter_notify_event)
self.connect('leave-notify-event', on_leave_notify_event)
self.connect('button-press-event', self.on_click, client, self.box)
if client["workspace"]["name"] == "special":
self.connect('button-press-event', self.on_special)
else:
self.connect('button-press-event', self.on_click, client, self.box)

if settings["show-app-icon"]:
name = client["class"]

image = Gtk.Image()
update_image_fallback_desktop(image, name, settings["image-size"], icons_path)
self.box.pack_start(image, False, False, 4)

if settings["show-app-name"]:
lbl = Gtk.Label()
lbl.set_angle(self.settings["angle"])
name = client["title"][:settings["name-max-len"]]
if settings["mark-xwayland"] and client["xwayland"]:
name = "X|" + name
lbl.set_text(name)
self.box.pack_start(lbl, False, False, 6)
if not client["workspace"]["name"] == "special" or settings["show-app-name-special"]:
lbl = Gtk.Label()
lbl.set_angle(self.settings["angle"])
name = client["title"][:settings["name-max-len"]]
if settings["mark-xwayland"] and client["xwayland"]:
name = "X|" + name
lbl.set_text(name)
self.box.pack_start(lbl, False, False, 6)

if settings["show-layout"]:
if client["pinned"]:
Expand All @@ -177,6 +182,9 @@ def on_click(self, widget, event, client, popup_at_widget):
else:
menu.popup_at_widget(popup_at_widget, Gdk.Gravity.NORTH, Gdk.Gravity.SOUTH, None)

def on_special(self, widget, event):
hyprctl('dispatch togglespecialworkspace ')

def context_menu(self, client):
menu = Gtk.Menu()
menu.set_reserve_toggle_size(False)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def read(f_name):

setup(
name='nwg-panel',
version='0.9.4',
version='0.9.5',
description='GTK3-based panel for sway and Hyprland Wayland compositors',
packages=find_packages(),
include_package_data=True,
Expand Down