Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
creating empty transparent window to hook up to
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
etnull
Apprentice
Apprentice


Joined: 26 Mar 2019
Posts: 289

PostPosted: Fri Jan 03, 2020 6:36 pm    Post subject: creating empty transparent window to hook up to Reply with quote

I use bspwm with urxvt. I have two scripts, one is a python script which tracks the active processes usage, and logs it into a file, something like this):
Code:
urxvtd
3:35:05 (34%)

mpv
3:14:35 (31%)

firefox
3:07:15 (30%)

emacs
0:16:25 (3%)

unknown
0:10:20 (2%)

urxvt
0:04:35 (1%)

colorcode
0:02:15 (0%)

Another bash script tracks if the system was idle or not each 15 minutes, and if it was, it executes the command.
Ideally the command should be to select some window which I can easily track in the first script and make it the 'idle' system state. I hope you get what I mean? Unfortunately it seems no mater what I tried to 'hook up' to in bspwm I can only select running non system applications like urxvt or something else, which is no use to me since I would not be able to distinguish them from real idle, the 'unknown' in the list above is some weird thing, I don't know what it is, maybe it happens when nothing is selected or in popups (the python script wasn't written by me). Any ideas how to achieve what I want? Here is the idle check script (as of now it just clicks the second screen, which works, but it's not optimal because the second monitor can have some windows on it):
Code:
#!/bin/bash

timeout=900000
# move to second screen and click to deselect urxvt
cmd="xdotool mousemove 2560 0 mousedown 1"
triggered=false

while true
do
    tosleep=$(((timeout - $(xssstate -i)) / 1000))
    if [ $tosleep -le 0 ];
    then
        $triggered || $cmd
        triggered=true
    else
        triggered=false
        sleep $tosleep
    fi
done

And here is random session with window ids and my comments
Code:
xwininfo -tree -root

xwininfo: Window id: 0x2a4 (the root window) (has no name) < couldn't select

  Root window id: 0x2a4 (the root window) (has no name) < couldn't select
  Parent window id: 0x0 (none)
     ~Random user apps~
     0xc00001 (has no name): ("motion_recorder" "Bspwm")  1x1+0+0  +0+0 < couldn't select
     0xc00000 "bspwm": ("wm" "Bspwm")  1x1+-1+-1  +-1+-1 < couldn't select
     0xc00003 "DVI-I-1": ("root" "Bspwm")  2560x1440+0+0  +0+0 < couldn't select
     0xc00005 "HDMI-0": ("root" "Bspwm")  1920x1200+2560+0  +2560+0 < couldn't select

I also tried to create a urxvt window with distinct name, and although it is possible, I can't make it transparent or of a 0 size, I don't use a compositor.
Back to top
View user's profile Send private message
geki
Advocate
Advocate


Joined: 13 May 2004
Posts: 2329
Location: Germania

PostPosted: Sat Jan 04, 2020 12:50 pm    Post subject: Reply with quote

I guess no one really understands, what you want to achieve. Most I could guess is that you want to track some(or all) window states?! You better not use a hidden window. That's bad practice.

If you use X11, I can point you to a little program I wrote to track all window focus states and set the window's transparency. It uses libxcb. You could adjust that to your liking:
https://github.com/geki-yaba/gekis-playground/blob/master/scripts/trans_follow_xcb.c
_________________
boost|select libs to build|slotable|python-buildid

hear hear


Last edited by geki on Sat Jan 04, 2020 1:14 pm; edited 1 time in total
Back to top
View user's profile Send private message
Ionen
Guru
Guru


Joined: 06 Dec 2018
Posts: 542

PostPosted: Sat Jan 04, 2020 1:13 pm    Post subject: Reply with quote

Not sure what you want to do either, but x11-misc/devilspie2 is often useful to track windows and set things as needed (it can also run external tools per-window if some things aren't supported internally). Works regardless of desktop environment which often have their own system (especially suitable if you don't use a DE).

Edit: nevermind the rest of the post, I just noticed you said you have no compositor

Also, if want to change/see transparency for X11 windows using only bash and common tools, you can try basic x11-apps/xprop too, like (rough example to set it):
Code:
opacity=70 # percent%
win=`xdotool getactivewindow`
xprop -id "$win" -f _NET_WM_WINDOW_OPACITY 32c -set _NET_WM_WINDOW_OPACITY $((opacity*0xffffffff/100))
Can also use
Code:
xprop -id "$win" -f _NET_WM_WINDOW_OPACITY_LOCKED 32c -set _NET_WM_WINDOW_OPACITY_LOCKED 1
To prevent the window manager or whatever other tools from changing it again (like when adjusting based on focus), assuming they respect standards anyway (any settings may end up ignored and/or need a different solution depending on window manager / compositor).

Last edited by Ionen on Sat Jan 04, 2020 5:02 pm; edited 1 time in total
Back to top
View user's profile Send private message
etnull
Apprentice
Apprentice


Joined: 26 Mar 2019
Posts: 289

PostPosted: Sat Jan 04, 2020 1:48 pm    Post subject: Reply with quote

I track my whole system idle state using xssstate -i, if it was idle for 15 minutes, I need to select something using xdotool selectwindow, which would then be tracked in my selected windows log as something, I can rename it to idle in the python script later, that something should be distinguishable from a regular user program, a root X window will do since you don't casually selecting it and staying there for long, but I can't select it in bspwm.
xprop command didn't work for some reason
Back to top
View user's profile Send private message
Ionen
Guru
Guru


Joined: 06 Dec 2018
Posts: 542

PostPosted: Sat Jan 04, 2020 2:00 pm    Post subject: Reply with quote

etnull wrote:
xprop command didn't work for some reason
Yeah, it's the normal way to set this but the WM/compositor does need support for it, so it's not surprising if doesn't always work. If not using a compositor, pretty sure it'll do nothing either way.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 14972

PostPosted: Sat Jan 04, 2020 4:53 pm    Post subject: Reply with quote

Why do you need to select something if the system is idle? What is wrong with doing nothing when the system is idle?
Back to top
View user's profile Send private message
Ionen
Guru
Guru


Joined: 06 Dec 2018
Posts: 542

PostPosted: Sat Jan 04, 2020 5:10 pm    Post subject: Reply with quote

Hu wrote:
Why do you need to select something if the system is idle? What is wrong with doing nothing when the system is idle?
I think "idle" here is in the sense of no user activity (didn't know of this tool but sounds like xssstate checks for input idle time, the type used to activate the screensaver), sounds like the plan is to activate a logging mechanism? after a period.
Edit: but while I can think of reasons to need to do something during that state, not sure what's the end goal here
Back to top
View user's profile Send private message
etnull
Apprentice
Apprentice


Joined: 26 Mar 2019
Posts: 289

PostPosted: Sat Jan 04, 2020 6:46 pm    Post subject: Reply with quote

Hu wrote:
Why do you need to select something if the system is idle? What is wrong with doing nothing when the system is idle?

Because when the system is idle it still stays selected on some window, urxvt for example, and then I have urxvt for 12 hours in my log, while I didn't use it for 12 hours it just my sleep time + other afk times.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 14972

PostPosted: Sat Jan 04, 2020 9:39 pm    Post subject: Reply with quote

Wouldn't sleep time go unlogged anyway, since the system is sleeping, not running? I think I understand your goal, but since you still haven't explained it, I will recap:
  • For reasons unknown, you are trying to record at a coarse granularity which windows you spend time using.
  • When you are not using the system, you leave it powered up and recording anyway, but would like not to count any window as in-use since you are not present.
  • You are trying to use the X Screen Saver idle time mechanism to detect whether the user is present. When the user is not present, you want to unfocus the window so as to trick the logging script into not crediting usage to whichever window the user last used.
  • You want not to take the more direct approach of recording that the user has become/ended idle, and therefore logs from the start to the end time should be ignored.
Is that correct? Why are you trying to track window usage like this? What do you hope to achieve if this works?
Back to top
View user's profile Send private message
etnull
Apprentice
Apprentice


Joined: 26 Mar 2019
Posts: 289

PostPosted: Sat Jan 04, 2020 11:03 pm    Post subject: Reply with quote

I didn't understand what you mean with your 4th point, but yes, everything is correct. What I want to achieve? Well I want to have logs of usage for maybe future analysis or just for reference, I already had moments when I couldn't remember how that one app was called which I was using years ago. It's like the 'Quantified Self' movement thing, data has value, or will have value, no matter what data it is, and since big corporations frantically collect data about me, why I can't/shouldn't do the same? About the X screensaver, I thought about hooking to that (it's the processes anyway right?), but, I usually like to have my screen ON for at least of 30min after I already went away, but that would be too long for the tracker accuracy.
---
I can spawn urxvt window with given name, but the script tracks binary names not window names, I also read about bspc (command util for bspwm), but it doesn't have anything regarding unfocus.
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1850

PostPosted: Sun Jan 05, 2020 1:32 pm    Post subject: Reply with quote

Quote:
, I usually like to have my screen ON for at least of 30min after I already went away, but that would be too long for the tracker accuracy.
Well... If you know that your screensaver kicks in after half an hour, you can subtract half an hour from the end of the last activity to refine your data while it's still hot.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum