File: flwm_wmconfig

package info (click to toggle)
flwm 1.02+git2015.10.03+7dbb30-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 444 kB
  • ctags: 500
  • sloc: cpp: 4,958; makefile: 183; sh: 179; tcl: 56
file content (67 lines) | stat: -rwxr-xr-x 1,593 bytes parent folder | download | duplicates (7)
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
#! /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"
}