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