1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134 | #!/usr/bin/python
import gobject
import os
import datetime
import time
import threading
import time
import sched
import glob
import pygtk, gtk, gobject
import sys
import difflib
# This is a 'Tooltip' Launcher taskbar ; the tt takes 2 or 3 sec to show up
# You must save and run this file as ' 2dinamic.py '
# You need python-gtk2, python-gtk2-dev , imagemagick, xdotool and wmctrl installed
# Press 'Start' or open a new window
# Type something in the Entry box to make it go away or to launch a new app (press 'Enter' then, not 'Start')
# After closing the window, press its name to remove the button from the taskbar
# Better to start it from a .desktop file (files will be created in your home)
class Dynamic:
var = []
os.system("rm -f 0x*")
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_keep_above(True)
self.window.set_opacity(0.7) # make it trasnparent as you wish
self.window.move(550, 790)
self.window.connect("destroy", self.close_application)
self.window.set_default_size(310, 60)
self.window.set_border_width(5)
hBox = gtk.HBox(False, 0)
addButton = gtk.Button("Start")
addButton.connect("clicked", self.AddCheckButton)
self.vBox = gtk.HBox(False, 0)
hBox.pack_start(self.vBox, True, True, 1)
hBox.pack_end(addButton)
# self.seconda(self) uncomment this, if you want a previous open windows scanning
self.window.add(hBox)
#self.window.set_decorated(False) # uncomment it, if you don't want the window controls
self.window.show_all()
gtk.main()
thread = threading.Thread(self.seconda(self))
thread.start()
def on_query_tooltip(self, b, x, y, keyboard_tip, tooltip):
os.system("import -window %s image.png" % b._value )
os.system("convert image.png -resize 50% -set filename:base \"%[base]\" \"%[filename:base].png\" ")
os.system("mv image.png %s" % b._value)
mio = self.name
hbox = gtk.HBox()
label = gtk.Label(' ')
image = gtk.Image()
image.set_from_file(b._value)
hbox.pack_start(image, False, False, 0)
hbox.pack_start(label, False, False, 0)
hbox.show_all()
tooltip.set_custom(hbox)
return True
def click(self,b,i):
x = os.system ("xdotool windowactivate %s" % (b._value) )
if x != 0:
b.set_visible(False)
self.var.remove(i)
def seconda(self,widget):
w=threading.Timer(03, self.seconda,[widget])
w.start()
os.system("for i in $(wmctrl -l | tail -n+7 | awk '{print $1}'); do echo $i; done > giulia3")
with open("giulia3") as z:
conten = z.readlines()
conten = [x.strip() for x in conten]
os.system("rm -f giulia4 ")
for q in conten :
os.system("for x in %s; do xprop -id $x |grep WM_CLASS |awk '{print $4}'| sed 's/.$//' | sed 's/^.//' ; done >> giulia4" % (q))
with open("giulia4") as d:
conte = d.readlines()
conte = [x.strip() for x in conte]
for i,t in zip(conte,conten):
if i != "2dinamic.py":
if not i in self.var :
self.var.append(i)
b = gtk.Button(i)
b._value = (t)
self.name = b._value
self.updatetool(self,b)
b.connect("clicked", self.click, i)
b.props.has_tooltip = True
b.connect("query-tooltip", self.on_query_tooltip)
self.vBox.pack_start(b, True, True, 1)
b.show()
def updatetool (self, widget, b):
os.system("import -window %s image.png" % b._value )
os.system("convert image.png -resize 50% -set filename:base \"%[base]\" \"%[filename:base].png\" ")
os.system("mv image.png %s" % b._value)
def AddCheckButton(self, button):
self.seconda(self)
text = gtk.Entry()
text.connect("activate", self.cb_activate)
self.vBox.pack_start(text, True, True, 1)
text.show()
def cb_activate (self, text):
port = text.get_text()
os.system("%s &" % port)
text.set_visible(False)
def close_application(self, widget):
gtk.main_quit()
os.system("pkill 2dinamic.py")
gobject.threads_init()
Dynamic()
gtk.main()
|