Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: scripts/xdg-screensaver

Issue 6928018: Linux: update xdg-utils to the latest git version and include a one-line fix in xdg-mime. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/xdg-utils/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « scripts/xdg-open ('k') | scripts/xdg-settings » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/sh 1 #!/bin/sh
2 #--------------------------------------------- 2 #---------------------------------------------
3 # xdg-screensaver 3 # xdg-screensaver
4 # 4 #
5 # Utility script to control screensaver. 5 # Utility script to control screensaver.
6 # 6 #
7 # Refer to the usage() function below for usage. 7 # Refer to the usage() function below for usage.
8 # 8 #
9 # Copyright 2006, Bryce Harrington <bryce@osdl.org> 9 # Copyright 2006, Bryce Harrington <bryce@osdl.org>
10 # 10 #
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 #---------------------------------------------------------------------------- 142 #----------------------------------------------------------------------------
143 143
144 DEBUG() 144 DEBUG()
145 { 145 {
146 [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0; 146 [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
147 [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0; 147 [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
148 shift 148 shift
149 echo "$@" >&2 149 echo "$@" >&2
150 } 150 }
151 151
152 # This handles backslashes but not quote marks.
153 first_word()
154 {
155 read first rest
156 echo "$first"
157 }
158
159 #-------------------------------------------------------------
160 # map a binary to a .desktop file
161 binary_to_desktop_file()
162 {
163 search="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/sha re:/usr/share}"
164 binary="`which "$1"`"
165 binary="`readlink -f "$binary"`"
166 base="`basename "$binary"`"
167 IFS=:
168 for dir in $search; do
169 unset IFS
170 [ "$dir" ] || continue
171 [ -d "$dir/applications" -o -d "$dir/applnk" ] || continue
172 for file in "$dir"/applications/*.desktop "$dir"/applications/*/*.deskto p "$dir"/applnk/*.desktop "$dir"/applnk/*/*.desktop; do
173 [ -r "$file" ] || continue
174 # Check to make sure it's worth the processing.
175 grep -q "^Exec.*$base" "$file" || continue
176 # Make sure it's a visible desktop file (e.g. not "preferred-web-bro wser.desktop").
177 grep -Eq "^(NoDisplay|Hidden)=true" "$file" && continue
178 command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | fir st_word`"
179 command="`which "$command"`"
180 if [ x"`readlink -f "$command"`" = x"$binary" ]; then
181 # Fix any double slashes that got added path composition
182 echo "$file" | sed -e 's,//*,/,g'
183 return
184 fi
185 done
186 done
187 }
188
189 #-------------------------------------------------------------
190 # map a .desktop file to a binary
191 ## FIXME: handle vendor dir case
192 desktop_file_to_binary()
193 {
194 search="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/sha re:/usr/share}"
195 desktop="`basename "$1"`"
196 IFS=:
197 for dir in $search; do
198 unset IFS
199 [ "$dir" -a -d "$dir/applications" ] || continue
200 file="$dir/applications/$desktop"
201 [ -r "$file" ] || continue
202 # Remove any arguments (%F, %f, %U, %u, etc.).
203 command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | first_w ord`"
204 command="`which "$command"`"
205 readlink -f "$command"
206 return
207 done
208 }
209
152 #------------------------------------------------------------- 210 #-------------------------------------------------------------
153 # Exit script on successfully completing the desired operation 211 # Exit script on successfully completing the desired operation
154 212
155 exit_success() 213 exit_success()
156 { 214 {
157 if [ $# -gt 0 ]; then 215 if [ $# -gt 0 ]; then
158 echo "$@" 216 echo "$@"
159 echo 217 echo
160 fi 218 fi
161 219
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 if [ "$action" = "suspend" ] ; then 1039 if [ "$action" = "suspend" ] ; then
982 # Start tracking $window_id and resume the screensaver once it disappears 1040 # Start tracking $window_id and resume the screensaver once it disappears
983 ( track_window ) 2> /dev/null > /dev/null & 1041 ( track_window ) 2> /dev/null > /dev/null &
984 fi 1042 fi
985 1043
986 if [ $result -eq 0 ]; then 1044 if [ $result -eq 0 ]; then
987 exit_success 1045 exit_success
988 else 1046 else
989 exit_failure_operation_failed 1047 exit_failure_operation_failed
990 fi 1048 fi
OLDNEW
« no previous file with comments | « scripts/xdg-open ('k') | scripts/xdg-settings » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698