The error:
File "/home/zorionten/Programs/Tests/dock/dockspace.py", line 16, in reserve_space
self._window.change_property(self._display.intern_atom('_NET_WM_STRUT'),
File "/home/zorionten/.local/lib/python3.8/site-packages/Xlib/xobject/drawable.py", line 430, in change_property
request.ChangeProperty(display = self.display,
File "/home/zorionten/.local/lib/python3.8/site-packages/Xlib/protocol/rq.py", line 1347, in __init__
self._binary = self._request.to_binary(*args, **keys)
File "/home/zorionten/.local/lib/python3.8/site-packages/Xlib/protocol/rq.py", line 1069, in to_binary
static_part = struct.pack(self.static_codes, *pack_items)
struct.error: required argument is not an integer
dockspace.py
from Xlib import display, X
class Window(object):
def __init__(self, windowID):
self._display = display.Display()
self._window = self._display.create_resource_object('window', windowID)
def reserve_space(self, left=0, right=0, top=0, bottom=0):
LEFT = left
RIGHT = right
TOP = top
BOTTOM = bottom
self._window.change_property(self._display.intern_atom('_NET_WM_STRUT'),
self._display.intern_atom('CARDINAL'),
32, [LEFT, RIGHT, TOP, BOTTOM])
self._display.sync()
I am making a dock (like plank) using python3. The problem arrives when trying to reserve desktop scpave for the dock. I f there is an alternative .. I'm all ears Thanks
EDIT:
After further experimentation I found out that the error is retrieving the X window id of the "dock window" that I create through GTK+3 in the main py file
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GLib, Gdk, GdkX11
from datetime import datetime
import dockspace
class window(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self,title="Test")
self.button_exit=Gtk.Button(label="Exit")
self.button_exit.connect("clicked",self.onClick)
self.clock=Gtk.Label()
self.addWidgets()
GLib.timeout_add(1000, self.updateClock)
self.set_resizable(False)
self.move(0,0)
self.set_default_size(1920,24)
def addWidgets(self):
self.box=Gtk.Box(spacing=5)
self.box.pack_start(self.button_exit,False,True,10)
self.box.pack_start(self.clock,expand=True,fill=False,padding=10)
self.add(self.box)
def onClick(self,widget):
Gtk.main_quit()
def updateClock(self):
self.clock.set_label(datetime.now().strftime("%H:%M:%S %p"))
return True
def fix_window(self):
set = False
while set == False:
try:
window = dockspace.Window('''window id needed''')
if window != None:
height = 24
window.reserve_space(0, 0, height, 0)
set = True
else:
self.sleep(1)
except:
raise
wi=window()
wi.connect("destroy",Gtk.main_quit)
wi.show_all()
wi.fix_window()
Gtk.main()
Solved it by using wmctrl -lp
command. Kills the cross platform compatibility but I wasnt aiming for that anyway.