The shortcuts wrote the Plasma 5 value format and so never bound anything, which is what produced "No default shortcuts" in System Settings. kglobalacceld's KServiceActionComponent::loadSettings reads the services _launch key as a bare key sequence and hands it straight to QKeySequence::fromString. Plasma 5 stored a "keys,default,name" triplet there and Plasma 6 does not, so "Meta+Alt+T,none,Insta360: Toggle AI tracking" parsed to an empty sequence and bound no key. The value is now just the key sequence; alternates would be tab-separated and "none" means unbound. Two supporting changes. The desktop entries now carry X-KDE-Shortcuts, which is where kglobalacceld reads an entry's default shortcut from, so the binding shows up in System Settings as a default instead of as nothing. And they are no longer NoDisplay by default: KApplicationTrader skips NoDisplay services, so hiding them from the launcher also hid them from the Shortcuts page, which is the opposite of helpful. HIDE_FROM_MENU=1 restores the old behaviour. --list is now a diagnostic rather than a bare dump: it reports the registered key, the default from the desktop entry, whether the entry file exists, and flags any comma-bearing value as the unparseable Plasma 5 form. It would have identified this fault directly. The new plasmoid is a Plasma 6 applet: a velocity-style virtual joystick plus zoom slider and Home/Center/Tracking buttons. It drives the gimbal with relative moves, not absolute ones, because linkctl status reports no pan or tilt while the camera is idle, leaving no trustworthy position to aim from; relative steps work in either state and cannot drift, and linkctl clamps them to the device range. The pure logic lives in a .js library so it is testable outside Plasma. Tested: 36 new node checks over shell quoting, tick command construction, inversion, the per-axis threshold and the multi-object JSON merge, each confirmed meaningful by mutation. Reproduced the broken shortcut state in a throwaway HOME and verified --list flags it and reinstalling repairs it. All QML passes qmllint with no syntax errors (KDE modules are unresolvable offline). shellcheck clean. The applet has not been loaded in a real Plasma session.
87 lines
2.6 KiB
Bash
Executable File
87 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# install.sh - install the Insta360 Link Joystick applet into Plasma.
|
|
#
|
|
# Usage:
|
|
# ./install.sh install, or upgrade if already present
|
|
# ./install.sh --uninstall remove it
|
|
# ./install.sh --restart also restart plasmashell (needed to pick up
|
|
# changes to an already-running applet)
|
|
#
|
|
# After installing: right-click the desktop or panel, Add Widgets, and search
|
|
# for "Insta360".
|
|
|
|
set -euo pipefail
|
|
|
|
readonly APPLET_ID="com.github.insta360linktools.joystick"
|
|
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
|
|
readonly SCRIPT_DIR
|
|
readonly PKG="$SCRIPT_DIR/package"
|
|
|
|
RESTART=0
|
|
MODE=install
|
|
|
|
die() { printf 'error: %s\n' "$*" >&2; exit 1; }
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
--uninstall) MODE=uninstall; shift ;;
|
|
--restart) RESTART=1; shift ;;
|
|
-h|--help)
|
|
awk 'NR>1 { if (!/^#/) exit; sub(/^# ?/, ""); print }' \
|
|
"${BASH_SOURCE[0]}"
|
|
exit 0 ;;
|
|
*) die "unknown option: $1" ;;
|
|
esac
|
|
done
|
|
|
|
if command -v kpackagetool6 >/dev/null 2>&1; then
|
|
KPT=kpackagetool6
|
|
elif command -v kpackagetool5 >/dev/null 2>&1; then
|
|
KPT=kpackagetool5
|
|
else
|
|
die "neither kpackagetool6 nor kpackagetool5 found; is this a KDE Plasma session?"
|
|
fi
|
|
|
|
restart_shell() {
|
|
(( RESTART )) || return 0
|
|
echo "Restarting plasmashell:"
|
|
if systemctl --user restart plasma-plasmashell.service 2>/dev/null; then
|
|
echo " restarted via systemd"
|
|
elif command -v kquitapp6 >/dev/null 2>&1; then
|
|
kquitapp6 plasmashell 2>/dev/null || true
|
|
sleep 2
|
|
(setsid plasmashell >/dev/null 2>&1 &)
|
|
echo " restarted"
|
|
else
|
|
echo " could not restart; log out and back in to pick up changes"
|
|
fi
|
|
}
|
|
|
|
case $MODE in
|
|
install)
|
|
[[ -f $PKG/metadata.json ]] || die "no package found at $PKG"
|
|
# Fail early on malformed metadata rather than leaving a half-installed
|
|
# applet that Plasma silently refuses to load.
|
|
python3 -c "import json,sys; json.load(open('$PKG/metadata.json'))" \
|
|
2>/dev/null || die "metadata.json is not valid JSON"
|
|
|
|
if "$KPT" --type Plasma/Applet --list 2>/dev/null | grep -qx "$APPLET_ID"; then
|
|
echo "Already installed; upgrading:"
|
|
"$KPT" --type Plasma/Applet --upgrade "$PKG"
|
|
else
|
|
echo "Installing:"
|
|
"$KPT" --type Plasma/Applet --install "$PKG"
|
|
fi
|
|
restart_shell
|
|
echo
|
|
echo "Done. Right-click a panel or the desktop, Add Widgets, search 'Insta360'."
|
|
;;
|
|
uninstall)
|
|
echo "Removing:"
|
|
"$KPT" --type Plasma/Applet --remove "$APPLET_ID"
|
|
restart_shell
|
|
echo "Done."
|
|
;;
|
|
esac
|