sane-open: refactor
This commit is contained in:
@@ -83,6 +83,22 @@ configureKeyboardFor_uri() {
|
|||||||
log "configureKeyboardFor_uri: $1"
|
log "configureKeyboardFor_uri: $1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
configureKeyboard() {
|
||||||
|
local resourceType="$1"
|
||||||
|
shift
|
||||||
|
case $resourceType in
|
||||||
|
(application)
|
||||||
|
configureKeyboardFor_application "$@"
|
||||||
|
;;
|
||||||
|
(file)
|
||||||
|
configureKeyboardFor_file "$@"
|
||||||
|
;;
|
||||||
|
(uri)
|
||||||
|
configureKeyboardFor_uri "$@"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
open_application() {
|
open_application() {
|
||||||
log "open_application: '$1'"
|
log "open_application: '$1'"
|
||||||
gdbus call --session --timeout 10 \
|
gdbus call --session --timeout 10 \
|
||||||
@@ -123,6 +139,22 @@ open_uri() {
|
|||||||
"" "$1" "{'ask': <false>}"
|
"" "$1" "{'ask': <false>}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open() {
|
||||||
|
local resourceType="$1"
|
||||||
|
shift
|
||||||
|
case $resourceType in
|
||||||
|
(application)
|
||||||
|
open_application "$@"
|
||||||
|
;;
|
||||||
|
(file)
|
||||||
|
open_file "$@"
|
||||||
|
;;
|
||||||
|
(uri)
|
||||||
|
open_uri "$@"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
# evaluate truthy and print desktop name as `FOO.desktop` if the provided file is a .desktop file suitable for open_application.
|
# evaluate truthy and print desktop name as `FOO.desktop` if the provided file is a .desktop file suitable for open_application.
|
||||||
tryAsDesktopFile() {
|
tryAsDesktopFile() {
|
||||||
# open_application (i.e. the DynamicLauncher portal) only understands applications by their
|
# open_application (i.e. the DynamicLauncher portal) only understands applications by their
|
||||||
@@ -263,7 +295,7 @@ fi
|
|||||||
|
|
||||||
if [ -n "$autoKeyboard" ]; then
|
if [ -n "$autoKeyboard" ]; then
|
||||||
# do in parallel to avoid delaying app launch
|
# do in parallel to avoid delaying app launch
|
||||||
configureKeyboardFor_"$resourceType" "$resource" &
|
(configureKeyboard "$resourceType" "$resource") &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
open_"$resourceType" "$resource"
|
open "$resourceType" "$resource"
|
||||||
|
Reference in New Issue
Block a user