[Solved] Grab nemo-desktop window id using script

Please post suggestions for improvement of Cinnamon here
https://github.com/linuxmint/Cinnamon
Post Reply
flugalgourmet
Level 1
Level 1
Posts: 2
Joined: Tue Jun 18, 2019 5:15 pm

[Solved] Grab nemo-desktop window id using script

Post by flugalgourmet » Tue Jun 18, 2019 5:23 pm

Been using Cinnamon for about two weeks now after dumping KDE and loving it. Wrote a script to start and stop a video background that allows my conkys' to stay above the video. Every time I reboot however, I have to use xwininfo, click on the desktop, and alter the window id in my script. Is there a way to do this programatically in Bash? Note, I used $nemo-desktop but it is not an environment variable. Could an environment variable be created at login, like it is when xscreensaver is launched?
Thank you :)
Last edited by flugalgourmet on Sat Jun 22, 2019 12:20 am, edited 1 time in total.

User avatar
smurphos
Level 11
Level 11
Posts: 3708
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: Grab nemo-desktop window id using script

Post by smurphos » Thu Jun 20, 2019 1:13 am

You may need to install wmctrl - apt install wmctrl

Try wmctrl -l in a terminal first

If you have desktop icons enabled the Window ID for the Desktop can be derived in bash via the command.

wmctrl -l | awk "/-1/ && /Desktop/" | cut -c 1-11

If desktop icons are disabled it's

wmctrl -l | awk "/-1/ && /nemo-desktop/" | cut -c 1-11

Note that the format includes an extra 0 compared to the output of xwininfo so you might want to cut -c 1-2,4-11 depending on your use case.

E.g.

Code: Select all

xwininfo: Window id: 0x3a0002f "Desktop"
<snip>
steve@steve-HP-Pavilion-g6-Notebook-PC:~$ wmctrl -l | awk "/-1/ && /Desktop/" | cut -c 1-11
0x03a0002f
steve@steve-HP-Pavilion-g6-Notebook-PC:~$ wmctrl -l | awk "/-1/ && /Desktop/" | cut -c 1-2,4-11
0x3a0002f
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

flugalgourmet
Level 1
Level 1
Posts: 2
Joined: Tue Jun 18, 2019 5:15 pm

Re: Grab nemo-desktop window id using script

Post by flugalgourmet » Thu Jun 20, 2019 8:45 am

Thank you smurphos for that.
wmctrl -l | awk "/-1/ && /nemo-desktop/" | cut -c 1-11 seems to work well.

I came up with this on my own because xdotool was already installed.
xdotool search --onlyvisible --name nemo-desktop

It would seem that there are two window id's associated with the nemo-desktop. What I needed was the last of the them.

xwininfo -name "nemo-desktop" | grep "Window id:" | cut -d' ' -f4 only returns the first.

So this thread is definitely solved. :D
Thank you.

Post Reply

Return to “Cinnamon”