XMonad not giving space for Tint2 bar - linux

I am currently setting up my new config for XMonad but I cannot get the docks to work.
https://hastebin.com/eqoliyodat.swift
The tint properties look like this.
WM_STATE(WM_STATE):
window state: Normal
icon window: 0x0
WM_NORMAL_HINTS(WM_SIZE_HINTS):
program specified location: 1559250944, -874843230
program specified minimum size: 127 by 42
program specified maximum size: 127 by 42
WM_CLASS(STRING) = "tint2", "Tint2"
XdndAware(ATOM) = ATOM
_MOTIF_WM_HINTS(_MOTIF_WM_HINTS) = 0x2, 0x0, 0x0, 0x0, 0x0
WM_HINTS(WM_HINTS):
Client accepts input or input focus: False
Initial state is Don't Care State.
window id # to use for icon: 0xe00003
window id # of group leader: 0xe00003
_NET_WM_STATE(ATOM) = _NET_WM_STATE_SKIP_PAGER, _NET_WM_STATE_SKIP_TASKBAR, _NET_WM_STATE_STICKY, _NET_WM_STATE_ABOVE
_NET_WM_DESKTOP(CARDINAL) = 4294967295
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_DOCK
_NET_WM_PID(CARDINAL) = 11648
_NET_WM_ICON_NAME(UTF8_STRING) = "tint2"
_NET_WM_NAME(UTF8_STRING) = "tint2"
WM_ICON_NAME(STRING) = "tint2"
WM_NAME(STRING) = "tint2"
I have no idea where this could be coming from, can somebody help me?
I was looking through the current threads, but didnt seem to find any other solution to my problem. I cant use the normal gaps, because I have multiple monitors but a bar only on one screen.
Best regards.

Related

Error when reading/writing from CAN and sensor simultaneously over I2C

I am using a can board and an IMU MPU6050 to be able use motors while also reading an angle from the IMU.
When using them separately it works, the IMU reads and the CAN can activate and run the motors. The issue arises when both are activated at the same time and the script gives the following error:
IOError: [Errno 5] Input/output error
Here are the registers:
# MPU6050 Registers
MPU6050_ADDR = 0x68#0x0c
PWR_MGMT_1 = 0x6B
SMPLRT_DIV = 0x19
CONFIG = 0x1A
GYRO_CONFIG = 0x1B
ACCEL_CONFIG = 0x1C
INT_PIN_CFG = 0x37
INT_ENABLE = 0x38
ACCEL_XOUT_H = 0x3B
ACCEL_YOUT_H = 0x3D
And fault messages arises when I try to write a byte to the IMU at the same time as the CAN bus is activated:
# Write to Configuration register
bus.write_byte_data(MPU6050_ADDR, CONFIG, 0)
I created a new I2C bus for the IMU which is bus #3 which gives me the addresses 0x68 and 0x0c.
I have checked the wiring which is correct. Otherwise I should get the same error when running them separately.
Does anyone have any suggestions on what to try next?

Micropython code displaying red-white noise on 1.54" ePaper display

I have the following code in micropython that is running on my Espressif ESP32-PICO-KIT. To this I have attached a WaveShare 1.54" ePaper display (supporting red color).
When I reach the last line the display updates in waves, but I only get white-red noise on the display.
I'm using the driver from mcauser/micropython-waveshare-epaper on Github.
This is my code:
from machine import Pin, SoftSPI
import epaper1in54b
miso = Pin(19)
sck = Pin(18) # yellow
mosi = Pin(23) # white
cs = Pin(5) # green
dc = Pin(25) # gray
rst = Pin(21) # orange
busy = Pin(19) # gray
spi = SoftSPI(baudrate=20000000, polarity=0, phase=0, sck=sck, mosi=mosi, miso=miso)
e = epaper1in54b.EPD(spi, cs, dc, rst, busy)
e.init()
w = 200
h = 200
x = 0
y = 0
import framebuf
buf = bytearray(w * h // 8)
fb = framebuf.FrameBuffer(buf, w, h, framebuf.MONO_VLSB)
black = 0
white = 1
red = 2
fb.fill(white)
fb.text('Hello world!', 0, 0,black)
e.display_frame(buf,None)
The result
Update:
I'm using MicroPython v1.16 on 2021-06-18; ESP32 module with ESP32.
Please note that I did file a new issue in the mcauser/micropython-waveshare-epaper repository.
Don't know anything about your Espressif ESP32-PICO-KIT, but the v4 datasheet says: "USB-UART bridge Single-chip USB-UART bridge: CP2102 in V4 provides up to 1 Mbps transfer rates and CP2102N in V4.1 offers up to 3 Mbps transfers rates."
The 20,000,000 value you have in SoftSPI looks VERY suspicious. Did you mean 2,000,000?
Edit: I just realied this isn't using USB-UART, rather SDIO/SPI. So, those rate limits above aren't relevant.

Console Screen Buffer Info shows incorrect X position

I recently found a great short code Why the irrelevant code made a difference? for obtaining console screen buffer info (which I include below) that replaces the huge code accompanying the standard 'CONSOLE_SCREEN_BUFFER_INFO()' method (which I won't include here!)
import ctypes
import struct
print("xxx",end="") # I added this to show what the problem is
hstd = ctypes.windll.kernel32.GetStdHandle(-11) # STD_OUTPUT_HANDLE = -11
csbi = ctypes.create_string_buffer(22)
res = ctypes.windll.kernel32.GetConsoleScreenBufferInfo(hstd, csbi)
width, height, curx, cury, wattr, left, top, right, bottom, maxx, maxy = struct.unpack("hhhhHhhhhhh", csbi.raw)
# The following two lines are also added
print() # To bring the cursor to next line for displaying infp
print(width, height, curx, cury, wattr, left, top, right, bottom, maxx, maxy) # Display what we got
Output:
80 250 0 7 7 0 0 79 24 80 43
This output is for Windows 10 MSDOS, with clearing the screen before running the code. However. 'curx' = 0 although it should be 3 (after printing "xxx"). The same phenomenon happens also with the 'CONSOLE_SCREEN_BUFFER_INFO()' method. Any idea what is the problem?
Also, any suggestion for a method of obtaining current cursor position -- besides 'curses' library -- will be welcome!
You need to flush the print buffer if you don't output a linefeed:
print("xxx",end="",flush=True)
Then I get the correct curx=3 with your code:
xxx
130 9999 3 0 14 0 0 129 75 130 76
BTW the original answer in the posted question is the "great" code. The "bitness" of HANDLE can break your code, and not defining .argtypes as a "shortcut" is usually the cause of most ctypes problems.

TinyX shows display using builtin fbtft touchscreen driver but touch doesn't work

I'm using an "adafruitts" touchscreen with a raspi to control a usb peripheral.
The full raspbian kernel takes forever to boot (50 seconds), and part of that is due to the touchscreen driver loading (by modprobe/udev) and initializing.
During the first 20-30 seconds of boot, the display is not loaded, so it is blank. I need this to be a user-friendly item that cannot be blank for 30 seconds each time it is turned on, so I've used buildroot to build a small kernel with the touchscreen driver built-in. (I am on a steep learning curve with buildroot and kernel building in general).
The display driver is fbtft_device.c patched to include the adafruitts display. This patch defines the "touch" half:
/* Touch device spi-half of adafruit touchscreen */
.name = "adafruitts",
.spi = &(struct spi_board_info) {
.modalias = "stmpe610",
.max_speed_hz = 500000,
.mode = SPI_MODE_0,
.chip_select = 1,
.platform_data = &(struct stmpe_platform_data) {
.blocks = STMPE_BLOCK_TOUCHSCREEN | STMPE_BLOCK_GPIO,
.irq_over_gpio = 1,
.irq_gpio = 24,
.irq_trigger = IRQF_TRIGGER_FALLING,
.irq_base = GPIO_IRQ_START + GPIO_IRQS,
.ts = &(struct stmpe_ts_platform_data) {
.sample_time = 4,
.mod_12b = 1,
.ref_sel = 0,
.adc_freq = 2,
.ave_ctrl = 3,
.touch_det_delay = 4,
.settling = 2,
.fraction_z = 7,
.i_drive = 0,
},
}
},
.is_support = 1,
.gpio_settings = (struct gpio_setting []) {
{
.gpio = 24,
.pull = pull_up,
}
},
.gpio_num_settings = 1,
},
and the LCD half:
}, {
/* LCD component of adafruit touchscreen */
.name = "adafruitts",
.spi = &(struct spi_board_info) {
.modalias = "fb_ili9340",
.max_speed_hz = 16000000,
.mode = SPI_MODE_0,
.chip_select = 0,
.platform_data = &(struct fbtft_platform_data) {
.display = {
.buswidth = 8,
.backlight = 1,
},
.bgr = true,
.gpios = (const struct fbtft_gpio []) {
{ "dc", 25 },
{},
},
}
}
}, {
by including:
fbtft_device.name=adafruitts
in the cmdline.txt for the boot loader, I've gotten the display half of the system to work (it boots in ~ 5 seconds :) ) with tinyX/matchbox desktop showing the desktop, but I cannot get the touchscreen part to work (the cursor does not move when I touch the screeen).
Somehow I have to bind the touch part of the touchscreen to tinyX, but I have not been able to figure out how to do this.
I have tried to specify the keyboard (and mouse) when launching tinyX:
X -keybd smpte610 (for example)
but X reports it cannot find the driver.
How can I verify the touch screen input device was successfully loaded?
The boot log has these messages about fbtft_device:
fbtft_device: SPI devices registered:
fbtft_device: spidev spi0.0 500kHz 8 bits mode=0x00
fbtft_device: spidev spi0.1 500kHz 8 bits mode=0x00
fbtft_device: 'fb' Platform devices registered:
fbtft_device: bcm2708_fb id=-1 pdata? no
fbtft_device: Deleting spi0.1 (spi0.1)
fbtft_device: Looking at item 0
fbtft_device: Setting pin 24 to 2
stmpe-spi: probe of spi0.1 failed with error -22
fbtft_device: Deleting spi0.0 (spi0.0)
Console: switching to colour frame buffer device 40x30
graphics fb0: fb_ili9340 frame buffer, 320x240, 150 KiB video memory, 16 KiB buffer memory, fps=20, spi0.0 at 16 MHz
fbtft_device: GPIOS used by 'adafruitts':
fbtft_device: 'dc' = GPIO25
fbtft_device: SPI devices registered:
fbtft_device: stmpe610 spi0.1 48000kHz 8 bits mode=0x00
fbtft_device: fb_ili9340 spi0.0 16000kHz 8 bits mode=0x00
kgdb: Registered I/O driver kgdboc.
Is the kgdb message associated with fbtft_device or something else?
If I look in /dev/input I see: event0, event1, and mice. event0 and event1 are associated with an attached keyboard (according to the boot log) and I have no mouse attached. Should there be some other items in input?
If the touch screen input device IS loaded, how to I specify the correct driver for tinyX?
Thanks
What I learned:
By comparing the boot messages in my modprobe/udev/module loading kernel with the fast built-in kernel, it shows:
stmpe-spi: probe of spi0.1 failed with error -22
is a "bad" thing.
A successful driver load will say (something like):
bcm2708_spi.0: registered child spi0.0
and then later:
input: stmpe-ts as /devices/virtual/input/input0
I fixed the "probe" failure by making these changes to my kernel configuration file. (Sorry, I don't want to include the whole thing, so these are the changes from when I had the issue to when the driver successfully loaded according to the syslog):
< Touch Did Not respond > Touch Did respond
> CONFIG_INPUT_FF_MEMLESS=y
< CONFIG_INPUT_POLLDEV=m > CONFIG_INPUT_POLLDEV=y
< CONFIG_INPUT_EVDEV=m > CONFIG_INPUT_EVDEV=y
< CONFIG_TOUCHSCREEN_STMPE=m > CONFIG_TOUCHSCREEN_STMPE=y
> CONFIG_KEYBOARD_STMPE=y
< CONFIG_SERIO=m > CONFIG_SERIO_SERPORT=m
> CONFIG_SPI_DEBUG=y
< CONFIG_SPI_SPIDEV=y
> CONFIG_SPI_GPIO=y
My main objective with these changes was to try to make sure that the dependent drivers were also built-in, and I enabled the debug. (Some of these were magically set by menuconfig, and this is diff from the "non-default" values from buildroot, so the diff is - different)
With this config, I now have event0, event1, event2, mice, and mouse0. The syslog says event1 and event2 are associated with the usb keyboard I have attached. I have no extra mouse attached.
I could use "evtest" to see events from /dev/input/event0 whenever I touched the display. evtest'ing /dev/input/mouse0 threw "Inappropriate ioctl for device"
I restarted X (tinyX) using:
X -mouse mouse,,/dev/input/mouse0
and touches worked, but the touch axis is rotated from the display axis.
I could not figure out a way to fix this in tinyX, so I'm going with a full blown Xorg implementation.
Make sure you have enabled the evdev input support in tinyx (BR2_PACKAGE_XSERVER_XORG_SERVER_KDRIVE_EVDEV) and use the syntax specified in hw/kdrive/src/kinput.c:
/*
* You can call your kdriver server with something like:
* $ ./hw/kdrive/yourserver/X :1 -mouse evdev,,device=/dev/input/event4 -keybd
* evdev,,device=/dev/input/event1,xkbmodel=abnt2,xkblayout=br
*/

Get number of opened application windows in linux

I want to detect how many instances of a specific application, managed by the window manager, are opened. At the moment, I have this:
#!/bin/bash
# wmctrl required
pids=$(pidof $1)
IFS=' ' read -a pid_arr <<< "$pids"
matches=0
for pid in "${pid_arr[#]}"
do
matching_lines=$(wmctrl -l -p | egrep -c "^.+\b.+\b$pid\b")
matches=$((matches + $matching_lines))
done
echo $matches
Say I have firefox open three times and I pass firefox as an argument, the function will only return the right number if there were no "sub-windows" (e.g. preference windows) opened. Otherwise, the function will count these windows too.
I want to get the number of windows without the "sub-windows".
P.S.: Made some changes. To count the number of windows without their dialog-windows, this is my current solution:
#!/bin/bash
pids=$(pidof $1)
IFS=' ' read -r -a pid_arr <<< "$pids"
matches=0
for pid in "${pid_arr[#]}"
do
ids=$(wmctrl -l -p | awk '$3=='$pid'{printf $1" "}')
IFS=' ' read -r -a id_arr <<< "$ids"
for id in "${id_arr[#]}"
do
if ! xprop -id "$id" |
egrep -q '(WM_TRANSIENT_FOR|_NET_WM_WINDOW_TYPE_DIALOG)'
then
((matches++))
fi
done
done
echo $matches
But in the case of firefox, the script cannot distinguish between the browser window and its preference window because none of them is a dialog window.
The above script is sufficient for me, because I use it to figure out how many windows (without dialog windows) of xfce4-appfinder are open. For xfce4-appfinder the script works, because its preference window can easily be recognized as a dialog window. In firefox the preference window can even be opened standalone by calling firefox -preferences. To recognize windows like this as some kind of "sub-window" is maybe impossible.
Here are my results of xprop and xwininfo for both the browser and preference window of firefox:
xwininfo (browser):
xwininfo: Window id: 0x1c0007f "bash - Get number of opened application windows in linux - Stack Overflow - Mozilla Firefox"
Root window id: 0xa1 (the root window) (has no name)
Parent window id: 0x1400048 (has no name)
1 child:
0x1c00080 (has no name): () 1x1+-1+-1 +1+37
Absolute upper-left X: 2
Absolute upper-left Y: 38
Relative upper-left X: 0
Relative upper-left Y: 14
Width: 956
Height: 511
Depth: 24
Visual: 0x20
Visual Class: TrueColor
Border width: 0
Class: InputOutput
Colormap: 0x22 (installed)
Bit Gravity State: NorthWestGravity
Window Gravity State: NorthWestGravity
Backing Store State: NotUseful
Save Under State: no
Map State: IsViewable
Override Redirect State: no
Corners: +2+38 -962+38 -962-531 +2-531
-geometry 956x511+0+22
Bit gravity: NorthWestGravity
Window gravity: NorthWestGravity
Backing-store hint: NotUseful
Backing-planes to be preserved: 0xffffffff
Backing pixel: 0
Save-unders: No
Someone wants these events:
KeyPress
KeyRelease
ButtonPress
ButtonRelease
EnterWindow
LeaveWindow
PointerMotion
Exposure
VisibilityChange
StructureNotify
FocusChange
PropertyChange
Do not propagate these events:
Override redirection?: No
Window manager hints:
Client accepts input or input focus: Yes
Initial state is Normal State
Displayed on desktop 0
Window type:
Normal
Process id: 792 on host T530
Normal window size hints:
Program supplied minimum size: 300 by 71
Program supplied maximum size: 32767 by 32767
Program supplied window gravity: NorthWestGravity
No zoom window size hints defined
No window shape defined
No border shape defined
xwininfo (preferences):
xwininfo: Window id: 0x1c046ef "Firefox Preferences"
Root window id: 0xa1 (the root window) (has no name)
Parent window id: 0x1400060 (has no name)
1 child:
0x1c046f0 (has no name): () 1x1+-1+-1 +961+37
Absolute upper-left X: 962
Absolute upper-left Y: 38
Relative upper-left X: 0
Relative upper-left Y: 14
Width: 956
Height: 1040
Depth: 24
Visual: 0x20
Visual Class: TrueColor
Border width: 0
Class: InputOutput
Colormap: 0x22 (installed)
Bit Gravity State: NorthWestGravity
Window Gravity State: NorthWestGravity
Backing Store State: NotUseful
Save Under State: no0x1c00001
Map State: IsViewable
Override Redirect State: no
Corners: +962+38 -2+38 -2-2 +962-2
-geometry 956x1040-0-0
Bit gravity: NorthWestGravity
Window gravity: NorthWestGravity
Backing-store hint: NotUseful
Backing-planes to be preserved: 0xffffffff
Backing pixel: 0
Save-unders: No
Someone wants these events:
KeyPress
KeyRelease
ButtonPress
ButtonRelease
EnterWindow
LeaveWindow
PointerMotion
Exposure
VisibilityChange
StructureNotify
FocusChange
PropertyChange
Do not propagate these events:
Override redirection?: No
Window manager hints:
Client accepts input or input focus: Yes
Initial state is Normal State
Displayed on desktop 0
Window type:
Normal
Process id: 792 on host T530
Normal window size hints:
Program supplied location: 0, 0
Program supplied minimum size: 604 by 594
Program supplied maximum size: 32767 by 32767
Program supplied window gravity: NorthWestGravity
No zoom window size hints defined
No window shape defined
No border shape defined
xprop (browser):
_DESKTOP(CARDINAL) = 0
WM_STATE(WM_STATE):
window state: Normal
icon window: 0x0
WM_HINTS(WM_HINTS):
Client accepts input or input focus: True
Initial state is Normal State.
bitmap id # to use for icon: 0x1c00082
bitmap id # of mask for icon: 0x1c00083
window id # of group leader: 0x1c00001
_NET_STARTUP_ID(UTF8_STRING) = "xfce4-appfinder/|usr|lib|firefox|firefox/756-0-T530_TIME21351"
WM_WINDOW_ROLE(STRING) = "browser"
XdndAware(ATOM) = BITMAP
_MOTIF_DRAG_RECEIVER_INFO(_MOTIF_DRAG_RECEIVER_INFO) = 0x6c, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0
_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 29360257
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL
_NET_WM_USER_TIME(CARDINAL) = 1758669
_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x1c00080
WM_CLIENT_LEADER(WINDOW): window id # 0x1c00001
_NET_WM_PID(CARDINAL) = 792
WM_LOCALE_NAME(STRING) = "en_US.UTF-8"
WM_CLIENT_MACHINE(STRING) = "T530"
WM_NORMAL_HINTS(WM_SIZE_HINTS):
program specified minimum size: 300 by 71
program specified maximum size: 32767 by 32767
window gravity: NorthWest
WM_PROTOCOLS(ATOM): protocols WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST
WM_CLASS(STRING) = "Navigator", "Firefox"
WM_ICON_NAME(STRING) = "bash - Get number of opened application windows in linux - Stack Overflow - Mozilla Firefox"
_NET_WM_ICON_NAME(UTF8_STRING) = "bash - Get number of opened application windows in linux - Stack Overflow - Mozilla Firefox"
WM_NAME(STRING) = "bash - Get number of opened application windows in linux - Stack Overflow - Mozilla Firefox"
_NET_WM_NAME(UTF8_STRING) = "bash - Get number of opened application windows in linux - Stack Overflow - Mozilla Firefox"
xprop (preferences)
_NET_WM_DESKTOP(CARDINAL) = 0
WM_STATE(WM_STATE):
window state: Normal
icon window: 0x0
WM_HINTS(WM_HINTS):
Client accepts input or input focus: True
Initial state is Normal State.
bitmap id # to use for icon: 0x1c046f2
bitmap id # of mask for icon: 0x1c046f3
window id # of group leader: 0x1c00001
WM_WINDOW_ROLE(STRING) = "Preferences"
XdndAware(ATOM) = BITMAP
_MOTIF_DRAG_RECEIVER_INFO(_MOTIF_DRAG_RECEIVER_INFO) = 0x6c, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0
_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 29378289
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL
_NET_WM_USER_TIME(CARDINAL) = 1456410
_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x1c046f0
WM_CLIENT_LEADER(WINDOW): window id # 0x1c00001
_NET_WM_PID(CARDINAL) = 792
WM_LOCALE_NAME(STRING) = "en_US.UTF-8"
WM_CLIENT_MACHINE(STRING) = "T530"
WM_NORMAL_HINTS(WM_SIZE_HINTS):
program specified location: 0, 0
program specified minimum size: 604 by 594
program specified maximum size: 32767 by 32767
window gravity: NorthWest
WM_PROTOCOLS(ATOM): protocols WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST
WM_CLASS(STRING) = "Browser", "Firefox"
WM_ICON_NAME(STRING) = "Firefox Preferences"
_NET_WM_ICON_NAME(UTF8_STRING) = "Firefox Preferences"
WM_NAME(STRING) = "Firefox Preferences"
_NET_WM_NAME(UTF8_STRING) = "Firefox Preferences"
I don't know that there's a simple answer to this. You are probably going to need to inspect the windows more closely and weed-out any that aren't what you want.
The group leader property on a window might be useful. (Some sub-windows should have this and main windows may not).
You can also look at the full WM_CLASS and WM_WINDOW_ROLE values which might help you distinguish between window types.
The _NET_WM_WINDOW_TYPE, etc. properties are also likely to be helpful in figuring out what "kind" of window you are looking at.
Play around with xwininfo and xprop on the various windows on your display and you'll see what you can find.
The follow give you a list of running application which have a windows:
(Tested on Debian 10)
# copy to terminal and press enter, for getting list of all programs with window
wmctrl -l
# Or grep if you look only for count of only one application
wmctrl -l -p | grep name_of_application
For getting the count of running programms, count the lines or the programm IDs of the output.

Resources