/media/bill/SWAPPER/Qnial/code develop_test/windows- develop.txt www.BillHowell.ca 08May2019 initial ********** 20Jan2020 convert to wmctl where possible +-----+ #] winTitle_get_winID IS OP winTitle - returns a list of winIDs having the name requested # 06Oct2016 If pname_winID window is open, does this "freeze" winID_get? # -> no, it still freezes # so what causes this to freeze when winTitle isn't open or isn't recognized?!?!?!? # Ah Hah! it's the --sync, so if window open isn't successfull, # my "Orchestrator" hangs up # 23Oct2016 changed : winID := last strOld_sub_strNew_in_strFull ' ' '' (readfile fin) ; # to : winID := string readfile fin ; # 20Jan2020 converted to wmctrl, simple output of [winID text, error] winTitle_get_winID IS OP winTitle { LOCAL winID_results winID ; winID_results := host_result link 'wmctrl -l | grep "' winTitle '" ' ; IF (= null winID_results) THEN fault '?winTitle_get_winID no winIDs' ELSEIF (= 1 (gage shape winID_results)) THEN first winID_results ELSE fault '?winTitle_get_winID multiple winIDs' ENDIF } # old code pname_winID := sg_ "s_windowOps "pname_winID ; write link 'pname_winID= ' pname_winID ; %host link 'xdotool >"' '" search --sync --name "' winTitle '"' ; write link 'pname_winID= ' pname_winID ; flag_undone := l ; n := 0 ; WHILE (AND (< n 10) flag_undone) DO fin := open pname_winID "r ; winID := readfile fin ; close fin ; IF isfault winID THEN host 'sleep 0.4s' ; ELSE flag_undone := o ; ENDIF ; n := n + 1 ; ENDWHILE ; write_debug link 'winID_get : ' 'winTitle= "' winTitle '", winID= "' winID '" winCycles= ' (string n) ; %EACH winID_write cart (solitary winTitle) winID ; string winID # with wmctrl host_result link 'wmctrl -l | grep "' winTitle '" | tail -1 | cut -f1 -d " " ' #] win_id_from_name IS - # from "$d_bin""starter/start_app.sh" ; 08Jan2017 initial from RaspPi # tail - output the last part of files (-n --lines=K) # cut - remove sections from each line of files -d, --delimiter=DELIM, use DELIM instead of TAB for field delimiter win_id_from_name IS { wmctrl -l | grep "$1" | tail -1 | cut -f1 -d" " } #] winTitle_isUnique IS OP winTitle - (winTitle_get_winID provides this!?) winTitle_isUnique IS OP winTitle { LOCAL winID_results winID ; winID_results := host_result link 'wmctrl -l | grep "' winTitle '" ' ; IF (= 1 (gage shape winID_results)) THEN first winID_results ELSE fault '?winTitle_get_winID [no, multiple] winIDs' ENDIF } #] winID_isDead IS OP winID - (winTitle_get_winID provides this!?) winID_isDead IS OP winID { LOCAL winID_results winID ; winID_results := host_result link 'wmctrl -l | grep "' winID '" ' ; IF (= 1 (gage shape winID_results)) THEN first winID_results ELSE fault '?winTitle_get_winID [no, multiple] winIDs' ENDIF } # old code { LOCAL fin pname_winID winID ; pname_winID := sg_ "s_windowOps "pname_winID ; result := fault '?winID_isDead - winID not valid' ; IF (AND (NOT isfault winID) (~= null winID)) THEN host link 'xdotool >"' pname_winID '" getwindowname "' (string winID) '"' ; fin := open pname_winID "r ; result := last strOld_sub_strNew_in_strFull ' ' '' (readfile fin) ; close fin ; write_debug link 'winID_isDead : winID= ' (string winID) '; result= ' result ; ENDIF ; IF isfault result THEN l ELSE o ENDIF } #] winID_Title_purpose_write IS OP winTitle winID purpose - winID_write IS OP winTitle winID purpose { write (link 'winID: ' winID ' for "' winTitle '", for the purpose of "' purpose '"."') ; } #] wigmt IS - # d_QNial_mine 'video production/0_vidProdn - common data, operators.ndf' wigmt IS { winTitler := 'KWrite' ; winID_test := winID_getMany winTitler ; link (solitary link 'winID_get for "' winTitler '" = ') winID_test } #] wigmt2 IS - # d_QNial_mine 'video production/0_vidProdn - common data, operators.ndf' wigmt2 IS OP winTitler { winID_test := winID_getMany winTitler ; link (solitary link 'winID_get for "' winTitler '" = ') winID_test } #] winID_get_winTitle IS OP winID - # cannot have multiple windows with a given winID!! winID_get_winTitle IS OP winID { LOCAL winID_results winID ; winTitle_results := host_result link 'wmctrl -l | grep "' winID '" ' ; IF (= null winTitle_results) THEN fault '?winID_get_winTitle no winTitles' ELSE first winTitle_results ENDIF } # winID_get_winTitle '0x07e000a7' # old code { LOCAL fin flag_undone n pname_winID winTitle ; pname_winID := sg_ "s_windowOps "pname_winID ; host link 'xdotool >"' pname_winID '" getwindowname "' winID '"' ; flag_undone := l ; n := 0 ; WHILE (AND (< n 10) flag_undone) DO fin := open pname_winID "r ; winTitle := last strOld_sub_strNew_in_strFull ' ' '' (readfile fin) ; close fin ; IF isfault winTitle THEN host 'sleep 0.4s' ; ELSE flag_undone := o ; ENDIF ; n := n + 1 ; ENDWHILE ; write_debug link 'winTitle_get : ' 'winID= ' winID ', title= ' winTitle ', cycles= ' (string n) ; string winTitle } #] winID_lastAdded IS - %wait a bit to allow update of wmctrl listing internally ; fname_winList := link d_QNial_temp 'USB workspace loads - winList.txt' ; %14Oct2017 reduced time for video productions, see how it works, especially after apps_init_open to initialize apps ; %host (link 'sleep 3s') -> from a year ago or maybe DesktopSetup mods >6 months ago ; %host (link 'sleep 1s') -> maybe too fast? seem to be getting erroneous window closures etc ; host (link 'sleep 2s') ; % 14Oct2017 - this resolved the freezes and incorrect win)IDs, but slows it down ; # 14Oct2017 check if cvlc window is named? $ cvlc "/media/bill/SWAPPER/Video production/170930 DrumLibrary - kids science/video production/app_inits/vlc init 110213 A_Walk_On_The_Wild_Side 4m11s.flv" & $ wmctrl -l >> set the window title below of "VLC media player", using winID from output $ wmctrl -ir 0x04c00000 -T "cvlc walk on the wide side" #] win_move_last IS - (wmctrl, not ready yet) win_move_last { # echo "X = $1" # echo "Y = $2" # echo "width = $3" # echo "height= $4" win_id=$(win_id_last) # echo "mvlast win_id= $win_id" sleep 1s win_PosnSize="0,$1,$2,$3,$4" # echo "'$win_PosnSize'" wmctrl -i -r "$win_id" -e "$win_PosnSize" sleep 1s } # alternate detailed way : # echo "winLOleft- $left,$top,$width,$height" # win_id=$(win_id_last) # wmctrl -i -r "$win_id" -e '0,0,68,905,910' #] winTitle_get_winPosnSize IS OP winTitle - # 17Aug2017 - adjustPosnSize is currently unused # specify -1 (minus one) for any dimension that should not change winTitle_get_winPosnSize IS OP winTitle { host_result link 'wmctrl -Gl | grep "' winTitle '" ' } # $ wmctrl -Gl | grep "windows and signals.ndf" # old code { LOCAL fin pname_win_PosnSize winID winPosn winSize ; pname_win_PosnSize := sg_ "s_windowOps "pname_win_PosnSize ; winID := winTitle_get_winID Titler ; host link 'xdotool >"' pname_win_PosnSize '" getwindowgeometry ' winID ; fin := open pname_win_PosnSize "r ; % ; winID := 1 pick strOld_sub_strNew_in_strFull ' ' '' (readfile fin) ; % ; winPosn := 3 pick strOld_sub_strNew_in_strFull ' ' '' (readfile fin) ; winPosn := EACH tonumber strOld_sub_strNew_in_strFull ',' '' winPosn ; % ; winSize := 3 pick strOld_sub_strNew_in_strFull ' ' '' (readfile fin) ; winSize := EACH tonumber strOld_sub_strNew_in_strFull 'x' '' winSize ; % ; close fin ; winID winPosn winSize } #] winID_get_winPosnSize IS OP winID - winID_get_winPosnSize IS OP winID { host_result link 'wmctrl -Gl | grep "' winID '" ' } { LOCAL fin pname_win_PosnSize ; pname_win_PosnSize := sg_ "s_windowOps "pname_win_PosnSize ; host link 'xdotool >"' pname_win_PosnSize '" getwindowgeometry ' winID ; fin := open pname_win_PosnSize "r ; % ; winID2 := 1 pick strOld_sub_strNew_in_strFull ' ' '' (readfile fin) ; % ; winPosn := 3 pick strOld_sub_strNew_in_strFull ' ' '' (readfile fin) ; winPosn := EACH tonumber strOld_sub_strNew_in_strFull ',' '' winPosn ; % ; winSize := 3 pick strOld_sub_strNew_in_strFull ' ' '' (readfile fin) ; winSize := EACH tonumber strOld_sub_strNew_in_strFull 'x' '' winSize ; % ; close fin ; winID2 winPosn winSize } #] winID_activate IS OP winID - check window activation from Qnial # 02Jul2014 initial # check window activation from Qnial : # z_vidProdn_winID_script.txt commands are one letter per line? # This is because I am missing 'solitary' ... winTest := winID_get 'KDE mixer' ; shellApp_cmds (link char_char 'xdotool windowactivate --sync ' winTest char_char) # Put 'solitary' in : Now it works winID_activate IS OP winID { host link 'wmctrl -a "' winID '" ' ; } # old code { LOCAL winTest ; winTest := winID_get 'KDE mixer' ; host link 'xdotool windowactivate --sync ' winTest ; } #] winTitle_get_winID IS OP winTitle - returns a list of winIDs having the name requested winTitle_get_winID IS OP winTitle { LOCAL winSpecsOne winID ; winSpecsOne := host_result link 'wmctrl -l | grep "' winTitle '" ' ; IF (isfault winSpecsOne) THEN fault '?winID_get_winTitle no winTitles' ELSEIF (= 1 (gage shape winSpecsOne)) THEN 10 take first winSpecsOne ELSE fault '?winTitle_get_winID multiple winIDs' ENDIF } # find_string 'dell64' '0x064000a7 2 dell64 windows and signals.ndf' >> 14, OK # host_result link 'wmctrl -l | grep "windows and signals.ndf" ' # find_string 'dell64' (host_result link 'wmctrl -l | grep "windows and signals.ndf" ') # winTitle_get_winID 'windows and signals.ndf' # | tail -1 | cut -f1 -d" " # $ wmctrl -l | grep "windows - position, size, move, desktop opens.ndf" | tail -1 | cut -f1 -d " " # $ wmctrl -l | grep "windows - position, size, move, desktop opens.ndf" # $ wmctrl -l | grep "windows" # $ wmctrl -l | grep "nuckle-head" #] winIDorTitle_getAll_winIDs IS OP winIDorTitle - # 23Oct2016 winID_getMany : --sync taken out, but put back in # 29Oct2016 winID_get/winID_getMany -> Kwrite, gedit, clvc return application name, not window name!! winIDorTitle_get_all IS OP winIDorTitle { LOCAL winSpecsOne ; host_result link 'wmctrl -l | grep "' winIDorTitle '" ' IF (= null winSpecsOne) THEN fault '?winIDorTitle_get_winID no windows' ELSEIF (= 1 (gage shape winSpecsOne)) THEN host_result link 'wmctrl -c "' winIDorTitle '" ' ELSE fault '?winIDorTitle_get_winID multiple winIDs or fault' ENDIF { LOCAL fin flag_undone n pname_winID winID winID_list ; pname_winID := sg_ "s_windowOps "pname_winID ; host link 'xdotool >"' pname_winID '" search --sync --name "' winTitle '"' ; flag_undone := l ; n := 0 ; winID_list := '' ; WHILE (AND (< n 10) flag_undone) DO fin := open pname_winID "r ; WHILE (~= '?eof' (winID := string readfile fin)) DO winID_list := winID_list append winID ; ENDWHILE ; close fin ; IF = NULL winID_list THEN host 'sleep 0.8s' ; ELSE flag_undone := o ; ENDIF ; n := n + 1 ; ENDWHILE ; %write_debug link 'winID_getMany : ' 'winTitle= ' winTitle ', winID= ' winID ' winCycles= ' (string n) ; %EACH winID_write cart (solitary winTitle) winID ; winID_list } #] winIDorTitle_siz_mov IS OP winIDorTitle winPosn winSize - # gravity := string 0 : I don't know what 'gravity' does! - not described by "man wmctrl" ; # 17Aug2017 - adjustPosnSize is currently unused # specify -1 (minus one) for any dimension that should not change winIDorTitle_siz_mov IS OP winIDorTitle winPosn winSize { LOCAL winSpecsOne ; winSpecsOne := host_result link 'wmctrl -l | grep "' winIDorTitle '" ' ; IF (= null winSpecsOne) THEN fault '?winIDorTitle_get_winID no windows' ELSEIF (= 1 (gage shape winSpecsOne)) THEN host_result link 'wmctrl -c "' winIDorTitle '" ' ELSE fault '?winIDorTitle_get_winID multiple winIDs or fault' ENDIF { LOCAL gravity xPosn yPosn xSize ySize winID ; xPosn yPosn xSize ySize := link (EACH tostring winPosn) (EACH tostring winSize) ; winID := winIDorTitle_get_winID winIDorTitle ; IF (NOT isfault winID) THEN cmd := link 'wmctrl -i -r ' winID ' -e 0,' xPosn ',' yPosn ',' xSize ',' ySize ; write cmd ; host cmd ; ENDIF ; } # qnial> winID_siz_mov '0x064000a7' (0 0) (150 150) ************************ 08May2019 winTitle = 'Write: Some Subject' qnial> winID_get 'Write: Some Subject' ?arg must be file port >> hmm, this operator is SPECIFIC to my windowing system! qnial> sg_ "s_windowOps "pname_winID Error : sg_ IS OP s_structPhr s_Lab, s_Lab unknown >> I had left this file in a state of limbo after later changes can't find "s_windowOps" $ find "/media/bill/SWAPPER/Qnial/MY_NDFS/" -maxdepth 3 -name "*.ndf" | tr \\n \\0 | xargs -0 -IFILE grep --with-filename --line-number "s_windowOps" "FILE" /media/bill/SWAPPER/Qnial/MY_NDFS/z_Archive/Ops- window [size,placement,move, lists] 170817.ndf:106:s_windowOps := sd_ >> I copied structures to 'windows - header.ndf' qnial> winTitle_get_winID 'Write: Some Subject' ?arg must be file port $ xdotool >"/media/bill/ramdisk/z_winID.txt" search --sync --name "Write: Some Subject" The program 'xdotool' is currently not installed. To run 'xdotool' please ask your administrator to install the package 'xdotool' xdotool: command not found # enddoc