| OLD | NEW |
| 1 #!/bin/sh | 1 #!/bin/sh |
| 2 #--------------------------------------------- | 2 #--------------------------------------------- |
| 3 # xdg-icon-resource | 3 # xdg-icon-resource |
| 4 # | 4 # |
| 5 # Utility script to install icons on a Linux desktop. | 5 # Utility script to install icons on a Linux desktop. |
| 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, Kevin Krammer <kevin.krammer@gmx.at> | 9 # Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at> |
| 10 # Copyright 2006, Jeremy White <jwhite@codeweavers.com> | 10 # Copyright 2006, Jeremy White <jwhite@codeweavers.com> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 } | 26 } |
| 27 | 27 |
| 28 #@xdg-utils-common@ | 28 #@xdg-utils-common@ |
| 29 | 29 |
| 30 # Set GTK_UPDATE_ICON_CACHE to gtk-update-icon-cache executable path or | 30 # Set GTK_UPDATE_ICON_CACHE to gtk-update-icon-cache executable path or |
| 31 # to "-" if not found. | 31 # to "-" if not found. |
| 32 GTK_UPDATE_ICON_CACHE= | 32 GTK_UPDATE_ICON_CACHE= |
| 33 find_gtk_update_icon_cache() | 33 find_gtk_update_icon_cache() |
| 34 { | 34 { |
| 35 [ -n "$GTK_UPDATE_ICON_CACHE" ] && return; | 35 [ -n "$GTK_UPDATE_ICON_CACHE" ] && return; |
| 36 | 36 |
| 37 GTK_UPDATE_ICON_CACHE="-" | 37 GTK_UPDATE_ICON_CACHE="-" |
| 38 for x in `echo "$PATH:/opt/gnome/bin" | sed 's/:/ /g'`; do | 38 for x in `echo "$PATH:/opt/gnome/bin" | sed 's/:/ /g'`; do |
| 39 DEBUG 3 "Checking $x for gtk-update-icon-cache" | 39 DEBUG 3 "Checking $x for gtk-update-icon-cache" |
| 40 if [ -x "$x/gtk-update-icon-cache" ] ; then | 40 if [ -x "$x/gtk-update-icon-cache" ] ; then |
| 41 DEBUG 1 "Found $x/gtk-update-icon-cache" | 41 DEBUG 1 "Found $x/gtk-update-icon-cache" |
| 42 GTK_UPDATE_ICON_CACHE="$x/gtk-update-icon-cache" | 42 GTK_UPDATE_ICON_CACHE="$x/gtk-update-icon-cache" |
| 43 return | 43 return |
| 44 fi | 44 fi |
| 45 done | 45 done |
| 46 } | 46 } |
| 47 | 47 |
| 48 # Start GNOME legacy workaround section | 48 # Start GNOME legacy workaround section |
| 49 need_dot_icon_path() | 49 need_dot_icon_path() |
| 50 { | 50 { |
| 51 # GTK < 2.6 uses ~/.icons but not XDG_DATA_HOME/icons | 51 # GTK < 2.6 uses ~/.icons but not XDG_DATA_HOME/icons |
| 52 # The availability of gtk-update-icon-cache is used as indication | 52 # The availability of gtk-update-icon-cache is used as indication |
| 53 # of whether the system is using GTK 2.6 or later | 53 # of whether the system is using GTK 2.6 or later |
| 54 find_gtk_update_icon_cache | 54 find_gtk_update_icon_cache |
| 55 [ "$GTK_UPDATE_ICON_CACHE" != "-" ] && return 1; | 55 [ "$GTK_UPDATE_ICON_CACHE" != "-" ] && return 1; |
| 56 return 0; | 56 return 0; |
| 57 } | 57 } |
| 58 | 58 |
| 59 update_icon_database() | 59 update_icon_database() |
| 60 { | 60 { |
| 61 # Touch me, I'm dirty | 61 # Touch me, I'm dirty |
| 62 touch "$1/.@NAME@-dummy" | 62 touch "$1/.@NAME@-dummy" |
| 63 rm -f "$1/.@NAME@-dummy" | 63 rm -f "$1/.@NAME@-dummy" |
| 64 | 64 |
| 65 # Don't create a cache if there wan't one already | 65 # Don't create a cache if there wan't one already |
| 66 if [ -f "$1/icon-theme.cache" ] ; then | 66 if [ -f "$1/icon-theme.cache" ] ; then |
| 67 find_gtk_update_icon_cache | 67 find_gtk_update_icon_cache |
| 68 if [ "$GTK_UPDATE_ICON_CACHE" != "-" ] ; then | 68 if [ "$GTK_UPDATE_ICON_CACHE" != "-" ] ; then |
| 69 DEBUG 1 "Running $GTK_UPDATE_ICON_CACHE -f -t \"$1\"" | 69 DEBUG 1 "Running $GTK_UPDATE_ICON_CACHE -f -t \"$1\"" |
| 70 eval '$GTK_UPDATE_ICON_CACHE -f -t "$1"'$xdg_redirect_output | 70 eval '$GTK_UPDATE_ICON_CACHE -f -t "$1"'$xdg_redirect_output |
| 71 return | 71 return |
| 72 fi | 72 fi |
| 73 fi | 73 fi |
| 74 } | 74 } |
| 75 | 75 |
| 76 [ x"$1" != x"" ] || exit_failure_syntax | 76 [ x"$1" != x"" ] || exit_failure_syntax |
| 77 | 77 |
| 78 mode= | 78 mode= |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 exit_failure_syntax "mode argument missing for --mode" | 119 exit_failure_syntax "mode argument missing for --mode" |
| 120 fi | 120 fi |
| 121 case "$1" in | 121 case "$1" in |
| 122 user) | 122 user) |
| 123 mode="user" | 123 mode="user" |
| 124 ;; | 124 ;; |
| 125 | 125 |
| 126 system) | 126 system) |
| 127 mode="system" | 127 mode="system" |
| 128 ;; | 128 ;; |
| 129 | 129 |
| 130 *) | 130 *) |
| 131 exit_failure_syntax "unknown mode '$1'" | 131 exit_failure_syntax "unknown mode '$1'" |
| 132 ;; | 132 ;; |
| 133 esac | 133 esac |
| 134 shift | 134 shift |
| 135 ;; | 135 ;; |
| 136 | 136 |
| 137 --theme) | 137 --theme) |
| 138 if [ -z "$1" ] ; then | 138 if [ -z "$1" ] ; then |
| 139 exit_failure_syntax "theme argument missing for --theme" | 139 exit_failure_syntax "theme argument missing for --theme" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 [ $needed -eq "1" ] && DEBUG 2 "need_kde_icon_path RETURN $needed (not needed)
" | 337 [ $needed -eq "1" ] && DEBUG 2 "need_kde_icon_path RETURN $needed (not needed)
" |
| 338 [ $needed -eq "0" ] && DEBUG 2 "need_kde_icon_path RETURN $needed (needed)" | 338 [ $needed -eq "0" ] && DEBUG 2 "need_kde_icon_path RETURN $needed (needed)" |
| 339 return $needed | 339 return $needed |
| 340 } | 340 } |
| 341 | 341 |
| 342 kde_dir= | 342 kde_dir= |
| 343 if [ x"$mode" = x"user" ] ; then | 343 if [ x"$mode" = x"user" ] ; then |
| 344 xdg_dir="$xdg_base_dir/$xdg_size_name/$context" | 344 xdg_dir="$xdg_base_dir/$xdg_size_name/$context" |
| 345 #KDE 3.x doesn't support XDG_DATA_HOME for icons | 345 #KDE 3.x doesn't support XDG_DATA_HOME for icons |
| 346 #Check if xdg_dir prefix is listed by kde-config --path icon | 346 #Check if xdg_dir prefix is listed by kde-config --path icon |
| 347 #If not, install additional symlink to kdedir | 347 #If not, install additional symlink to kdedir |
| 348 if need_kde_icon_path "$xdg_user_prefix" ; then | 348 if need_kde_icon_path "$xdg_user_prefix" ; then |
| 349 kde_user_dir="$HOME/.kde/share/icons/$theme" | 349 kde_user_icon_dir=`kde${KDE_SESSION_VERSION}-config --path icon | cut -d
':' -f 1` |
| 350 kde_user_dir="$kde_user_icon_dir/$theme" |
| 350 kde_dir="$kde_user_dir/$xdg_size_name/$context" | 351 kde_dir="$kde_user_dir/$xdg_size_name/$context" |
| 351 fi | 352 fi |
| 352 #Gnome 2.8 supports ~/.icons but not XDG_DATA_HOME | 353 #Gnome 2.8 supports ~/.icons but not XDG_DATA_HOME |
| 353 if [ -n "$dot_icon_dir" ] ; then | 354 if [ -n "$dot_icon_dir" ] ; then |
| 354 if [ -L "$dot_icon_dir" ] ; then | 355 if [ -L "$dot_icon_dir" ] ; then |
| 355 # Don't do anything | 356 # Don't do anything |
| 356 dot_icon_dir= | 357 dot_icon_dir= |
| 357 elif [ ! -d "$dot_icon_dir/" ] ; then | 358 elif [ ! -d "$dot_icon_dir/" ] ; then |
| 358 # Symlink if it doesn't exist | 359 # Symlink if it doesn't exist |
| 359 eval 'ln -s ".local/share/icons" "$dot_icon_dir"'$xdg_redirect_outpu
t | 360 eval 'ln -s ".local/share/icons" "$dot_icon_dir"'$xdg_redirect_outpu
t |
| 360 dot_icon_dir= | 361 dot_icon_dir= |
| 361 else | 362 else |
| 362 dot_icon_dir="$dot_icon_dir/$theme/$xdg_size_name/$context" | 363 dot_icon_dir="$dot_icon_dir/$theme/$xdg_size_name/$context" |
| 363 fi | 364 fi |
| 364 fi | 365 fi |
| 365 my_umask=077 | 366 my_umask=077 |
| 366 else | 367 else |
| 367 xdg_dir="$xdg_base_dir/$xdg_size_name/$context" | 368 xdg_dir="$xdg_base_dir/$xdg_size_name/$context" |
| 368 #KDE 3.x doesn't support XDG_DATA_DIRS for icons | 369 #KDE 3.x doesn't support XDG_DATA_DIRS for icons |
| 369 #Check if xdg_dir prefix is listed by kde-config --path icon | 370 #Check if xdg_dir prefix is listed by kde-config --path icon |
| 370 #If not, install additional symlink to kdedir | 371 #If not, install additional symlink to kdedir |
| 371 if need_kde_icon_path "$xdg_global_prefix" ; then | 372 if need_kde_icon_path "$xdg_global_prefix" ; then |
| 372 kde_global_dir="$kde_global_prefix/$theme" | 373 kde_global_dir="$kde_global_prefix/$theme" |
| 373 kde_dir="$kde_global_dir/$xdg_size_name/$context" | 374 kde_dir="$kde_global_dir/$xdg_size_name/$context" |
| 374 fi | 375 fi |
| 375 my_umask=022 | 376 my_umask=022 |
| 376 fi | 377 fi |
| 377 # End KDE legacy workaround section | 378 # End KDE legacy workaround section |
| 378 | 379 |
| 379 # Start GNOME legacy workaround section | 380 # Start GNOME legacy workaround section |
| 380 need_gnome_mime= | 381 need_gnome_mime= |
| 381 [ $context = "mimetypes" ] && need_gnome_mime=true | 382 [ $context = "mimetypes" ] && need_gnome_mime=true |
| 382 # End GNOME legacy workaround section | 383 # End GNOME legacy workaround section |
| 383 | 384 |
| 384 [ -n "$icon_name" ] || icon_name=`basename "$icon_file" | sed 's/\.[a-z][a-z][a-
z]$//'` | 385 [ -n "$icon_name" ] || icon_name=`basename "$icon_file" | sed 's/\.[a-z][a-z][a-
z]$//'` |
| 385 | 386 |
| 386 if [ "$vendor" = "true" -a "$action" = "install" -a "$context" = "apps" ] ; then | 387 if [ "$vendor" = "true" -a "$action" = "install" -a "$context" = "apps" ] ; then |
| 387 check_vendor_prefix "$icon_name" "icon name" | 388 check_vendor_prefix "$icon_name" "icon name" |
| 388 fi | 389 fi |
| 389 | 390 |
| 390 icon_icon_file=`echo "$icon_file" | sed 's/\.[a-z][a-z][a-z]$/.icon/'` | 391 icon_icon_file=`echo "$icon_file" | sed 's/\.[a-z][a-z][a-z]$/.icon/'` |
| 391 icon_icon_name="$icon_name.icon" | 392 icon_icon_name="$icon_name.icon" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 417 fi | 418 fi |
| 418 | 419 |
| 419 umask $save_umask | 420 umask $save_umask |
| 420 ;; | 421 ;; |
| 421 | 422 |
| 422 uninstall) | 423 uninstall) |
| 423 for icon_dir in $xdg_dir $dot_icon_dir; do | 424 for icon_dir in $xdg_dir $dot_icon_dir; do |
| 424 rm -f "$icon_dir/$icon_name.xpm" "$icon_dir/$icon_name.png" | 425 rm -f "$icon_dir/$icon_name.xpm" "$icon_dir/$icon_name.png" |
| 425 rm -f "$icon_dir/$icon_icon_name" | 426 rm -f "$icon_dir/$icon_icon_name" |
| 426 if [ -n "$need_gnome_mime" ] ; then | 427 if [ -n "$need_gnome_mime" ] ; then |
| 427 rm -f "$icon_dir/gnome-mime-$icon_name.xpm" | 428 rm -f "$icon_dir/gnome-mime-$icon_name.xpm" |
| 428 rm -f "$icon_dir/gnome-mime-$icon_name.png" | 429 rm -f "$icon_dir/gnome-mime-$icon_name.png" |
| 429 fi | 430 fi |
| 430 done | 431 done |
| 431 if [ -n "$kde_dir" ] ; then | 432 if [ -n "$kde_dir" ] ; then |
| 432 rm -f "$kde_dir/$icon_name.xpm" "$kde_dir/$icon_name.png" | 433 rm -f "$kde_dir/$icon_name.xpm" "$kde_dir/$icon_name.png" |
| 433 fi | 434 fi |
| 434 | 435 |
| 435 ;; | 436 ;; |
| 436 esac | 437 esac |
| 437 | 438 |
| 438 if [ x"$update" = x"yes" ] ; then | 439 if [ x"$update" = x"yes" ] ; then |
| 439 update_icon_database "$xdg_base_dir" | 440 update_icon_database "$xdg_base_dir" |
| 440 if [ -n "$dot_icon_dir" ] ; then | 441 if [ -n "$dot_icon_dir" ] ; then |
| 441 if [ -d "$dot_icon_dir/" -a ! -L "$dot_icon_dir" ] ; then | 442 if [ -d "$dot_icon_dir/" -a ! -L "$dot_icon_dir" ] ; then |
| 442 update_icon_database $dot_base_dir | 443 update_icon_database $dot_base_dir |
| 443 fi | 444 fi |
| 444 fi | 445 fi |
| 445 fi | 446 fi |
| 446 | 447 |
| 447 exit_success | 448 exit_success |
| OLD | NEW |