উবুন্টু 16.04।
লক্ষ্যটি অর্জনের জন্য একই সমস্যা ছিল এবং নিম্নলিখিতগুলি ব্যবহার করা হয়েছিল। অটোস্টার্ট এন্ট্রি এই স্ক্রিপ্টের মাধ্যমে চলমান থান্ডারবার্ড যুক্ত করেছে:
#!/usr/bin/env python3
import subprocess
import sys
import time
#
# Check out command
#
command = sys.argv[1]
#
# Run it as a subservice in own bash
#
subprocess.Popen(["/bin/bash", "-c", command])
#
# If a window name does not match command process name, add here.
# Check out by running :~$ wmctrl -lp
# Do not forget to enable the feature, seperate new by comma.
#
#windowProcessMatcher = {'CommandName':'WindowName'}
#if command in windowProcessMatcher:
# command = ''.join(windowProcessMatcher[command])
#print("Command after terminator" + command)
#
# Set some values. t is the iteration counter, maxIter guess what?, and a careCycle to check twice.
#
t = 1
maxIter=30
wellDone=False
careCycle=True
sleepValue=0.1
#
# MaxIter OR if the minimize job is done will stop the script.
#
while not wellDone:
# And iteration count still under limit. Count*Sleep, example: 60*0.2 = 6 seconds should be enough.
# When we found a program
if t >= maxIter:
break
# Try while it could fail.
try:
# Gives us a list with all entries
w_list = [output.split() for output in subprocess.check_output(["wmctrl", "-lp"]).decode("utf-8").splitlines()]
# Why not check the list?
for entry in w_list:
# Can we find our command string in one of the lines? Here is the tricky part:
# When starting for example terminator is shows yourname@yourmaschine ~.
# Maybee some matching is needed here for your purposes. Simply replace the command name
# But for our purposes it should work out.
#
# Go ahead if nothing found!
if command not in (''.join(entry)).lower():
continue
#######
print("mt### We got a match and minimize the window!!!")
# First entry is our window pid
match = entry[0]
# If something is wrong with the value...try another one :-)
subprocess.Popen(["xdotool", "windowminimize", match])
#
# Maybee there will be more than one window running with our command name.
# Check the list till the end. And go one more iteration!
if careCycle:
# Boolean gives us one more iteration.
careCycle=False
break
else:
wellDone=True
except (IndexError, subprocess.CalledProcessError):
pass
t += 1
time.sleep(sleepValue)
if wellDone:
print(" ")
print("mt### Well Done!")
print("mt### Window found and minimize command send.")
print("mt### ByBy")
else:
print(" ")
print("mt### Seems that the window while counter expired or your process command did not start well.")
print("mt### == Go ahead. What can you do/try out now? ")
এটি প্রতিটি অন্যান্য অ্যাপ্লিকেশনটির জন্যও কাজ করা উচিত।
ভাল কোডিং