From 4a82a5f38056237923caa0d58808cbc9df2db9a2 Mon Sep 17 00:00:00 2001 From: Benjamin Lupton Date: Mon, 18 Mar 2024 05:03:37 +0800 Subject: [PATCH] support vscode on Raspberry Pi OS Signed-off-by: Benjamin Lupton --- commands/dorothy | 2 +- commands/edit | 7 +++++++ commands/is-kde | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100755 commands/is-kde diff --git a/commands/dorothy b/commands/dorothy index d5067a7b2..eb94ffac1 100755 --- a/commands/dorothy +++ b/commands/dorothy @@ -1622,7 +1622,7 @@ function dorothy_() ( # ensure_minimal_dependencies <-- if they are editing, then we assume they are already setup ensure_permissions_configured if test "$(edit --dry --only-editor)" == 'code'; then - code -- "$DOROTHY/.vscode/workspace.code-workspace" + edit -- "$DOROTHY/.vscode/workspace.code-workspace" else edit -- "$DOROTHY" fi diff --git a/commands/edit b/commands/edit index 73ec0dbca..bf4e8e1ec 100755 --- a/commands/edit +++ b/commands/edit @@ -156,6 +156,13 @@ function edit_() ( if test "$prompt" = 'no' -o "$sudo" = 'yes'; then continue fi + if is-kde; then + # https://code.visualstudio.com/docs/editor/settings-sync#_recommended-configure-the-keyring-to-use-with-vs-code + if command-missing kwalletmanager5; then + setup-util --quiet --cli=kwalletmanager5 APT='kwalletmanager' + fi + array+=('--password-store=kwallet5') + fi if test "$wait" = 'yes'; then array+=('-w') fi diff --git a/commands/is-kde b/commands/is-kde new file mode 100755 index 000000000..01ac7fddc --- /dev/null +++ b/commands/is-kde @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +function is_kde() ( + source "$DOROTHY/sources/bash.bash" + + # ===================================== + # Arguments + + function help { + cat <<-EOF >/dev/stderr + ABOUT: + Checks if the desktop environment is KDE or LXDE (LXDE is KDE based) + + USAGE: + is-kde + + RETURNS: + [0] if the desktop environment is KDE or LXDE + [1] if the desktop environment is not KDE nor LXDE + EOF + if test "$#" -ne 0; then + echo-error "$@" + fi + return 22 # EINVAL 22 Invalid argument + } + + # process + local item + while test "$#" -ne 0; do + item="$1" + shift + case "$item" in + '--help' | '-h') help ;; + '--'*) help "An unrecognised flag was provided: $item" ;; + *) help "An unrecognised argument was provided: $item" ;; + esac + done + + # ===================================== + # Action + + if [[ "${DESKTOP_SESSION}" = 'LXDE'* ]] || [[ "${DESKTOP_SESSION}" = 'KDE'* ]]; then + return 0 + else + return 1 + fi +) + +# fire if invoked standalone +if test "$0" = "${BASH_SOURCE[0]}"; then + is_kde "$@" +fi