Sample Header Ad - 728x90

List open windows and save to file(wmctrl) for latter recall

1 vote
0 answers
162 views
I am trying to get the list off open windows and save them to a file. The problem I have is that 'String' and 'List' are not compatible. I have tried various methods of joining the information together but with limited success. The included code has been cobbled together from the internet.
=' '.join([str(item) for item in line1])
Is the item that compiles and runs, when my program runs but it produces a single file with '0' in it, It should be like this sample output,
-1 991    1920 0    1920 1080 Main Desktop — Plasma
0x01800011 -1 991    0    0    1920 1080 Main Desktop — Plasma
0x01800019 -1 991    1920 1056 1920 24   Main Plasma
0x00400003  0 1156   880  154  800  600  Main NordPass Password Manager
0x03c0002c  0 1432   2101 56   1529 731  Main List open windows and save to file(wmctrl) for latter recall - Unix & Linux Stack Exchange — Mozilla Firefox
0x03a00003  0 3449   1959 622  1609 724  Main mwin1 - Scripts - Visual Studio Code
0x04c00006  0 4757   1073 608  760  437  Main Scripts — Dolphin
0x03c000a1  0 1432   2115 177  1529 731  Main 1 hidden tab - Workona — Mozilla Firefox
0x04e00007  0 6441   962  55   916  453  Main ~
I wish to write to a file and later read that information back.
from asyncio import create_subprocess_shell
from distutils.file_util import write_file
from fileinput import FileInput
import os
from re import X
import subprocess

def getwin():
    line1=[os.system('wmctrl -p -G -l')]
    string1=' '.join([str(item) for item in line1])
    with open(r'winmove', 'w') as fp:
        for i in line1 :
            fp.write(string1) #line1
        fp.close

if __name__ == '__main__':

    getwin()
**I think the line "**
line1=[os.system('wmctrl -p -G -l')]
" **is not functioning right the items-/-are written to the console, however, if one adds lines to print the list to console** print line1 then the line in the cli is 0.
Asked by Data (11 rep)
Sep 24, 2022, 07:13 AM
Last activity: Sep 25, 2022, 12:26 PM