source: src-sh/de-info/de-info @ 3f6d079

releng/10.0.1releng/10.0.2releng/10.0.3
Last change on this file since 3f6d079 was 3f6d079, checked in by yurkis <yurkis@…>, 7 months ago

Added optional 'configuration application' to de-info, de profiles and libpcbsd de-info backand

  • Property mode set to 100755
File size: 3.9 KB
Line 
1#!/bin/sh
2
3PROFILES_PREFIX="/usr/local/share/pcbsd/de-profiles"
4
5SHOW_INSTALLED=0
6SHOW_ALL=0
7SHOW_ONLY_ACTIVE=1
8SHOW_TERMINAL=0
9SHOW_FILEMAN=0
10
11DEFAULT_TERMINAL="xterm"
12DEFAULT_SUDO="pc-su %s"
13DEFAULT_TERMINAL_COMMAND="-e"
14DEFAULT_TERMINAL_TITLE="-T"
15DEFAULT_TERMINAL_SEPARATE_ARGS="NO"
16display_help()
17{
18  echo "de-info - display desktop environment info script"
19  echo "usage: de-info [-i] [-a] [-terminal] [-fileman]"
20  echo " Without any params script displays current active desktop environment info"
21  echo " -i - display installed desktop environments list"
22  echo " -a - display all supported desktop environments list"
23  echo " -terminal - display terminal application call related to current environment"
24  echo " -fileman - display file manager related to current desktop environment"
25  exit 0
26}
27
28display_de_info()
29{
30    echo
31    echo "DE name: $DE_NAME"
32    if [ $DE_ACTIVE -eq 1 ] ; then
33      echo "Current DE: YES"
34      DE_INSTALLED=1
35    else
36      echo "Current DE: NO"
37    fi
38    if [ $DE_INSTALLED -eq 1 ] ; then
39      echo "Installed: YES"
40    else
41      echo "Installed: NO"
42    fi
43    if [ "$XDG" = "1" ] ; then
44      XDG="YES"
45    fi
46      echo "XDG compatible: $XDG"
47     
48      if [ -n "$DE_CONFIG_APP" ] ; then
49      echo "Configuration app: $DE_CONFIG_APP"
50      fi
51      echo "Sudo command: $DE_SU" 
52      echo "File manager: $DE_FILEMAN"
53      echo "Terminal: $DE_TERMINAL"
54      echo "Terminal title switch: $DE_TERMINAL_TITLE"
55      echo "Terminal command switch: $DE_TERMINAL_COMMAND"
56      echo "Terminal command separate args: $DE_TERMINAL_SEPARATE_ARGS"
57}
58
59check_instaled()
60{
61  if [ -n "$DE_METAPACKAGE" ]
62  then
63    pc-metapkgmanager status $DE_METAPACKAGE | grep "is installed" >/dev/null
64    if [ $? -eq 0 ] ; then
65      DE_INSTALLED=1
66    fi
67  fi
68  if [ -n "$DE_INSTALL_FILE"  ]
69  then
70    for I_FILE in $DE_INSTALL_FILE
71    do
72      which $I_FILE >/dev/null 2>/dev/null
73      if [ $? -eq 0 ] ; then
74        DE_INSTALLED=1
75      fi
76    done
77  fi
78 
79  if [ -n "$DE_METAPACKAGE" ] && [ -n "$DE_INSTALL_FILE" ]
80  then     
81    installed
82  fi
83}
84
85check_active()
86{
87  if [ -n "$DE_SESSION_NAME" ]
88  then
89    if [ "$DE_SESSION_NAME" == "$PCDM_SESSION" ] ; then
90      DE_ACTIVE=1
91  fi
92  else
93    active 
94  fi
95}
96
97parse_all()
98{
99  for PROF in `ls $PROFILES_PREFIX/*.profile`
100  do
101  DE_NAME=""
102  XDG=""
103  DE_CONFIG_APP=""
104  DE_METAPACKAGE=""
105  DE_INSTALL_FILE=""
106  DE_SESSION_NAME=""
107  DE_SU=$DEFAULT_SUDO
108  DE_FILEMAN=""
109  DE_TERMINAL=$DEFAULT_TERMINAL
110  DE_TERMINAL_TITLE=$DEFAULT_TERMINAL_TITLE
111  DE_TERMINAL_COMMAND=$DEFAULT_TERMINAL_COMMAND
112  DE_TERMINAL_SEPARATE_ARGS=$DEFAULT_TERMINAL_SEPARATE_ARGS
113  DE_INSTALLED=0
114  DE_ACTIVE=0
115
116  . $PROF 
117
118  check_instaled
119  check_active
120 
121  if  [ $DE_ACTIVE -eq 1 ] ||  ( [ $DE_INSTALLED -eq 1 ] && [ $SHOW_INSTALLED -eq 1 ] ) || [ $SHOW_ALL -eq 1 ]
122  then
123    display_de_info
124  fi
125
126  done
127
128}
129
130parse_current()
131{
132
133for PROF in `ls $PROFILES_PREFIX/*.profile`
134  do
135  DE_NAME=""
136  XDG=""
137  DE_CONFIG_APP=""
138  DE_METAPACKAGE=""
139  DE_INSTALL_FILE=""
140  DE_SESSION_NAME=""
141  DE_TERMINAL=$DEFAULT_TERMINAL
142  DE_FILEMAN=""
143  DE_TERMINAL=$DEFAULT_TERMINAL
144  DE_TERMINAL_TITLE=$DEFAULT_TERMINAL_TITLE
145  DE_TERMINAL_COMMAND=$DEFAULT_TERMINAL_COMMAND
146  DE_TERMINAL_SEPARATE_ARGS=$DEFAULT_TERMINAL_SEPARATE_ARGS
147
148  DE_INSTALLED=0
149  DE_ACTIVE=0
150
151  . $PROF
152
153  check_active
154
155  if [ $DE_ACTIVE -eq 1 ] ; then
156    if [ $SHOW_TERMINAL -eq 1 ] ; then
157      echo "$DE_TERMINAL $DE_TERMINAL_COMMAND %s"
158    else
159      if [ $SHOW_FILEMAN -eq 1 ] ; then
160        echo $DE_FILEMAN
161      else
162        display_de_info
163      fi
164    fi
165  fi
166
167  done
168
169}
170
171
172
173if [ "$1" = "-help" ] || [ "$1" = "--help" ] || [ "$1" = "-?" ] 
174then
175display_help
176fi
177
178if [ "$1" = "-i" ] ; then
179SHOW_INSTALLED=1
180SHOW_ONLY_ACTIVE=0
181fi
182
183if [ "$1" = "-a" ] ; then
184SHOW_ALL=1
185SHOW_ONLY_ACTIVE=0
186fi
187
188if [ "$1" = "-terminal" ] ; then
189SHOW_TERMINAL=1
190fi
191
192if [ "$1" = "-fileman" ] ; then
193SHOW_FILEMAN=1
194fi
195
196
197if [ $SHOW_ONLY_ACTIVE -eq 1 ] ; then
198parse_current
199else
200parse_all
201fi
202
203
Note: See TracBrowser for help on using the repository browser.