File: create_menu.sh

package info (click to toggle)
windowlab 1.40-3
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, stretch, trixie
  • size: 392 kB
  • ctags: 487
  • sloc: ansic: 4,359; makefile: 114; sh: 58
file content (88 lines) | stat: -rwxr-xr-x 2,475 bytes parent folder | download | duplicates (6)
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
#!/bin/bash
#
# /usr/lib/windowlab/create_menu.sh
# WindowLab automatic menu generation script.
# This file is invoked by /etc/menu-methods/windowlab.
#
# Copyright (C) 2005 Stan Vasilyev <stan.vasilyev@csun.edu>
#
# 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 2 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.

# get prefix from command line parameters
prefix=$1
if [ -z "$prefix" ]; then exit 1; fi

# define constants used in this script
global_prefix="/etc/X11/windowlab"
user_menu_file="$prefix/user_menu"
common_menu_file="$global_prefix/common_menu"
debian_config_file="debian_config"
all_menu_file="menudefs.hook"
menufile="$prefix/windowlab.menurc"

# define variables used in windowlab.debianrc file
preferred_browsers=
preferred_email=
preferred_editors=
preferred_graphics=
preferred_terminals=

# include the debian config file, if exists
# if ran as a regular user, includes both global and user configs
for file in "$global_prefix/$debian_config_file" "$prefix/$debian_config_file"
do
	if [ -f "$file" ]
	then
		source "$file"
	fi
done

# backup the menu file
cp -f "$menufile" "$menufile.old"

echo "# This menu file is automatically generated by update-menus, do not edit." > $menufile
echo >> $menufile

# output the Debian menu into Windowlab menu
echo "# Debian Menu:" >> $menufile
for app_list in "$preferred_browsers" "$preferred_email" "$preferred_editors" "$preferred_graphics" "$preferred_terminals"
do
	for app in $app_list
	do
		echo -n "Looking for $app..."
		menu_entry=`grep -m 1 "$app" "$all_menu_file"`
		if [ -n "$menu_entry" ]
		then
			echo "found"
			echo "$menu_entry" >> "$menufile"
			break
		else
			echo "not found"
		fi
	done
done

# output the user menu into Windowlab menu
if [ -f "$user_menu_file" ]
then
	echo >> $menufile
	echo "# User Menu:" >> $menufile
	grep -v "#" "$user_menu_file" | grep ":" >> $menufile
fi

# output the common menu into Windowlab menu
if [ -f "$common_menu_file" ]
then
	echo >> $menufile
	echo "# Common Menu:" >> $menufile
	grep -v "#" "$common_menu_file" | grep ":" >> $menufile
fi

rm -f "$all_menu_file"