mrkramps
Anmeldungsdatum: 10. Oktober 2006
Beiträge: 5523
Wohnort: south central EL
|
Die aus Windows7 als Aero Snap bekannte Funktion um Fenster links und rechts gleichmäßig auf dem Bildschirm anzuordnen, sollte inzwischen recht bekannt sein. kwin4 (KDE) sollte sämtliche Bormittel mitbringen um diese Funktion selber anzubieten. Anderen Fenstermanager benötigen dafür noch einen Umweg über Befehlszeilenwerkzeuge. Der Grundstein für eine verlässliche Lösung wurde bereits Ende 2009 in diesem Thema auf UbuntuForums.org gelegt, und das Ergebnis zusammengefasst schließlich in verschiedenen Linux/Ubuntu Blogs veröffentlicht. Inzwischen sollte man in diesem Thema auch vollständige Script-Lösungen finden um die Anwendung komfortabel zu gestalten. Interessierte Anwender werde sicherlich auch irgendwann, irgendwo schon einmal über einen solchen Lösungsansatz gestolpert sein. Unabhängig von der Entwicklung auf UbuntuForums.org habe ich ausgehend von diesem Thema hier im Forum mein Script, welches ich für diesen Anwendungsfall damals geschrieben hatte, nochmal überarbeitet und um die gewünschten Funktionen aus eben diesem Thema erweitert. PhotonX schlug mir nach Veröffentlichung des Scriptes dort vor, ein eigenes Thema dafür im Projekte-Unterforum zu eröffnen, was ich hier mit tue. Das Script lässt sich effektiv über Tastenkürzel, Compiz Edge Bindings oder Brightside ansteuern. Im Gegensatz zu der ursprünglichen Lösung verzichte ich allerdings darauf die Bildschirmauflösung automatisch auslesen zu lassen, weil wmctrl als Basis für die Platzierung der Fenster lediglich die Größe des Fensterinhalts ohne Rücksicht auf Rahmen oder vorhandener Leisten verwendet, und somit einige Werte dafür schon individuell in das Script eingetragen werden müssen. Die Liste der EWMH/NetWM-kompatiblen Fensterverwaltungen, mit denen das Script laufen sollte, kann man der Projektseite von wmctrl entnehmen. Kompatiblität mit Compiz müsste gewährleistet sein, und kwin4 unterstützt die Funktionen - wie oben schon erwähnt - weitesgehend von Haus aus, ist aber trotzdem ebenfalls verhältnismäßig kompatibel. Ich selber verwende xfwm4 (Xfce4) für die Fensterverwaltung und konnte das Script bislang auch nur damit ausgiebig testen. Ferner ist das Script an einigen Stellen, insbesondere bei der Ermittlung des aktiven Desktops, noch etwas wackelig. Über ein paar Rückmeldungen und/oder Vorschläge für Verbesserungen/Erweiterungen würde ich mich freuen, weniger weil zu diesem Thema noch nicht genug an anderer Stelle gesagt wurde, sondern mehr weil das ganz eigennützig meinen Lernprozess im Bash Scripting unterstützt - und der ein oder andere von euch davon profitieren könnte. Danke. Benötigte Pakete:
Das Script:
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279 | #!/bin/bash
###############################INFORMATION######################################
# This script provides additional functionality for window placement with
# EWMH/NetWM compatible X Window Managers such as metacity, xfwm4, kwin, icewm,
# window maker or openbox. Possibly newer versions of those window managers
# might already support these features innately.
# The functions influences the active window only and it is recommended to use
# the script with "focus follows mouse" for best user experience.
#
# Although generally a command line utility with fully working switches this
# script is meant to be a backend wrapper to bind keyboard shortcuts to.
# Best working with a combination of mod keys and the numpad keys.
#
# Dependencies:
# wmctrl, xdotool, xwit, EWMH/NetWM compatible X Window Manager
#
###############################CONFIGURATION####################################
# You have to change the following values (unit: pixels) to ensure the script
# will work properly with your screen resolution and theme.
# Resolution, screen width (sw) and height (sh)
sw="1440"
sh="900"
# Top panel height
tp="0"
# Bottom panel height
bp="32"
# Left panel width
lp="0"
# Right panel width
rp="0"
# Titlebar height
tb="25"
# Left border width
lb="3"
# Right border width
rb="3"
# Bottom border width
bb="3"
# Additional window margins
wm="1"
################################################################################
# Define remaining variables
# Get window ID for all windows on current desktop
# Still kinda instable, FIX ME!
win_id_all=$(wmctrl -l | grep " $(xdotool get_desktop)" | cut -d " " -f1)
# Store in array for further processing
win_array=( $win_id_all )
# Get window ID of currently active window
win_active=$(xdotool getactivewindow)
# Display usage information
function usage () {
cat <<USAGE
window-fu - This script provides additional functionality for window placement
with EWMH/NetWM compatible X Window Managers accessible via keyboard shortcuts.
Please apply according shortcuts in your desktop environment manually to
window-fu and one(!) parameter.
To ensure the script is working properly edit the variables at the top of the
script file according to your screen and theme settings.
Dependencies:
wmctrl, xdotool, xwit
Usage:
window-fu [PARAMETER] (applied to keyboard shortcut)
Example:
window-fu -l (applied to SHIFT+ALT+KP_LEFT)
Parameters:
-h -? Display this usage information.
-l Dock window at left screen edge maximized vertically
-r Dock window at right screen edge maximized vertically
-t Dock window at top screen edge maximized horizontally
-b Dock window at bottom screen edge maximized horizontally
-pt Set window height to screen height half docked at top edge
-pb Set window height to screen height half docked at bottom edge
-tl Set window height to screen height half docked at top left corner
-bl Set window height to screen height half docked at bottom left corner
-tr Set window height to screen height half docked at top right corner
-br Set window height to screen height half docked at top left corner
-f Toggle window fullscreen (maximize window)
-m Minimize all windows except active one on current desktop
-u Unminimize all windows on current desktop
USAGE
}
# Functions
function snap_left ()
{
w=$(($sw/2 - $lb - $rb - $lp/2 - $rp/2 - $wm))
h=$(($sh - $tb - $bb - -$tp - $bp))
x=$((0 + $lp))
y=$((0 + $tp))
wmctrl -r :ACTIVE: -e 0,$x,$y,$w,$h
# Function win_maximize will overwrite the properties
# Use absolute values for placement and size instead
#wmctrl -r :ACTIVE: -b add,maximized_vert
}
function snap_right ()
{
w=$(($sw/2 - $lb - $rb - $lp/2 - $rp/2 - $wm))
h=$(($sh - $tb - $bb - -$tp - $bp))
x=$(($sw/2 - $rp/2 + $lp/2 + $wm))
y=$((0 + $tp))
wmctrl -r :ACTIVE: -e 0,$x,$y,$w,$h
# See comment in function snap_left
#wmctrl -r :ACTIVE: -b add,maximized_vert
}
function snap_top ()
{
w=$(($sw - $lb - $rb - $lp - $rp))
h=$(($sh/2 - $tb - $bb - $tp/2 - $bp/2 - $wm))
x=$((0 + $lp))
y=$((0 + $tp))
wmctrl -r :ACTIVE: -e 0,$x,$y,$w,$h
# See comment in function snap_left
#wmctrl -r :ACTIVE: -b add,maximized_horz
}
function snap_bottom ()
{
w=$(($sw - $lb - $rb - $lp - $rp))
h=$(($sh/2 - $tb - $bb - $tp/2 - $bp/2 - $wm))
x=$((0 + $lp))
y=$(($sh/2 - $bp/2 + $tp/2))
wmctrl -r :ACTIVE: -e 0,$x,$y,$w,$h
# See comment in function snap_left
#wmctrl -r :ACTIVE: -b add,maximized_horz
}
function pos_top ()
{
h=$(($sh/2 - $tb - $bb - $tp/2 - $bp/2 - $wm))
y=$((0 + $tp))
wmctrl -r :ACTIVE: -e 0,-1,$y,-1,$h
}
function pos_bottom ()
{
h=$(($sh/2 - $tb - $bb - $tp/2 - $bp/2 - $wm))
y=$(($sh/2 - $bp/2 + $tp/2))
wmctrl -r :ACTIVE: -e 0,-1,$y,-1,$h
}
function snap_top_left ()
{
w=$(($sw/2 - $lb - $rb - $lp/2 - $rp/2 - $wm))
h=$(($sh/2 - $tb - $bb - $tp/2 - $bp/2 - $wm))
x=$((0 + $lp))
y=$((0 + $tp))
wmctrl -r :ACTIVE: -e 0,$x,$y,$w,$h
}
function snap_bottom_left ()
{
w=$(($sw/2 - $lb - $rb - $lp/2 - $rp/2 - $wm))
h=$(($sh/2 - $tb - $bb - $tp/2 - $bp/2 - $wm))
x=$((0 + $lp/2 + $rp/2 + $wm))
y=$(($sh/2 - $bp/2 + $tp/2))
wmctrl -r :ACTIVE: -e 0,$x,$y,$w,$h
}
function snap_top_right ()
{
w=$(($sw/2 - $lb - $rb - $lp/2 - $rp/2 - $wm))
h=$(($sh/2 - $tb - $bb - $tp/2 - $bp/2 - $wm))
x=$(($sw/2 - $rp/2 + $lp/2 + $wm))
y=$((0 + $tp))
wmctrl -r :ACTIVE: -e 0,$x,$y,$w,$h
}
function snap_bottom_right ()
{
w=$(($sw/2 - $lb - $rb - $lp/2 - $rp/2 - $wm))
h=$(($sh/2 - $tb - $bb - $tp/2 - $bp/2 - $wm))
x=$(($sw/2 - $rp/2 + $lp/2 + $wm))
y=$(($sh/2 - $bp/2 + $tp/2))
wmctrl -r :ACTIVE: -e 0,$x,$y,$w,$h
}
function win_maximize ()
{
wmctrl -r :ACTIVE: -b toggle,maximized_vert,maximized_horz
}
function win_minimize ()
{
for i in ${win_array[@]}
do
# wmctrl outputs hex, xdotool and xwit use decimal values for window IDs
# let converts those hex to decimal values
let win_id=$i
if [ "$win_active" != "$win_id" ]
then
xwit -iconify -id $win_id
fi
done
}
function win_unminimize ()
{
for i in ${win_array[@]}
do
# See function win_minimize for explaination
let win_id=$i
if [ "$win_active" != "$win_id" ]
then
# Give focus to each unhidden window to avoid pager blinking
xwit -pop -focus -id $win_id
fi
done
# Give focus to formerly active window again
xwit -focus -id $win_active
}
# Bring together parameters and functions
function win_fu ()
{
case $1 in
-h)
usage
;;
-\?)
usage
;;
-l)
snap_left
;;
-r)
snap_right
;;
-t)
snap_top
;;
-b)
snap_bottom
;;
-pt)
pos_top
;;
-pb)
pos_bottom
;;
-tl)
snap_top_left
;;
-bl)
snap_bottom_left
;;
-tr)
snap_top_right
;;
-br)
snap_bottom_right
;;
-f)
win_maximize
;;
-m)
win_minimize
;;
-u)
win_unminimize
;;
*)
exit 1
;;
esac
}
# Let it happen
win_fu $1
Code
|
|
silberzwiebel
Anmeldungsdatum: 1. Februar 2010
Beiträge: 30
|
Hallo, ich möchte keineswegs Deine Mühe nicht wertschätzen, sondern einen Tipp geben für Leute, die Compiz nutzen: Mit dem Plugin Grid lässt sich diese Funktion auch wunderbar und ganz einfach nutzen.
Voreinstellung: Strg+Alt+Numpad, funktioniert super.
Ich glaube man muss das Paket compiz-fusion-plugins-extra installieren. Ich selber kann ohne dieses Plugin garnicht mehr leben 😉 Gruß,
silberzwiebel
|
Zombie_im_Bademantel
Anmeldungsdatum: 13. April 2005
Beiträge: 655
|
Allerdings kann Compiz grid ("Fensterpositionierung") nur das fokussierte Fenster verschieben, nicht zwei/alle geöffneten gleichmäßig anordnen (zB linke Hälfte Fenster eins, rechte Hälfte Fenster zwei). Wenn das doch geht, wäre ein Erkläfung nett, fänd das mit Bordmitteln schon gut ☺ Voreinstellung ist bei mir übrigens <super>+Numpad.
|
mrkramps
(Themenstarter)
Anmeldungsdatum: 10. Oktober 2006
Beiträge: 5523
Wohnort: south central EL
|
Zombie im Bademantel schrieb: Allerdings kann Compiz grid ("Fensterpositionierung") nur das fokussierte Fenster verschieben, nicht zwei/alle geöffneten gleichmäßig anordnen (zB linke Hälfte Fenster eins, rechte Hälfte Fenster zwei). Wenn das doch geht, wäre ein Erkläfung nett, fänd das mit Bordmitteln schon gut ☺ Voreinstellung ist bei mir übrigens <super>+Numpad.
Mit wmctrl geht das schonmal. Das folgende Script ordnet alle Fenster einer Arbeitsfläche zwar übereinander, aber abwechselnd links und rechts auf dem Bildschirm an. Eine Anordnung in andere Gitterstrukturen sollte auch gehen, aber mir ist gerade noch nicht so klar, wie ich die Platzierung in einem 4er-Gitter bei mehr als 4 Fenstern wiederholen kann. Wird sich finden lassen... In diesem Script habe ich im Gegensatz zum vorherigen die Abfrage nach der aktiven Arbeitsfläche mit wmctrl statt xdotool gemacht, damit nur noch ein externes Programm notwendig ist. Evtl. verschmelze ich beide Scripte später noch. Benötigte Pakete:
Das Script:
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 | #!/bin/bash
# Resolution, screen width (sw) and height (sh)
sw="1440"
sh="900"
# Top panel height
tp="0"
# Bottom panel height
bp="32"
# Left panel width
lp="0"
# Right panel width
rp="0"
# Titlebar height
tb="25"
# Left border width
lb="3"
# Right border width
rb="3"
# Bottom border width
bb="3"
# Additional window margins
wm="1"
# Get active desktop and window ids from this desktop
desk_active=$(wmctrl -d | grep "*" | cut -d " " -f1)
win_id_all=$(wmctrl -l | grep " $desk_active" | cut -d " " -f1)
win_array=( $win_id_all )
# For each serial number of each element of array do...
for n in $(seq 0 $((${#win_array[@]} - 1)) )
do
# For each win_id with serial number $n do...
for i in ${win_array[$n]}
do
# Check wether serial number $n is even (0) or odd (1)
if [ "$(( $n % 2 ))" -eq "0" ]
# If even snap window left
then
w=$(($sw/2 - $lb - $rb - $lp/2 - $rp/2 - $wm))
h=$(($sh - $tb - $bb -$tp - $bp))
x=$((0 + $lp))
y=$((0 + $tp))
wmctrl -i -r $i -e 0,$x,$y,$w,$h
# If odd snap window right
else
w=$(($sw/2 - $lb - $rb - $lp/2 - $rp/2 - $wm))
h=$(($sh - $tb - $bb - -$tp - $bp))
x=$(($sw/2 - $rp/2 + $lp/2 + $wm))
y=$((0 + $tp))
wmctrl -i -r $i -e 0,$x,$y,$w,$h
fi
done
done
|
|
mrkramps
(Themenstarter)
Anmeldungsdatum: 10. Oktober 2006
Beiträge: 5523
Wohnort: south central EL
|
Ich sag ja, wird sich finden lassen... Zwei oder weniger Fenster Anordnung links und rechts, drei Fenster Anordnung eins links und zwei rechts, vier oder mehr Fenster Anordnung zwei links und zwei rechts. Bei mehr als vier Fenstern wird ab dem fünften die Anordnung wiederholt und die Fenster werden übereinander gelegt. Optional könnte man das Script jetzt ähnlich wie das oben gestalten, so dass man verschiedene Aufteilungen bzw. Gitterformen für die Fenster über einzelne Tastenkürzel direkt aufrufen kann. Dazu später vielleicht mehr... Benötigte Pakete (immer noch):
Das Script:
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
135
136
137
138 | #!/bin/bash
# Resolution, screen width (sw) and height (sh)
sw="1440"
sh="900"
# Top panel height
tp="0"
# Bottom panel height
bp="32"
# Left panel width
lp="0"
# Right panel width
rp="0"
# Titlebar height
tb="25"
# Left border width
lb="3"
# Right border width
rb="3"
# Bottom border width
bb="3"
# Additional window margins
wm="1"
# Get active desktop and window ids from this desktop
desk_active=$(wmctrl -d | grep "*" | cut -d " " -f1)
win_id_all=$(wmctrl -l | grep " $desk_active" | cut -d " " -f1)
win_array=( $win_id_all )
win_count=${#win_array[@]}
function left ()
{
w=$(($sw/2 - $lb - $rb - $lp/2 - $rp/2 - $wm))
h=$(($sh - $tb - $bb -$tp - $bp))
x=$((0 + $lp))
y=$((0 + $tp))
}
function right ()
{
w=$(($sw/2 - $lb - $rb - $lp/2 - $rp/2 - $wm))
h=$(($sh - $tb - $bb - -$tp - $bp))
x=$(($sw/2 - $rp/2 + $lp/2 + $wm))
y=$((0 + $tp))
}
function top_left ()
{
w=$(($sw/2 - $lb - $rb - $lp/2 - $rp/2 - $wm))
h=$(($sh/2 - $tb - $bb - $tp/2 - $bp/2 - $wm))
x=$((0 + $lp))
y=$((0 + $tp))
}
function bottom_left ()
{
w=$(($sw/2 - $lb - $rb - $lp/2 - $rp/2 - $wm))
h=$(($sh/2 - $tb - $bb - $tp/2 - $bp/2 - $wm))
x=$((0 + $lp/2 + $rp/2 + $wm))
y=$(($sh/2 - $bp/2 + $tp/2))
}
function top_right ()
{
w=$(($sw/2 - $lb - $rb - $lp/2 - $rp/2 - $wm))
h=$(($sh/2 - $tb - $bb - $tp/2 - $bp/2 - $wm))
x=$(($sw/2 - $rp/2 + $lp/2 + $wm))
y=$((0 + $tp))
}
function bottom_right ()
{
w=$(($sw/2 - $lb - $rb - $lp/2 - $rp/2 - $wm))
h=$(($sh/2 - $tb - $bb - $tp/2 - $bp/2 - $wm))
x=$(($sw/2 - $rp/2 + $lp/2 + $wm))
y=$(($sh/2 - $bp/2 + $tp/2))
}
function place ()
{
wmctrl -i -r $i -e 0,$x,$y,$w,$h
}
# If 2 or less open windows 1 left and 1 right
if [ "$win_count" -le "2" ]
then
# For each serial number of each element of array do...
for (( n=0 ; n <= $((win_count - 1)) ; n++))
do
# For each win_id with serial number $n do...
for i in ${win_array[$n]}
do
# Check wether serial number $n is even (0) or odd (1)
if [ "$(( $n % 2 ))" -eq "0" ]
# If even snap window left
then
left && place
# If odd snap window right
else
right && place
fi
done
done
# If 3 open windows 1 left and 2 right
elif [ "$win_count" -eq "3" ]
then
for i in ${win_array[0]}
do
top_left && place
done
for i in ${win_array[1]}
do
bottom_left && place
done
for i in ${win_array[2]}
do
right && place
done
# If 4 or more open windows 2 left and 2 right
else
for ((n=0 ; n <= $(($win_count - 1)) ; n++))
do
# Set $i for function place ()
i=${win_array[$n]}
if [ "$(( $n % 4 ))" -eq "0" ]
then
top_left && place
elif [ "$(( $n % 4 ))" -eq "1" ]
then
bottom_left && place
elif [ "$(( $n % 4 ))" -eq "2" ]
then
top_right && place
elif [ "$(( $n % 4 ))" -eq "3" ]
then
bottom_right && place
fi
done
fi
|
|
mrkramps
(Themenstarter)
Anmeldungsdatum: 10. Oktober 2006
Beiträge: 5523
Wohnort: south central EL
|
Dazu jetzt mehr... Mit diesem Script stehen jetzt insgesamt 7 Varianten der Fensterplatzierung zur Auswahl, die über Parameter auf einzelne Tastenkürzel gelegt werden können. Was mich jetzt immer noch annervt ist die Ausgabe der ID des aktiven Fensters, insbesondere wenn man man diese ID für/von zwei Befehlszeilenwerkzeuge vergleichen möchte...
| wmctrl -l | grep " $(wmctrl -d | grep "*" | cut -d " " -f1)" | cut -d " " -f1
= 0x04400003
xdpyinfo | grep focus | grep -E -o 0x[0-9a-f]+
= 0x4400004
xdotool getactivewindow
= 71303171
|
Man bemerke, es sollte sich eigentlich in allen drei Fällen um das gleiche Fenster handeln. Für eine Kondition eignet sich im Moment nur die Umrechnung der hexadezimalen Ausgabe von wmctrl in die dezimale Ausgabe von xdotool...
| hex_id=0x04400003
let hex_id=$dec_id
echo $dec_id
= 71303171
|
Falls da jemand zufällig 'ne coolere Idee hat, ich wäre dankbar. Benötigte Pakete:
Das Script:
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326 | #!/bin/bash
# Dependencies:
# wmctrl, xdotool
# Resolution, screen width (sw) and height (sh)
sw="1440"
sh="900"
# Top panel height
tp="0"
# Bottom panel height
bp="32"
# Left panel width
lp="0"
# Right panel width
rp="0"
# Titlebar height
tb="25"
# Left border width
lb="3"
# Right border width
rb="3"
# Bottom border width
bb="3"
# Additional window margins
wm="1"
# Get active desktop and window ids from this desktop
desk_active=$(wmctrl -d | grep "*" | cut -d " " -f1)
win_id_all=$(wmctrl -l | grep " $desk_active" | cut -d " " -f1)
win_array=( $win_id_all )
win_count=${#win_array[@]}
# Functions to declare variables for window geometry
function left ()
{
w=$(($sw/2 - $lb - $rb - $lp/2 - $rp/2 - $wm))
h=$(($sh - $tb - $bb -$tp - $bp))
x=$((0 + $lp))
y=$((0 + $tp))
}
function right ()
{
w=$(($sw/2 - $lb - $rb - $lp/2 - $rp/2 - $wm))
h=$(($sh - $tb - $bb - -$tp - $bp))
x=$(($sw/2 - $rp/2 + $lp/2 + $wm))
y=$((0 + $tp))
}
function top ()
{
h=$(($sh/2 - $tb - $bb - $tp/2 - $bp/2 - $wm))
w=$(($sw - $lb - $rb - $lp - $rp))
x=$((0 + $lp))
y=$((0 + $tp))
}
function bottom ()
{
w=$(($sw - $lb - $rb - $lp - $rp))
h=$(($sh/2 - $tb - $bb - $tp/2 - $bp/2 - $wm))
x=$((0 + $lp))
y=$(($sh/2 - $bp/2 + $tp/2))
}
function top_left ()
{
w=$(($sw/2 - $lb - $rb - $lp/2 - $rp/2 - $wm))
h=$(($sh/2 - $tb - $bb - $tp/2 - $bp/2 - $wm))
x=$((0 + $lp))
y=$((0 + $tp))
}
function bottom_left ()
{
w=$(($sw/2 - $lb - $rb - $lp/2 - $rp/2 - $wm))
h=$(($sh/2 - $tb - $bb - $tp/2 - $bp/2 - $wm))
x=$((0 + $lp/2 + $rp/2 + $wm))
y=$(($sh/2 - $bp/2 + $tp/2))
}
function top_right ()
{
w=$(($sw/2 - $lb - $rb - $lp/2 - $rp/2 - $wm))
h=$(($sh/2 - $tb - $bb - $tp/2 - $bp/2 - $wm))
x=$(($sw/2 - $rp/2 + $lp/2 + $wm))
y=$((0 + $tp))
}
function bottom_right ()
{
w=$(($sw/2 - $lb - $rb - $lp/2 - $rp/2 - $wm))
h=$(($sh/2 - $tb - $bb - $tp/2 - $bp/2 - $wm))
x=$(($sw/2 - $rp/2 + $lp/2 + $wm))
y=$(($sh/2 - $bp/2 + $tp/2))
}
# wmctrl command for window placement
function place ()
{
wmctrl -i -r $win_id -e 0,$x,$y,$w,$h
}
# The functions for each type of placement grid
function left_right ()
{
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
if [ "$(( $n % 2 ))" -eq "0" ]
then
left && place
else
right && place
fi
done
}
function top_bottom ()
{
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
if [ "$(( $n % 2 ))" -eq "0" ]
then
top && place
else
bottom && place
fi
done
}
function left_right_right ()
{
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
win_active=$(xdotool getactivewindow)
let win_current=$win_id
if [ "$(( $n % 3 ))" -eq "0" ]
then
if [ $win_active = $win_current ]
then
left && place
else
top_right && place
fi
elif [ "$(( $n % 3 ))" -eq "1" ]
then
if [ $win_active = $win_current ]
then
left && place
else
bottom_right && place
fi
elif [ "$(( $n % 3 ))" -eq "2" ]
then
if [ $win_active = $win_current ]
then
left && place
else
top_right && place
fi
fi
done
}
function right_left_left ()
{
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
win_active=$(xdotool getactivewindow)
let win_current=$win_id
if [ "$(( $n % 3 ))" -eq "0" ]
then
if [ $win_active = $win_current ]
then
right && place
else
top_left && place
fi
elif [ "$(( $n % 3 ))" -eq "1" ]
then
if [ $win_active = $win_current ]
then
right && place
else
bottom_left && place
fi
elif [ "$(( $n % 3 ))" -eq "2" ]
then
if [ $win_active = $win_current ]
then
right && place
else
top_left && place
fi
fi
done
}
function top_bottom_bottom ()
{
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
win_active=$(xdotool getactivewindow)
let win_current=$win_id
if [ "$(( $n % 3 ))" -eq "0" ]
then
if [ $win_active = $win_current ]
then
top && place
else
bottom_left && place
fi
elif [ "$(( $n % 3 ))" -eq "1" ]
then
if [ $win_active = $win_current ]
then
top && place
else
bottom_right && place
fi
elif [ "$(( $n % 3 ))" -eq "2" ]
then
if [ $win_active = $win_current ]
then
top && place
else
bottom_left && place
fi
fi
done
}
function bottom_top_top ()
{
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
win_active=$(xdotool getactivewindow)
let win_current=$win_id
if [ "$(( $n % 3 ))" -eq "0" ]
then
if [ $win_active = $win_current ]
then
bottom && place
else
top_left && place
fi
elif [ "$(( $n % 3 ))" -eq "1" ]
then
if [ $win_active = $win_current ]
then
bottom && place
else
top_right && place
fi
elif [ "$(( $n % 3 ))" -eq "2" ]
then
if [ $win_active = $win_current ]
then
bottom && place
else
top_left && place
fi
fi
done
}
function top_bottom_left_right ()
{
for (( n=0 ; n <= $(($win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
if [ "$(( $n % 4 ))" -eq "0" ]
then
top_left && place
elif [ "$(( $n % 4 ))" -eq "1" ]
then
bottom_left && place
elif [ "$(( $n % 4 ))" -eq "2" ]
then
top_right && place
elif [ "$(( $n % 4 ))" -eq "3" ]
then
bottom_right && place
fi
done
}
# Bring together parameters and according functions
function win_place ()
{
case $1 in
-lr)
left_right
;;
-tb)
top_bottom
;;
-lrr)
left_right_right
;;
-rll)
right_left_left
;;
-tbb)
top_bottom_bottom
;;
-btt)
bottom_top_top
;;
-f)
top_bottom_left_right
;;
*)
exit 1
;;
esac
}
# Let it happen
win_place $1
|
|
silberzwiebel
Anmeldungsdatum: 1. Februar 2010
Beiträge: 30
|
Zombie im Bademantel schrieb: Allerdings kann Compiz grid ("Fensterpositionierung") nur das fokussierte Fenster verschieben, nicht zwei/alle geöffneten gleichmäßig anordnen (zB linke Hälfte Fenster eins, rechte Hälfte Fenster zwei). Wenn das doch geht, wäre ein Erkläfung nett, fänd das mit Bordmitteln schon gut ☺ Voreinstellung ist bei mir übrigens <super>+Numpad.
Ähm, ich verstehe den Unterschied nicht so ganz. Geht es um den etwas größeren Zeitaufwand jedes einzelne Fenster an die gewünschte Stelle verschieben zu lassen? Kann man dann doch mit Alt+Tab wechseln, wenn man eh grad mit der Tastatur Fensteraktionen macht, oder?
Hab grade mal probiert das mit dem "Gruppiere und Tabbe Fenster"-Plugin hinzukriegen, das klappt aber nicht...
|
mrkramps
(Themenstarter)
Anmeldungsdatum: 10. Oktober 2006
Beiträge: 5523
Wohnort: south central EL
|
So, alles zusammen in einem Script mit externe Konfigurationsdatei, verständlicher Gebrauchsanweisung und was sonst noch in so ein Script reingehören könnte. Insbesondere jetzt wäre ich sehr dankbar, wenn sich vielleicht der ein oder andere Zeit nehmen würde das Script zu testen, und vielleicht sogar noch ein wenig Feedback zur technischen Umsetzung im Script machen könnte. Danke. Benötigte Pakete:
Das Script:
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725 | #!/bin/bash
##WINDOW-FOO####################################################################
# By Andreas Lis <dauerflucher@googlemail.com>
# Released under GNU General Public License 3.0
# Copyright (c) 2011
#
# Last updated on Jan /25/2011
#
##GNU GENERAL PUBLIC LICENSE 3.0################################################
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/> or write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
##GENERAL INFORMATION###########################################################
# This script provides additional functionality for window operations with
# EWMH/NetWM compatible X Window Managers such as metacity, xfwm4, kwin, icewm,
# window maker or openbox. Possibly newer versions of some of those window
# managers might already support all or some of the features innately.
#
# Dependencies:
# wmctrl, xdotool, xwit, EWMH/NetWM compatible X Window Manager
#
##END OF HEAD###################################################################
# Uncomment for debugging
#set -x
# Define global variables
# Remaining global variables are defined in configuration file - see line 339
if [ "$1" != "-h" ] && [ "$1" != "-?" ] && [ "$1" != "-s" ] && [ "$1" != "-V" ]
then
# Get active desktop
#desk_active=$(xdotool get_desktop)
#desk_active=$(wmctrl -d | grep "*" | cut -d " " -f1)
desk_active=$(wmctrl -d | awk '/\*/{print $1}')
# Get all window IDs from windows on active desktop
#win_id_all=$(wmctrl -l | grep " $desk_active" | cut -d " " -f1)
win_id_all=$(wmctrl -l | awk '/ '$desk_active'/{print $1}')
# Store in array for further processing
win_array=( $win_id_all )
# Get total of all windows on active dekstop
win_count=${#win_array[@]}
if [ "$1" = "-lrr" ] || [ "$1" = "-rll" ] || [ "$1" = "-tbb" ] || [ "$1" = "-btt" ] || [ "$1" = "-m" ] || [ "$1" = "-u" ]
then
# Get window ID of currently active window
win_active=$(xdotool getactivewindow)
fi
fi
# Path of configuration file
config_path="$HOME/.config/window-foo"
config_file="window-foo.cfg"
# Display usage information
function usage () {
cat <<USAGE
Window-Foo - Based on several command line utilities this script provides
additional functionality for window operations with EWMH/NetWM compatible X
Window Managers. Mainly meant to be controlled via keyboard shortcuts, please
apply those in your keyboard settings manually.
To ensure the script is working properly with your screen resolution and window
manager theme please edit the configuration file accordingly.
Dependencies:
wmctrl, xdotool, xwit, EWMH/NetWM compatible X Window Manager
Usage:
window-foo [PARAMETER] (best applied to keyboard shortcut)
Example:
window-foo -l (applied to SHIFT+ALT+KP_LEFT)
Parameters:
General:
-h -? Displays usage information
-s Opens window-foo configuration file with the default editor set in
the $EDITOR environment variable or creates configuration file if
non-existent in $HOME/.config/window-foo/window-foo.cfg
This function is automatically invoked if no configuration file is
found
-V Displays version and license information
Active window only:
-l Snap active window at left screen edge maximized vertically
-------------
| |
| a |
| |
-------------
-r Snap active window at right screen edge maximized vertically
-------------
| |
| a |
| |
-------------
-t Snap active window at top screen edge maximized horizontally
-------------
| a |
-------------
-------------
-b Snap active window at bottom screen edge maximized horizontally
-------------
-------------
| a |
-------------
-f Toggle active window maximized
-------------
| |
| a |
| |
-------------
-pt Set active window height to screen height half and snap to top edge
-------------
| a |
---------
-------------
-pb Set active window height to screen height half and snap to bottom
edge
-------------
| a |
---------
-------------
-tl Set active window height to screen height half and snap to top left
screen corner
-------------
| a |
-------
-------------
-bl Set active window height to screen height half and snap to bottom
left screen corner
-------------
-------
| a |
-------------
-tr Set active window height to screen height half and snap to top right
screen corner
-------------
| a |
-------
-------------
-br Set active window height to screen height half and snap to bottom
right screen corner
-------------
-------
| a |
-------------
All windows on active desktop:
-lr Snap all windows alternating to left and right screen edges with
screen width half and maximized vertically
-------------
| | |
| | |
| | |
-------------
-tb Snap all windows alternating to top and bottom screen edges with
screen height half and maximized horizontally
-------------
| |
-------------
| |
-------------
-lrr Snap active window to left screen edge maximized vertically, stack
inactive windows alternating to top and bottom right screen corners
-------------
| | |
| a -------
| | |
-------------
-rll Snap active window to right screen edge maximized vertically, stack
inactive windows alternating to top and bottom left screen corners
-------------
| | |
------- a |
| | |
-------------
-tbb Snap active window to top screen edge maximized horizontally, stack
inactive windows alternating to bottom left and right screen corners
-------------
| a |
-------------
| | |
-------------
-btt Snap active window to bottom screen edge maximized horizontally,
stack inactive windows alternating to top left and right screen
corners
-------------
| | |
-------------
| a |
-------------
-tblr Snap all windows alternating to top and bottom left and right screen
corners
-------------
| | |
-------------
| | |
-------------
-m Minimize resp. iconify all windows expect active one on current
desktop
-u Unminimize resp. popup all windows on current desktop
USAGE
}
# Create a default config file
function config () {
cat << CONFIG
##WINDOW-FOO CONFIGURATION FILE#################################################
# To ensure the script working properly with your screen resolution and window
# manager theme you have to change the values of the following variables
# accordingly. Unit is pixels.
# To get the border sizes for your window manager theme have a look in the theme
# folder in /usr/share/themes/.
# The default values currently feature a 1440x900 wide screen resolution with
# window manager theme Shiki-Colors-Easy and one 32px panel at the bottom.
################################################################################
# Screen resolution
screen_width="1440"
screen_height="900"
# Top panel height
top_panel="0"
# Bottom panel height
bottom_panel="32"
# Left panel width
left_panel="0"
# Right panel width
right_panel="0"
# Window title bar height
title_bar="25"
# Window left border width
left_border="3"
# Window right border width
right_border="3"
# Window bottom border width
bottom_border="3"
# Additional window margins (space between window borders)
window_margin="1"
CONFIG
}
function version () {
cat << VERSION
Window-Foo --
By Andreas Lis <dauerflucher@googlemail.com>
Released unter GNU General Public License 3.0
Copyright (c) 2011
Last updated on Jan /25/2011
VERSION
}
# Function to create and edit configuration file
# Configuration file contains remaining global variables
function setup () {
if [ -e $config_path/$config_file ]
then
editor $config_path/$config_file
else
mkdir -p $config_path
config > $config_path/$config_file
editor $config_path/$config_file
fi
}
# Check if a configuration file is existent
if [ -e $config_path/$config_file ]
then
# Source configuration file to define remaining global variables
if [ "$1" != "-h" ] && [ "$1" != "-?" ] && [ "$1" != "-V" ]
then
source $config_path/$config_file
fi
else
# If non-existent invoke setup function except user manually executes setup
if [ "$1" != "-s" ]
then
setup
fi
fi
# Functions to define variables for window geometry
function left () {
w=$(( $screen_width/2 - $left_border - $right_border - $left_panel/2 - $right_panel/2 - $window_margin ))
h=$(( $screen_height - $title_bar - $bottom_border -$top_panel - $bottom_panel ))
x=$(( 0 + $left_panel ))
y=$(( 0 + $top_panel ))
}
function right () {
w=$(( $screen_width/2 - $left_border - $right_border - $left_panel/2 - $right_panel/2 - $window_margin ))
h=$(( $screen_height - $title_bar - $bottom_border -$top_panel - $bottom_panel ))
x=$(( $screen_width/2 - $right_panel/2 + $left_panel/2 + $window_margin ))
y=$(( 0 + $top_panel ))
}
function top () {
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
w=$(( $screen_width - $left_border - $right_border - $left_panel - $right_panel ))
x=$(( 0 + $left_panel ))
y=$(( 0 + $top_panel ))
}
function bottom () {
w=$(( $screen_width - $left_border - $right_border - $left_panel - $right_panel ))
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
x=$(( 0 + $left_panel ))
y=$(( $screen_height/2 - $bottom_panel/2 + $top_panel/2 ))
}
function top_left () {
w=$(( $screen_width/2 - $left_border - $right_border - $left_panel/2 - $right_panel/2 - $window_margin ))
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
x=$(( 0 + $left_panel ))
y=$(( 0 + $top_panel ))
}
function bottom_left () {
w=$(( $screen_width/2 - $left_border - $right_border - $left_panel/2 - $right_panel/2 - $window_margin ))
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
x=$(( 0 + $left_panel/2 + $right_panel/2 + $window_margin ))
y=$(( $screen_height/2 - $bottom_panel/2 + $top_panel/2 ))
}
function top_right () {
w=$(( $screen_width/2 - $left_border - $right_border - $left_panel/2 - $right_panel/2 - $window_margin ))
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
x=$(( $screen_width/2 - $right_panel/2 + $left_panel/2 + $window_margin ))
y=$(( 0 + $top_panel ))
}
function bottom_right () {
w=$(( $screen_width/2 - $left_border - $right_border - $left_panel/2 - $right_panel/2 - $window_margin ))
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
x=$(( $screen_width/2 - $right_panel/2 + $left_panel/2 + $window_margin ))
y=$(( $screen_height/2 - $bottom_panel/2 + $top_panel/2 ))
}
function pos_top () {
w="-1"
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
x="-1"
y=$(( 0 + $top_panel ))
}
function pos_bottom () {
w="-1"
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
x="-1"
y=$(( $screen_height/2 - $bottom_panel/2 - $top_panel/2 ))
}
# wmctrl commands for window placement
function place () {
wmctrl -i -r $win_id -e 0,$x,$y,$w,$h
}
function place_active () {
wmctrl -r :ACTIVE: -e 0,$x,$y,$w,$h
}
# Functions for each type of placement grid
function left_right () {
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
if [ "$(( $n % 2 ))" -eq "0" ]
then
left && place
else
right && place
fi
done
}
function top_bottom () {
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
if [ "$(( $n % 2 ))" -eq "0" ]
then
top && place
else
bottom && place
fi
done
}
function left_right_right () {
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
let win_current=$win_id
if [ "$(( $n % 3 ))" -eq "0" ]
then
if [ $win_active = $win_current ]
then
left && place
else
top_right && place
fi
elif [ "$(( $n % 3 ))" -eq "1" ]
then
if [ $win_active = $win_current ]
then
left && place
else
bottom_right && place
fi
elif [ "$(( $n % 3 ))" -eq "2" ]
then
if [ $win_active = $win_current ]
then
left && place
else
top_right && place
fi
fi
done
}
function right_left_left () {
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
let win_current=$win_id
if [ "$(( $n % 3 ))" -eq "0" ]
then
if [ $win_active = $win_current ]
then
right && place
else
top_left && place
fi
elif [ "$(( $n % 3 ))" -eq "1" ]
then
if [ $win_active = $win_current ]
then
right && place
else
bottom_left && place
fi
elif [ "$(( $n % 3 ))" -eq "2" ]
then
if [ $win_active = $win_current ]
then
right && place
else
top_left && place
fi
fi
done
}
function top_bottom_bottom () {
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
let win_current=$win_id
if [ "$(( $n % 3 ))" -eq "0" ]
then
if [ $win_active = $win_current ]
then
top && place
else
bottom_left && place
fi
elif [ "$(( $n % 3 ))" -eq "1" ]
then
if [ $win_active = $win_current ]
then
top && place
else
bottom_right && place
fi
elif [ "$(( $n % 3 ))" -eq "2" ]
then
if [ $win_active = $win_current ]
then
top && place
else
bottom_left && place
fi
fi
done
}
function bottom_top_top () {
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
let win_current=$win_id
if [ "$(( $n % 3 ))" -eq "0" ]
then
if [ $win_active = $win_current ]
then
bottom && place
else
top_left && place
fi
elif [ "$(( $n % 3 ))" -eq "1" ]
then
if [ $win_active = $win_current ]
then
bottom && place
else
top_right && place
fi
elif [ "$(( $n % 3 ))" -eq "2" ]
then
if [ $win_active = $win_current ]
then
bottom && place
else
top_left && place
fi
fi
done
}
function top_bottom_left_right () {
for (( n=0 ; n <= $(($win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
if [ "$(( $n % 4 ))" -eq "0" ]
then
top_left && place
elif [ "$(( $n % 4 ))" -eq "1" ]
then
bottom_left && place
elif [ "$(( $n % 4 ))" -eq "2" ]
then
top_right && place
elif [ "$(( $n % 4 ))" -eq "3" ]
then
bottom_right && place
fi
done
}
function minimize () {
for i in ${win_array[@]}
do
# wmctrl outputs hex, xdotool and xwit use decimal values for window IDs
# let converts those hex to decimal values
let win_id=$i
if [ "$win_active" != "$win_id" ]
then
xwit -iconify -id $win_id
fi
done
}
function unminimize () {
for i in ${win_array[@]}
do
# See function win_minimize for explaination
let win_id=$i
if [ "$win_active" != "$win_id" ]
then
# Give focus to each unhidden window to avoid pager blinking
xwit -pop -focus -id $win_id
fi
done
# Give focus to formerly active window again
xwit -focus -id $win_active
}
# Bring together parameters and according functions
function win_foo () {
case $1 in
-h)
usage
echo ""
version
;;
-\?)
usage
echo ""
version
;;
-s)
setup
;;
-V)
version
;;
-l)
left && place_active
;;
-r)
right && place_active
;;
-t)
top && place_active
;;
-b)
bottom && place_active
;;
-f)
wmctrl -r :ACTIVE: -b toggle,maximized_vert,maximized_horz
;;
-pt)
pos_top && place_active
;;
-pb)
pos_bottom && place_active
;;
-tl)
top_left && place_active
;;
-bl)
bottom_left && place_active
;;
-tr)
top_right && place_active
;;
-br)
bottom_right && place_active
;;
-lr)
left_right
;;
-tb)
top_bottom
;;
-lrr)
left_right_right
;;
-rll)
right_left_left
;;
-tbb)
top_bottom_bottom
;;
-btt)
bottom_top_top
;;
-tblr)
top_bottom_left_right
;;
-m)
minimize
;;
-u)
unminimize
;;
*)
exit 1
;;
esac
}
# Let it happen
win_foo $1
|
Das Script im Anhang nochmal als Datei.
- window-foo (16.7 KiB)
- Download window-foo
|
mrkramps
(Themenstarter)
Anmeldungsdatum: 10. Oktober 2006
Beiträge: 5523
Wohnort: south central EL
|
Ich habe noch ein paar Änderungen vorgenommen. Zum einem ist mir irgendwie entfallen, dass ich das Script mal window-fu getauft habe und nicht window-foo. Nach kurzer Überlegung habe ich mich jetzt allerdings dazu entschieden es einfacher und eingängiger win-fu zu taufen. Entsprechende Namensänderungen wurde im Script übernommen. Die Konfigurationsdatei wird jetzt allerdings in $HOME/.config/win-fu/win-fu.cfg angelegt. Eine bereits bestehende Konfigurationsdatei in $HOME/.config/window-foo/window-foo.cfg muss von Hand gelöscht werden. Zum anderen kam es zu Problemen, weil scheinbar bei einigen Programmen die Fensterrahmen nicht erkannt werden. Das kann man damit umgehen, wenn man für wmctrl die Einstellung Gravity 10 verwendet. Damit wird nur die Geometrie der Fensterinhalte beeinflusst und die Fensterrahmen ignoriert. Die Geomertriefunktionen im Script habe ich jetzt entsprechend angepasst. Nochmal das Script:
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767 | #!/bin/bash
##WIN-FU####################################################################
# By Andreas Lis <dauerflucher@googlemail.com>
# Released under GNU General Public License 3.0
# Copyright (c) 2011
#
# Last updated on Jan /27/2011
#
##GNU GENERAL PUBLIC LICENSE 3.0################################################
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/> or write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
##GENERAL INFORMATION###########################################################
# This script provides additional functionality for window operations with
# EWMH/NetWM compatible X Window Managers such as metacity, xfwm4, kwin, icewm,
# window maker or openbox. Possibly newer versions of some of those window
# managers might already support all or some of the features innately.
#
# Dependencies:
# wmctrl, xdotool, xwit, EWMH/NetWM compatible X Window Manager
#
##END OF HEAD###################################################################
# Uncomment for debugging
#set -x
# Define global variables
# Remaining global variables are defined in configuration file - see line 339
if [ "$1" != "-h" ] && [ "$1" != "-?" ] && [ "$1" != "-s" ] && [ "$1" != "-V" ]
then
# Get active desktop
#desk_active=$(xdotool get_desktop)
#desk_active=$(wmctrl -d | grep "*" | cut -d " " -f1)
desk_active=$(wmctrl -d | awk '/\*/{print $1}')
# Get all window IDs from windows on active desktop
#win_id_all=$(wmctrl -l | grep " $desk_active" | cut -d " " -f1)
win_id_all=$(wmctrl -l | awk '/ '$desk_active'/{print $1}')
# Store in array for further processing
win_array=( $win_id_all )
# Get total of all windows on active dekstop
win_count=${#win_array[@]}
if [ "$1" = "-lrr" ] || [ "$1" = "-rll" ] || [ "$1" = "-tbb" ] || [ "$1" = "-btt" ] || [ "$1" = "-m" ] || [ "$1" = "-u" ]
then
# Get window ID of currently active window
win_active=$(xdotool getactivewindow)
fi
fi
# Path of configuration file
config_path="$HOME/.config/win-fu"
config_file="win-fu.cfg"
# Display usage information
function usage () {
cat <<USAGE
WIN-FU - Based on several command line utilities this script provides
additional functionality for window operations with EWMH/NetWM compatible X
Window Managers. Mainly meant to be controlled via keyboard shortcuts, please
apply those in your keyboard settings manually.
To ensure the script is working properly with your screen resolution and window
manager theme please edit the configuration file accordingly.
Dependencies:
wmctrl, xdotool, xwit, EWMH/NetWM compatible X Window Manager
Usage:
win-fu [PARAMETER] (best applied to keyboard shortcut)
Example:
win-fu -l (applied to SHIFT+ALT+KP_LEFT)
Parameters:
General:
-h -? Displays usage information
-s Opens win-fu configuration file with the default editor set in
the $EDITOR environment variable or creates configuration file if
non-existent in $HOME/.config/win-fu/win-fu.cfg
This function is automatically invoked if no configuration file is
found
-V Displays version and license information
Active window only:
-l Snap active window at left screen edge maximized vertically
-------------
| |
| a |
| |
-------------
-r Snap active window at right screen edge maximized vertically
-------------
| |
| a |
| |
-------------
-t Snap active window at top screen edge maximized horizontally
-------------
| a |
-------------
-------------
-b Snap active window at bottom screen edge maximized horizontally
-------------
-------------
| a |
-------------
-f Toggle active window maximized
-------------
| |
| a |
| |
-------------
-pt Set active window height to screen height half and snap to top edge
-------------
| a |
---------
-------------
-pb Set active window height to screen height half and snap to bottom
edge
-------------
| a |
---------
-------------
-tl Set active window height to screen height half and snap to top left
screen corner
-------------
| a |
-------
-------------
-bl Set active window height to screen height half and snap to bottom
left screen corner
-------------
-------
| a |
-------------
-tr Set active window height to screen height half and snap to top right
screen corner
-------------
| a |
-------
-------------
-br Set active window height to screen height half and snap to bottom
right screen corner
-------------
-------
| a |
-------------
All windows on active desktop:
-lr Snap all windows alternating to left and right screen edges with
screen width half and maximized vertically
-------------
| | |
| | |
| | |
-------------
-tb Snap all windows alternating to top and bottom screen edges with
screen height half and maximized horizontally
-------------
| |
-------------
| |
-------------
-lrr Snap active window to left screen edge maximized vertically, stack
inactive windows alternating to top and bottom right screen corners
-------------
| | |
| a -------
| | |
-------------
-rll Snap active window to right screen edge maximized vertically, stack
inactive windows alternating to top and bottom left screen corners
-------------
| | |
------- a |
| | |
-------------
-tbb Snap active window to top screen edge maximized horizontally, stack
inactive windows alternating to bottom left and right screen corners
-------------
| a |
-------------
| | |
-------------
-btt Snap active window to bottom screen edge maximized horizontally,
stack inactive windows alternating to top left and right screen
corners
-------------
| | |
-------------
| a |
-------------
-tblr Snap all windows alternating to top and bottom left and right screen
corners
-------------
| | |
-------------
| | |
-------------
-m Minimize resp. iconify all windows expect active one on current
desktop
-u Unminimize resp. popup all windows on current desktop
USAGE
}
# Create a default config file
function config () {
cat << CONFIG
##WIN-FU CONFIGURATION FILE#################################################
# To ensure the script working properly with your screen resolution and window
# manager theme you have to change the values of the following variables
# accordingly. Unit is pixels.
# To get the border sizes for your window manager theme have a look in the theme
# folder in /usr/share/themes/.
# The default values currently feature a 1440x900 wide screen resolution with
# window manager theme Shiki-Colors-Easy and one 32px panel at the bottom.
################################################################################
# Screen resolution
screen_width="1440"
screen_height="900"
# Top panel height
top_panel="0"
# Bottom panel height
bottom_panel="32"
# Left panel width
left_panel="0"
# Right panel width
right_panel="0"
# Window title bar height
title_bar="25"
# Window left border width
left_border="3"
# Window right border width
right_border="3"
# Window bottom border width
bottom_border="3"
# Additional window margins (space between window borders)
window_margin="1"
CONFIG
}
function version () {
cat << VERSION
WIN-FU --
By Andreas Lis <dauerflucher@googlemail.com>
Released unter GNU General Public License 3.0
Copyright (c) 2011
Last updated on Jan /27/2011
VERSION
}
# Function to create and edit configuration file
# Configuration file contains remaining global variables
function setup () {
if [ -e $config_path/$config_file ]
then
editor $config_path/$config_file
else
mkdir -p $config_path
config > $config_path/$config_file
editor $config_path/$config_file
fi
}
# Check if a configuration file is existent
if [ -e $config_path/$config_file ]
then
# Source configuration file to define remaining global variables
if [ "$1" != "-h" ] && [ "$1" != "-?" ] && [ "$1" != "-V" ]
then
source $config_path/$config_file
fi
else
# If non-existent invoke setup function except user manually executes setup
if [ "$1" != "-s" ]
then
setup
fi
fi
# Functions to define variables for window geometry
function left () {
w=$(( $screen_width/2 - $left_border - $right_border - $left_panel/2 - $right_panel/2 - $window_margin ))
h=$(( $screen_height - $title_bar - $bottom_border -$top_panel - $bottom_panel ))
# For use with wmctrl and gravity 10
x=$(( 0 + $left_panel + $left_border ))
y=$(( 0 + $top_panel + $title_bar ))
# For use with wmctrl and gravity 0
#x=$(( 0 + $left_panel ))
#y=$(( 0 + $top_panel ))
}
function right () {
w=$(( $screen_width/2 - $left_border - $right_border - $left_panel/2 - $right_panel/2 - $window_margin ))
h=$(( $screen_height - $title_bar - $bottom_border -$top_panel - $bottom_panel ))
# For use with wmctrl and gravity 10
x=$(( $screen_width/2 - $right_panel/2 + $left_panel/2 + $window_margin + $right_border ))
y=$(( 0 + $top_panel + $title_bar ))
# For use with wmctrl and gravity 0
#x=$(( $screen_width/2 - $right_panel/2 + $left_panel/2 + $window_margin ))
#y=$(( 0 + $top_panel ))
}
function top () {
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
w=$(( $screen_width - $left_border - $right_border - $left_panel - $right_panel ))
# For use with wmctrl and gravity 10
x=$(( 0 + $left_panel + $left_border ))
y=$(( 0 + $top_panel + $title_bar ))
# For use with wmctrl and gravity 0
#x=$(( 0 + $left_panel ))
#y=$(( 0 + $top_panel ))
}
function bottom () {
w=$(( $screen_width - $left_border - $right_border - $left_panel - $right_panel ))
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
# For use with wmctrl and gravity 10
x=$(( 0 + $left_panel + $left_border ))
y=$(( $screen_height/2 - $bottom_panel/2 + $top_panel/2 + $title_bar ))
# For use with wmctrl and gravity 0
#x=$(( 0 + $left_panel ))
#y=$(( $screen_height/2 - $bottom_panel/2 + $top_panel/2 ))
}
function top_left () {
w=$(( $screen_width/2 - $left_border - $right_border - $left_panel/2 - $right_panel/2 - $window_margin ))
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
# For use with wmctrl and gravity 10
x=$(( 0 + $left_panel + $left_border ))
y=$(( 0 + $top_panel + $title_bar ))
# For use with wmctrl and gravity 0
#x=$(( 0 + $left_panel ))
#y=$(( 0 + $top_panel ))
}
function bottom_left () {
w=$(( $screen_width/2 - $left_border - $right_border - $left_panel/2 - $right_panel/2 - $window_margin ))
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
# For use with wmctrl and gravity 10
x=$(( 0 + $left_panel/2 + $right_panel/2 + $window_margin + $left_border ))
y=$(( $screen_height/2 - $bottom_panel/2 + $top_panel/2 + $title_bar ))
# For use with wmctrl and gravity 0
#x=$(( 0 + $left_panel/2 + $right_panel/2 + $window_margin ))
#y=$(( $screen_height/2 - $bottom_panel/2 + $top_panel/2 ))
}
function top_right () {
w=$(( $screen_width/2 - $left_border - $right_border - $left_panel/2 - $right_panel/2 - $window_margin ))
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
# For use with wmctrl and gravity 10
x=$(( $screen_width/2 - $right_panel/2 + $left_panel/2 + $window_margin + $right_border ))
y=$(( 0 + $top_panel + $title_bar ))
# For use with wmctrl and gravity 0
#x=$(( $screen_width/2 - $right_panel/2 + $left_panel/2 + $window_margin ))
#y=$(( 0 + $top_panel ))
}
function bottom_right () {
w=$(( $screen_width/2 - $left_border - $right_border - $left_panel/2 - $right_panel/2 - $window_margin ))
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
# For use with wmctrl and gravity 10
x=$(( $screen_width/2 - $right_panel/2 + $left_panel/2 + $window_margin + $right_border ))
y=$(( $screen_height/2 - $bottom_panel/2 + $top_panel/2 + $title_bar ))
# For use with wmctrl and gravity 0
#x=$(( $screen_width/2 - $right_panel/2 + $left_panel/2 + $window_margin ))
#y=$(( $screen_height/2 - $bottom_panel/2 + $top_panel/2 ))
}
function pos_top () {
w="-1"
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
x="-1"
# For use with wmctrl and gravity 10
y=$(( 0 + $top_panel + $title_bar ))
# For use with wmctrl and gravity 0
#y=$(( 0 + $top_panel ))
}
function pos_bottom () {
w="-1"
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
x="-1"
if [ -n "$(xprop -id $(xdotool getactivewindow) | grep Scribes)" ]
then
y=$(( $screen_height/2 - $bottom_panel/2 - $top_panel/2 + $title_bar ))
else
y=$(( $screen_height/2 - $bottom_panel/2 - $top_panel/2 ))
fi
}
# wmctrl commands for window placement
# Use gravity 10 to influence window content geometry only and avoid problems
# with window manager theme borders not properly recognized for some programs
function place () {
wmctrl -i -r $win_id -e 10,$x,$y,$w,$h
}
function place_active () {
wmctrl -r :ACTIVE: -e 10,$x,$y,$w,$h
}
# Functions for each type of placement grid
function left_right () {
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
if [ "$(( $n % 2 ))" -eq "0" ]
then
left && place
else
right && place
fi
done
}
function top_bottom () {
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
if [ "$(( $n % 2 ))" -eq "0" ]
then
top && place
else
bottom && place
fi
done
}
function left_right_right () {
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
let win_current=$win_id
if [ "$(( $n % 3 ))" -eq "0" ]
then
if [ $win_active = $win_current ]
then
left && place
else
top_right && place
fi
elif [ "$(( $n % 3 ))" -eq "1" ]
then
if [ $win_active = $win_current ]
then
left && place
else
bottom_right && place
fi
elif [ "$(( $n % 3 ))" -eq "2" ]
then
if [ $win_active = $win_current ]
then
left && place
else
top_right && place
fi
fi
done
}
function right_left_left () {
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
let win_current=$win_id
if [ "$(( $n % 3 ))" -eq "0" ]
then
if [ $win_active = $win_current ]
then
right && place
else
top_left && place
fi
elif [ "$(( $n % 3 ))" -eq "1" ]
then
if [ $win_active = $win_current ]
then
right && place
else
bottom_left && place
fi
elif [ "$(( $n % 3 ))" -eq "2" ]
then
if [ $win_active = $win_current ]
then
right && place
else
top_left && place
fi
fi
done
}
function top_bottom_bottom () {
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
let win_current=$win_id
if [ "$(( $n % 3 ))" -eq "0" ]
then
if [ $win_active = $win_current ]
then
top && place
else
bottom_left && place
fi
elif [ "$(( $n % 3 ))" -eq "1" ]
then
if [ $win_active = $win_current ]
then
top && place
else
bottom_right && place
fi
elif [ "$(( $n % 3 ))" -eq "2" ]
then
if [ $win_active = $win_current ]
then
top && place
else
bottom_left && place
fi
fi
done
}
function bottom_top_top () {
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
let win_current=$win_id
if [ "$(( $n % 3 ))" -eq "0" ]
then
if [ $win_active = $win_current ]
then
bottom && place
else
top_left && place
fi
elif [ "$(( $n % 3 ))" -eq "1" ]
then
if [ $win_active = $win_current ]
then
bottom && place
else
top_right && place
fi
elif [ "$(( $n % 3 ))" -eq "2" ]
then
if [ $win_active = $win_current ]
then
bottom && place
else
top_left && place
fi
fi
done
}
function top_bottom_left_right () {
for (( n=0 ; n <= $(($win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
if [ "$(( $n % 4 ))" -eq "0" ]
then
top_left && place
elif [ "$(( $n % 4 ))" -eq "1" ]
then
bottom_left && place
elif [ "$(( $n % 4 ))" -eq "2" ]
then
top_right && place
elif [ "$(( $n % 4 ))" -eq "3" ]
then
bottom_right && place
fi
done
}
function minimize () {
for i in ${win_array[@]}
do
# wmctrl outputs hex, xdotool and xwit use decimal values for window IDs
# let converts those hex to decimal values
let win_id=$i
if [ "$win_active" != "$win_id" ]
then
xwit -iconify -id $win_id
fi
done
}
function unminimize () {
for i in ${win_array[@]}
do
# See function minimize for explaination
let win_id=$i
if [ "$win_active" != "$win_id" ]
then
# Give focus to each unhidden window to avoid pager blinking
xwit -pop -focus -id $win_id
fi
done
# Give focus to formerly active window again
xwit -focus -id $win_active
}
# Bring together parameters and according functions
function win_fu () {
case $1 in
-h)
usage
echo ""
version
;;
-\?)
usage
echo ""
version
;;
-s)
setup
;;
-V)
version
;;
-l)
left && place_active
;;
-r)
right && place_active
;;
-t)
top && place_active
;;
-b)
bottom && place_active
;;
-f)
wmctrl -r :ACTIVE: -b toggle,maximized_vert,maximized_horz
;;
-pt)
pos_top && place_active
;;
-pb)
pos_bottom && place_active
;;
-tl)
top_left && place_active
;;
-bl)
bottom_left && place_active
;;
-tr)
top_right && place_active
;;
-br)
bottom_right && place_active
;;
-lr)
left_right
;;
-tb)
top_bottom
;;
-lrr)
left_right_right
;;
-rll)
right_left_left
;;
-tbb)
top_bottom_bottom
;;
-btt)
bottom_top_top
;;
-tblr)
top_bottom_left_right
;;
-m)
minimize
;;
-u)
unminimize
;;
*)
exit 1
;;
esac
}
# Let it happen
win_fu $1
|
Und im Anhang das ganze nochmal als Datei. Über Feedback würde ich mich immer noch freuen.
- win-fu (18.6 KiB)
- Download win-fu
|
mrkramps
(Themenstarter)
Anmeldungsdatum: 10. Oktober 2006
Beiträge: 5523
Wohnort: south central EL
|
Da ist mir beim Umschreiben der Geometriefunktionen eine durchgerutscht... Fixed. Das Script:
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765 | #!/bin/bash
##WIN-FU####################################################################
# By Andreas Lis <dauerflucher@googlemail.com>
# Released under GNU General Public License 3.0
# Copyright (c) 2011
#
# Last updated on Jan /28/2011
#
##GNU GENERAL PUBLIC LICENSE 3.0################################################
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/> or write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
##GENERAL INFORMATION###########################################################
# This script provides additional functionality for window operations with
# EWMH/NetWM compatible X Window Managers such as metacity, xfwm4, kwin, icewm,
# window maker or openbox. Possibly newer versions of some of those window
# managers might already support all or some of the features innately.
#
# Dependencies:
# wmctrl, xdotool, xwit, EWMH/NetWM compatible X Window Manager
#
##END OF HEAD###################################################################
# Uncomment for debugging
#set -x
# Define global variables
# Remaining global variables are defined in configuration file - see line 339
if [ "$1" != "-h" ] && [ "$1" != "-?" ] && [ "$1" != "-s" ] && [ "$1" != "-V" ]
then
# Get active desktop
#desk_active=$(xdotool get_desktop)
#desk_active=$(wmctrl -d | grep "*" | cut -d " " -f1)
desk_active=$(wmctrl -d | awk '/\*/{print $1}')
# Get all window IDs from windows on active desktop
#win_id_all=$(wmctrl -l | grep " $desk_active" | cut -d " " -f1)
win_id_all=$(wmctrl -l | awk '/ '$desk_active'/{print $1}')
# Store in array for further processing
win_array=( $win_id_all )
# Get total of all windows on active dekstop
win_count=${#win_array[@]}
if [ "$1" = "-lrr" ] || [ "$1" = "-rll" ] || [ "$1" = "-tbb" ] || [ "$1" = "-btt" ] || [ "$1" = "-m" ] || [ "$1" = "-u" ]
then
# Get window ID of currently active window
win_active=$(xdotool getactivewindow)
fi
fi
# Path of configuration file
config_path="$HOME/.config/win-fu"
config_file="win-fu.cfg"
# Display usage information
function usage () {
cat <<USAGE
WIN-FU - Based on several command line utilities this script provides
additional functionality for window operations with EWMH/NetWM compatible X
Window Managers. Mainly meant to be controlled via keyboard shortcuts, please
apply those in your keyboard settings manually.
To ensure the script is working properly with your screen resolution and window
manager theme please edit the configuration file accordingly.
Dependencies:
wmctrl, xdotool, xwit, EWMH/NetWM compatible X Window Manager
Usage:
win-fu [PARAMETER] (best applied to keyboard shortcut)
Example:
win-fu -l (applied to SHIFT+ALT+KP_LEFT)
Parameters:
General:
-h -? Displays usage information
-s Opens win-fu configuration file with the default editor set in
the $EDITOR environment variable or creates configuration file if
non-existent in $HOME/.config/win-fu/win-fu.cfg
This function is automatically invoked if no configuration file is
found
-V Displays version and license information
Active window only:
-l Snap active window at left screen edge maximized vertically
-------------
| |
| a |
| |
-------------
-r Snap active window at right screen edge maximized vertically
-------------
| |
| a |
| |
-------------
-t Snap active window at top screen edge maximized horizontally
-------------
| a |
-------------
-------------
-b Snap active window at bottom screen edge maximized horizontally
-------------
-------------
| a |
-------------
-f Toggle active window maximized
-------------
| |
| a |
| |
-------------
-pt Set active window height to screen height half and snap to top edge
-------------
| a |
---------
-------------
-pb Set active window height to screen height half and snap to bottom
edge
-------------
| a |
---------
-------------
-tl Set active window height to screen height half and snap to top left
screen corner
-------------
| a |
-------
-------------
-bl Set active window height to screen height half and snap to bottom
left screen corner
-------------
-------
| a |
-------------
-tr Set active window height to screen height half and snap to top right
screen corner
-------------
| a |
-------
-------------
-br Set active window height to screen height half and snap to bottom
right screen corner
-------------
-------
| a |
-------------
All windows on active desktop:
-lr Snap all windows alternating to left and right screen edges with
screen width half and maximized vertically
-------------
| | |
| | |
| | |
-------------
-tb Snap all windows alternating to top and bottom screen edges with
screen height half and maximized horizontally
-------------
| |
-------------
| |
-------------
-lrr Snap active window to left screen edge maximized vertically, stack
inactive windows alternating to top and bottom right screen corners
-------------
| | |
| a -------
| | |
-------------
-rll Snap active window to right screen edge maximized vertically, stack
inactive windows alternating to top and bottom left screen corners
-------------
| | |
------- a |
| | |
-------------
-tbb Snap active window to top screen edge maximized horizontally, stack
inactive windows alternating to bottom left and right screen corners
-------------
| a |
-------------
| | |
-------------
-btt Snap active window to bottom screen edge maximized horizontally,
stack inactive windows alternating to top left and right screen
corners
-------------
| | |
-------------
| a |
-------------
-tblr Snap all windows alternating to top and bottom left and right screen
corners
-------------
| | |
-------------
| | |
-------------
-m Minimize resp. iconify all windows expect active one on current
desktop
-u Unminimize resp. popup all windows on current desktop
USAGE
}
# Create a default config file
function config () {
cat << CONFIG
##WIN-FU CONFIGURATION FILE#################################################
# To ensure the script working properly with your screen resolution and window
# manager theme you have to change the values of the following variables
# accordingly. Unit is pixels.
# To get the border sizes for your window manager theme have a look in the theme
# folder in /usr/share/themes/.
# The default values currently feature a 1440x900 wide screen resolution with
# window manager theme Shiki-Colors-Easy and one 32px panel at the bottom.
################################################################################
# Screen resolution
screen_width="1440"
screen_height="900"
# Top panel height
top_panel="0"
# Bottom panel height
bottom_panel="32"
# Left panel width
left_panel="0"
# Right panel width
right_panel="0"
# Window title bar height
title_bar="25"
# Window left border width
left_border="3"
# Window right border width
right_border="3"
# Window bottom border width
bottom_border="3"
# Additional window margins (space between window borders)
window_margin="1"
CONFIG
}
function version () {
cat << VERSION
WIN-FU --
By Andreas Lis <dauerflucher@googlemail.com>
Released unter GNU General Public License 3.0
Copyright (c) 2011
Last updated on Jan /28/2011
VERSION
}
# Function to create and edit configuration file
# Configuration file contains remaining global variables
function setup () {
if [ -e $config_path/$config_file ]
then
editor $config_path/$config_file
else
mkdir -p $config_path
config > $config_path/$config_file
editor $config_path/$config_file
fi
}
# Check if a configuration file is existent
if [ -e $config_path/$config_file ]
then
# Source configuration file to define remaining global variables
if [ "$1" != "-h" ] && [ "$1" != "-?" ] && [ "$1" != "-V" ]
then
source $config_path/$config_file
fi
else
# If non-existent invoke setup function except user manually executes setup
if [ "$1" != "-s" ]
then
setup
fi
fi
# Functions to define variables for window geometry
function left () {
w=$(( $screen_width/2 - $left_border - $right_border - $left_panel/2 - $right_panel/2 - $window_margin ))
h=$(( $screen_height - $title_bar - $bottom_border -$top_panel - $bottom_panel ))
# For use with wmctrl and gravity 10
x=$(( 0 + $left_panel + $left_border ))
y=$(( 0 + $top_panel + $title_bar ))
# For use with wmctrl and gravity 0
#x=$(( 0 + $left_panel ))
#y=$(( 0 + $top_panel ))
}
function right () {
w=$(( $screen_width/2 - $left_border - $right_border - $left_panel/2 - $right_panel/2 - $window_margin ))
h=$(( $screen_height - $title_bar - $bottom_border -$top_panel - $bottom_panel ))
# For use with wmctrl and gravity 10
x=$(( $screen_width/2 - $right_panel/2 + $left_panel/2 + $window_margin + $right_border ))
y=$(( 0 + $top_panel + $title_bar ))
# For use with wmctrl and gravity 0
#x=$(( $screen_width/2 - $right_panel/2 + $left_panel/2 + $window_margin ))
#y=$(( 0 + $top_panel ))
}
function top () {
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
w=$(( $screen_width - $left_border - $right_border - $left_panel - $right_panel ))
# For use with wmctrl and gravity 10
x=$(( 0 + $left_panel + $left_border ))
y=$(( 0 + $top_panel + $title_bar ))
# For use with wmctrl and gravity 0
#x=$(( 0 + $left_panel ))
#y=$(( 0 + $top_panel ))
}
function bottom () {
w=$(( $screen_width - $left_border - $right_border - $left_panel - $right_panel ))
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
# For use with wmctrl and gravity 10
x=$(( 0 + $left_panel + $left_border ))
y=$(( $screen_height/2 - $bottom_panel/2 + $top_panel/2 + $title_bar ))
# For use with wmctrl and gravity 0
#x=$(( 0 + $left_panel ))
#y=$(( $screen_height/2 - $bottom_panel/2 + $top_panel/2 ))
}
function top_left () {
w=$(( $screen_width/2 - $left_border - $right_border - $left_panel/2 - $right_panel/2 - $window_margin ))
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
# For use with wmctrl and gravity 10
x=$(( 0 + $left_panel + $left_border ))
y=$(( 0 + $top_panel + $title_bar ))
# For use with wmctrl and gravity 0
#x=$(( 0 + $left_panel ))
#y=$(( 0 + $top_panel ))
}
function bottom_left () {
w=$(( $screen_width/2 - $left_border - $right_border - $left_panel/2 - $right_panel/2 - $window_margin ))
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
# For use with wmctrl and gravity 10
x=$(( 0 + $left_panel/2 + $right_panel/2 + $window_margin + $left_border ))
y=$(( $screen_height/2 - $bottom_panel/2 + $top_panel/2 + $title_bar ))
# For use with wmctrl and gravity 0
#x=$(( 0 + $left_panel/2 + $right_panel/2 + $window_margin ))
#y=$(( $screen_height/2 - $bottom_panel/2 + $top_panel/2 ))
}
function top_right () {
w=$(( $screen_width/2 - $left_border - $right_border - $left_panel/2 - $right_panel/2 - $window_margin ))
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
# For use with wmctrl and gravity 10
x=$(( $screen_width/2 - $right_panel/2 + $left_panel/2 + $window_margin + $right_border ))
y=$(( 0 + $top_panel + $title_bar ))
# For use with wmctrl and gravity 0
#x=$(( $screen_width/2 - $right_panel/2 + $left_panel/2 + $window_margin ))
#y=$(( 0 + $top_panel ))
}
function bottom_right () {
w=$(( $screen_width/2 - $left_border - $right_border - $left_panel/2 - $right_panel/2 - $window_margin ))
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
# For use with wmctrl and gravity 10
x=$(( $screen_width/2 - $right_panel/2 + $left_panel/2 + $window_margin + $right_border ))
y=$(( $screen_height/2 - $bottom_panel/2 + $top_panel/2 + $title_bar ))
# For use with wmctrl and gravity 0
#x=$(( $screen_width/2 - $right_panel/2 + $left_panel/2 + $window_margin ))
#y=$(( $screen_height/2 - $bottom_panel/2 + $top_panel/2 ))
}
function pos_top () {
w="-1"
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
x="-1"
# For use with wmctrl and gravity 10
y=$(( 0 + $top_panel + $title_bar ))
# For use with wmctrl and gravity 0
#y=$(( 0 + $top_panel ))
}
function pos_bottom () {
w="-1"
h=$(( $screen_height/2 - $title_bar - $bottom_border - $top_panel/2 - $bottom_panel/2 - $window_margin ))
x="-1"
# For use with wmctrl and gravity 10
y=$(( $screen_height/2 - $bottom_panel/2 - $top_panel/2 + $title_bar ))
# For use with wmctrl and gravity 0
#y=$(( $screen_height/2 - $bottom_panel/2 - $top_panel/2 ))
}
# wmctrl commands for window placement
# Use gravity 10 to influence window content geometry only and avoid problems
# with window manager theme borders not properly recognized for some programs
function place () {
wmctrl -i -r $win_id -e 10,$x,$y,$w,$h
}
function place_active () {
wmctrl -r :ACTIVE: -e 10,$x,$y,$w,$h
}
# Functions for each type of placement grid
function left_right () {
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
if [ "$(( $n % 2 ))" -eq "0" ]
then
left && place
else
right && place
fi
done
}
function top_bottom () {
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
if [ "$(( $n % 2 ))" -eq "0" ]
then
top && place
else
bottom && place
fi
done
}
function left_right_right () {
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
let win_current=$win_id
if [ "$(( $n % 3 ))" -eq "0" ]
then
if [ $win_active = $win_current ]
then
left && place
else
top_right && place
fi
elif [ "$(( $n % 3 ))" -eq "1" ]
then
if [ $win_active = $win_current ]
then
left && place
else
bottom_right && place
fi
elif [ "$(( $n % 3 ))" -eq "2" ]
then
if [ $win_active = $win_current ]
then
left && place
else
top_right && place
fi
fi
done
}
function right_left_left () {
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
let win_current=$win_id
if [ "$(( $n % 3 ))" -eq "0" ]
then
if [ $win_active = $win_current ]
then
right && place
else
top_left && place
fi
elif [ "$(( $n % 3 ))" -eq "1" ]
then
if [ $win_active = $win_current ]
then
right && place
else
bottom_left && place
fi
elif [ "$(( $n % 3 ))" -eq "2" ]
then
if [ $win_active = $win_current ]
then
right && place
else
top_left && place
fi
fi
done
}
function top_bottom_bottom () {
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
let win_current=$win_id
if [ "$(( $n % 3 ))" -eq "0" ]
then
if [ $win_active = $win_current ]
then
top && place
else
bottom_left && place
fi
elif [ "$(( $n % 3 ))" -eq "1" ]
then
if [ $win_active = $win_current ]
then
top && place
else
bottom_right && place
fi
elif [ "$(( $n % 3 ))" -eq "2" ]
then
if [ $win_active = $win_current ]
then
top && place
else
bottom_left && place
fi
fi
done
}
function bottom_top_top () {
for (( n=0 ; n <= $((win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
let win_current=$win_id
if [ "$(( $n % 3 ))" -eq "0" ]
then
if [ $win_active = $win_current ]
then
bottom && place
else
top_left && place
fi
elif [ "$(( $n % 3 ))" -eq "1" ]
then
if [ $win_active = $win_current ]
then
bottom && place
else
top_right && place
fi
elif [ "$(( $n % 3 ))" -eq "2" ]
then
if [ $win_active = $win_current ]
then
bottom && place
else
top_left && place
fi
fi
done
}
function top_bottom_left_right () {
for (( n=0 ; n <= $(($win_count - 1)) ; n++ ))
do
win_id=${win_array[$n]}
if [ "$(( $n % 4 ))" -eq "0" ]
then
top_left && place
elif [ "$(( $n % 4 ))" -eq "1" ]
then
bottom_left && place
elif [ "$(( $n % 4 ))" -eq "2" ]
then
top_right && place
elif [ "$(( $n % 4 ))" -eq "3" ]
then
bottom_right && place
fi
done
}
function minimize () {
for i in ${win_array[@]}
do
# wmctrl outputs hex, xdotool and xwit use decimal values for window IDs
# let converts those hex to decimal values
let win_id=$i
if [ "$win_active" != "$win_id" ]
then
xwit -iconify -id $win_id
fi
done
}
function unminimize () {
for i in ${win_array[@]}
do
# See function minimize for explaination
let win_id=$i
if [ "$win_active" != "$win_id" ]
then
# Give focus to each unhidden window to avoid pager blinking
xwit -pop -focus -id $win_id
fi
done
# Give focus to formerly active window again
xwit -focus -id $win_active
}
# Bring together parameters and according functions
function win_fu () {
case $1 in
-h)
usage
echo ""
version
;;
-\?)
usage
echo ""
version
;;
-s)
setup
;;
-V)
version
;;
-l)
left && place_active
;;
-r)
right && place_active
;;
-t)
top && place_active
;;
-b)
bottom && place_active
;;
-f)
wmctrl -r :ACTIVE: -b toggle,maximized_vert,maximized_horz
;;
-pt)
pos_top && place_active
;;
-pb)
pos_bottom && place_active
;;
-tl)
top_left && place_active
;;
-bl)
bottom_left && place_active
;;
-tr)
top_right && place_active
;;
-br)
bottom_right && place_active
;;
-lr)
left_right
;;
-tb)
top_bottom
;;
-lrr)
left_right_right
;;
-rll)
right_left_left
;;
-tbb)
top_bottom_bottom
;;
-btt)
bottom_top_top
;;
-tblr)
top_bottom_left_right
;;
-m)
minimize
;;
-u)
unminimize
;;
*)
exit 1
;;
esac
}
# Let it happen
win_fu $1
|
- win-fu (18.6 KiB)
- Download win-fu
|
Onli
Ehemalige
Anmeldungsdatum: 1. August 2005
Beiträge: 6941
|
Find ich durchaus interessant. Unter icewm scheint es im Grunde zu funktionieren, also zumindest das getestete -f und -l. Wobei ich irritiert war, xdotools nicht in den Quellen zu finden (hardy). Ist halt solange wahrscheinlich für die meisten uninteressant, solange es nicht an die entsprechenden Mausaktionen (z.B. Maximiertes Fenster herunterziehen, Fenster oben an den Rand ziehen) verknüpft ist.
|
mrkramps
(Themenstarter)
Anmeldungsdatum: 10. Oktober 2006
Beiträge: 5523
Wohnort: south central EL
|
Onli schrieb: Find ich durchaus interessant. Unter icewm scheint es im Grunde zu funktionieren, also zumindest das getestete -f und -l.
Entscheidend ist eigentlich nur, dass die jeweiligen Fenstermanager von wmctrl unterstützt werde. Das kann man auf der Entwicklerseite nachschauen. icewm gehört zum Beispiel dazu.
Wobei ich irritiert war, xdotools nicht in den Quellen zu finden (hardy).
Jau, bin ich jetzt gerade auch. Das Programm ist erst offiziell ab Karmic in den Universe-Quellen, für Hardy wäre es allerdings auch schon in den Backports vorhanden.
Ist halt solange wahrscheinlich für die meisten uninteressant, solange es nicht an die entsprechenden Mausaktionen (z.B. Maximiertes Fenster herunterziehen, Fenster oben an den Rand ziehen) verknüpft ist.
Das könnte man für einige Desktopumgebungen über Brightside (s.o.) für Arbeitsflächenkanten und -ecken lösen, oder z.B. mit Mausgesten über gestikk. Oder aber man bleibt einfach bei ganz konventionellen Tastenkürzeln. Aber Recht hast du schon. Aufgrund der Möglichkeiten, die Compiz oder Kwin4 bieten, ist dieses Script für die meisten Anwender ziemlich uninteressant. Dazu kommt noch der zusätzliche Aufwand, dass man die einzelnen Befehle für die Fenstersteuerung erst manuell für die Benutzeroberfläche einrichten muss. Da warten die Leute lieber auf Gnome3 oder Unity. Wurde vielleicht nicht ganz so deutlich, aber ich habe das Script primär für mich selber geschrieben - für Xfwm4 ohne Compiz. Und die Veröffentlichung soll, wenn überhaupt, jenen Anwendern zu Gute kommen, die selber mit ähnlichen Fenstermanagern ohne Compiz arbeiten. Ich habe mir sagen lassen, dass es davon vereinzelt tatsächlich noch welche geben soll. Danke, dass du dir einen Moment Zeit genommen hast das Script anzusehen und zu testen.
|
Linux_Und_Ich
Anmeldungsdatum: 4. September 2010
Beiträge: 46
|
Die Höhe der Panels könntest du auch so... gconftool-2 --dir-exists="/apps/panel/toplevels/top_panel_screen0"
if [ $? = "0" ] ; then
TOP_PANEL_SIZE=$(gconftool-2 -g /apps/panel/toplevels/bottom_panel_screen0/size)
fi
gconftool-2 --dir-exists="/apps/panel/toplevels/bottom_panel_screen0"
if [ $? = "0" ] ; then
BOTTOM_PANEL_SIZE=$(gconftool-2 -g /apps/panel/toplevels/bottom_panel_screen0/size)
fi automatisiert auslesen.
|
mrkramps
(Themenstarter)
Anmeldungsdatum: 10. Oktober 2006
Beiträge: 5523
Wohnort: south central EL
|
Linux Und Ich schrieb: Die Höhe der Panels könntest du auch so... gconftool-2 --dir-exists="/apps/panel/toplevels/top_panel_screen0"
if [ $? = "0" ] ; then
TOP_PANEL_SIZE=$(gconftool-2 -g /apps/panel/toplevels/bottom_panel_screen0/size)
fi
gconftool-2 --dir-exists="/apps/panel/toplevels/bottom_panel_screen0"
if [ $? = "0" ] ; then
BOTTOM_PANEL_SIZE=$(gconftool-2 -g /apps/panel/toplevels/bottom_panel_screen0/size)
fi automatisiert auslesen.
Vielen Dank für den Hinweis. Funktioniert allerdings nur sofern GConf verwendet wird, was - soweit mir bekannt - nur von der Gnome-Desktopumgebung so gehandhabt wird.
|
Linux_Und_Ich
Anmeldungsdatum: 4. September 2010
Beiträge: 46
|
Stimmt, du hast recht. Hab daran ja gar nicht gedacht, dass du das ja allgemein umsetzen willst.
|