33
33
34
34
css .load_from_data (
35
35
"""
36
- progressbar text {
36
+ progressbar.overlay text {
37
37
color: yellow;
38
38
font-weight: bold;
39
39
}
40
- progressbar trough, progress {
40
+ progressbar.overlay trough, progress {
41
41
min-height: 100px;
42
42
}
43
- progressbar progress {
43
+ progressbar.pomodoro progress {
44
44
background-image: none;
45
- background-color: #f00 ;
45
+ background-color: #0f0 ;
46
46
}
47
- progressbar trough {
47
+ progressbar.pomodoro trough {
48
48
background-image: none;
49
- background-color: #0f0 ;
49
+ background-color: #00f ;
50
50
}
51
51
"""
52
52
)
57
57
from cairo import Region # type:ignore
58
58
59
59
60
- # When the application is launched…
61
- def on_activate (app : Gtk .Application ) -> None :
62
- # … create a new window…
60
+ def makeOneProgressBar (display : Gdk .Display , monitor : Gdk .Monitor , ewmh : EWMH ) -> None :
63
61
win = Gtk .ApplicationWindow (application = app , title = "Should Never Focus" )
64
62
win .set_opacity (0.25 )
65
63
win .set_decorated (False )
66
- win . set_default_size ( 2000 , 100 )
67
- # … with a button in it…
68
- # btn = Gtk.Button(label="Hello, World!")
64
+ monitor_geom = monitor . get_geometry ( )
65
+ win . set_default_size ( monitor_geom . width , 100 )
66
+
69
67
prog = Gtk .ProgressBar ()
68
+ prog .add_css_class ("pomodoro" )
69
+ prog .add_css_class ("overlay" )
70
70
frac = 0.7
71
71
72
72
def refraction () -> bool :
@@ -75,17 +75,9 @@ def refraction() -> bool:
75
75
frac %= 1.0
76
76
prog .set_fraction (frac )
77
77
return True
78
-
79
78
to = GLib .timeout_add ((1000 // 10 ), refraction )
80
-
81
79
prog .set_fraction (0.7 )
82
-
83
80
win .set_child (prog )
84
- gdisplay = prog .get_display ()
85
-
86
- Gtk .StyleContext .add_provider_for_display (
87
- gdisplay , css , Gtk .STYLE_PROVIDER_PRIORITY_USER
88
- )
89
81
90
82
# we can't actually avoid getting focus, but in case the compositors ever
91
83
# fix themselves, let's give it our best try
@@ -101,12 +93,11 @@ def refraction() -> bool:
101
93
win .get_surface ().set_input_region (Region ())
102
94
gdk_x11_win = win .get_native ().get_surface ()
103
95
xid = gdk_x11_win .get_xid ()
104
- display = XOpenDisplay ()
105
96
xlibwin = display .create_resource_object ("window" , xid )
106
- screen = display .screen ()
107
- ewmh = EWMH (display , screen .root )
97
+
108
98
# Always on top
109
- ewmh .setMoveResizeWindow (xlibwin , x = 300 , y = 800 , w = 2000 , h = 150 )
99
+ print (f'moving to { monitor_geom .x } { monitor_geom .y } { monitor_geom .width } ' )
100
+ ewmh .setMoveResizeWindow (xlibwin , x = monitor_geom .x , y = monitor_geom .y + (monitor_geom .height - 150 ), w = monitor_geom .width , h = 150 )
110
101
ewmh .setWmState (xlibwin , 1 , "_NET_WM_STATE_ABOVE" )
111
102
112
103
# Draw even over the task bar (this breaks stuff)
@@ -117,6 +108,20 @@ def refraction() -> bool:
117
108
ewmh .setWmState (xlibwin , 1 , "_NET_WM_STATE_SKIP_PAGER" )
118
109
display .flush ()
119
110
111
+ # When the application is launched…
112
+ def on_activate (app : Gtk .Application ) -> None :
113
+ # … create a new window…
114
+ gdisplay = Gdk .Display .get_default ()
115
+ Gtk .StyleContext .add_provider_for_display (
116
+ gdisplay , css , Gtk .STYLE_PROVIDER_PRIORITY_USER
117
+ )
118
+
119
+ display = XOpenDisplay ()
120
+ screen = display .screen ()
121
+ ewmh = EWMH (display , screen .root )
122
+ for monitor in gdisplay .get_monitors ():
123
+ makeOneProgressBar (display , monitor , ewmh )
124
+
120
125
121
126
if __name__ == "__main__" :
122
127
# Create a new application
0 commit comments