-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathflwm_wmconfig
executable file
·67 lines (60 loc) · 1.56 KB
/
flwm_wmconfig
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
#! /usr/bin/tcl
# flwm_wmconfig reads the RedHat "/etc/X11/wmconfig" directory (and
# the ~/.wmconfig directory) and builds a ~/.wmx directory from it so
# that you have a big complex menu in flwm!
set count 0
proc read_wmfile {fname} {
global count
global env
if [catch {set f [open $fname]} message] {
puts $message
} else {
set group ""
set name ""
set exec ""
while {[gets $f list]>=0} {
set n 0
catch {set n [llength $list]}
if $n<3 continue
set tag [lindex $list 1]
set value [lrange $list 2 1000]
if [llength $value]==1 {set value [lindex $value 0]}
if {$tag=="group"} {set group $value}
if {$tag=="name"} {set name $value}
if {$tag=="exec"} {set exec $value}
}
close $f
if {$group=="" || $name == "" || $exec == ""} {
puts "$fname is missing necessary data"
return
}
set dir $env(HOME)/.wmx/$group
set exec [string trimright $exec "& "]
catch {mkdir [list $dir]}
if [llength $exec]==1 {
if [catch {set command [exec which $exec]}] {
puts "$fname : can't find the program $exec"
return
} else {
catch {unlink [list $dir/$name]}
link -sym $command $dir/$name
}
} else {
set f [open $dir/$name "w"]
puts $f "#! /bin/sh"
puts $f "exec $exec"
close $f
chmod +x [list $dir/$name]
}
incr count
}
}
if ![catch {set l [glob /etc/X11/wmconfig/*]}] {
foreach f $l {read_wmfile $f}
}
if ![catch {set l [glob $env(HOME)/.wmconfig/*]}] {
foreach f $l {read_wmfile $f}
}
if !$count {
error "No files found in /etc/X11/wmconfig or ~/.wmconfig"
}