489
505
# }}} MIME utilities
508
# Reads the KDE configuration setting, compensating for a bug in some versions of kreadconfig.
514
application="`kreadconfig --file $configfile --group $configsection --key $configkey`"
515
if [ x"$application" != x ]; then
518
# kreadconfig in KDE 4 may not notice Key[$*]=... localized settings, so
519
# check by hand if it didn't find anything (oddly kwriteconfig works
521
configfile_dir=`kde${KDE_SESSION_VERSION}-config --path config | cut -d ':' -f 1`
522
configfile_path="$configfile_dir/$configfile"
523
[ ! -f "$configfile_path" ] && return
524
# This will only take the first value if there is more than one.
525
grep "^$configkey"'\[$[^]=]*\]=' "$configfile_path" | head -n 1 | cut -d= -f 2-
492
532
# Resolves the KDE browser setting to a binary: if prefixed with !, simply removes it;
523
# Reads the KDE browser setting, compensating for a bug in some versions of kreadconfig.
524
563
read_kde_browser()
526
browser="`kreadconfig --file kdeglobals --group General --key BrowserApplication`"
527
if [ x"$browser" != x ]; then
530
# kreadconfig in KDE 4 may not notice Key[$*]=... localized settings, so
531
# check by hand if it didn't find anything (oddly kwriteconfig works
533
kdeglobals_dir=`kde${KDE_SESSION_VERSION}-config --path config | cut -d ':' -f 1`
534
kdeglobals="$kdeglobals_dir/kdeglobals"
535
[ ! -f "$kdeglobals" ] && return
536
# This will only take the first value if there is more than one.
537
grep '^BrowserApplication\[$[^]=]*\]=' "$kdeglobals" | head -n 1 | cut -d= -f 2-
565
read_kde_config kdeglobals General BrowserApplication
541
568
get_browser_kde()
753
780
# }}} default browser
782
# {{{ default url scheme handler
784
exit_unimplemented_default_handler()
786
exit_failure_operation_impossible "default-url-scheme-handler not implemented for $DE"
791
# Recent versions of KDE support default scheme handler applications using the
792
# mime type of x-scheme-handler/scheme. Older versions will not support this
793
# but do have support for setting a default mail handler. There is also a
794
# system in KDE where .protocol files can be used, however this is not
795
# supported by this script. When reading a scheme handler we will use the
796
# default mail handler for the mailto scheme, otherwise we will use the mime
797
# type x-scheme-handler/scheme.
799
get_url_scheme_handler_kde()
801
if [ "$1" = "mailto" ]; then
802
handler="`read_kde_config emaildefaults PROFILE_Default EmailClient | first_word`"
803
echo "handler is $handler"
804
if [ x"$handler" != x ]; then
805
binary_to_desktop_file "$handler"
807
get_browser_mime "x-scheme-handler/$1"
810
get_browser_mime "x-scheme-handler/$1"
814
check_url_scheme_handler_kde()
816
check="`desktop_file_to_binary "$2"`"
817
if [ -z "$check" ]; then
821
if [ x"$1" = "mailto" ]; then
822
binary="`read_kde_config emaildefaults PROFILE_Default EmailClient`"
823
if [ x"$binary" != x"$check" ]; then
828
handler="`get_browser_mime x-scheme-handler/$1`"
829
binary="`desktop_file_to_binary "$handler"`"
830
if [ x"$binary" != x"$check" ]; then
838
set_url_scheme_handler_kde()
840
set_browser_mime "$2" "x-scheme-handler/$1" || return
841
if [ "$1" = "mailto" ]; then
842
binary="`desktop_file_to_binary "$2"`"
843
kwriteconfig --file emaildefaults --group PROFILE_Default --key EmailClient "$binary"
850
get_url_scheme_handler_gnome()
852
binary="`gconftool-2 --get /desktop/gnome/url-handlers/$1/command | first_word`"
853
if [ x"$binary" != x"" ]; then
854
# gconftool gives the binary (maybe with %s etc. afterward),
855
# but we want the desktop file name, not the binary. So, we
856
# have to find the desktop file to which it corresponds.
857
desktop="`binary_to_desktop_file "$binary"`"
862
check_url_scheme_handler_gnome()
864
check="`desktop_file_to_binary "$2"`"
865
if [ -z "$check" ]; then
869
binary="`gconftool-2 --get /desktop/gnome/url-handlers/$1/command | first_word`"
870
if [ x"$binary" != x"$check" ]; then
878
set_url_scheme_handler_gnome()
880
binary="`desktop_file_to_binary "$2"`"
881
[ "$binary" ] || exit_failure_file_missing
883
gconftool-2 --type string --set /desktop/gnome/url-handlers/$1/command "$binary %s"
884
gconftool-2 --type bool --set /desktop/gnome/url-handlers/$1/needs_terminal false
885
gconftool-2 --type bool --set /desktop/gnome/url-handlers/$1/enabled true
891
get_url_scheme_handler_gnome3()
893
get_browser_mime "x-scheme-handler/$1"
896
check_url_scheme_handler_gnome3()
899
check="`desktop_file_to_binary "$2"`"
900
if [ -z "$check" ]; then
904
browser="`get_browser_mime "x-scheme-handler/$1"`"
905
if [ x"$browser" != x"$desktop" ]; then
913
set_url_scheme_handler_gnome3()
915
binary="`desktop_file_to_binary "$2"`"
916
[ "$binary" ] || exit_failure_file_missing
917
set_browser_mime "$2" || return
919
# Set the default browser.
920
set_browser_mime "$2" "x-scheme-handler/$1" || return
926
get_url_scheme_handler_xfce()
928
exit_unimplemented_default_handler "$1"
931
check_url_scheme_handler_xfce()
933
exit_unimplemented_default_handler "$1"
936
set_url_scheme_handler_xfce()
938
exit_unimplemented_default_handler "$1"
942
# }}} default protocol handler
755
944
dispatch_specific()
757
946
# The PROP comments in this function are used to generate the output of