From cd4dc28b180f2bc3c5e2ad6b8c2f69387d539c94 Mon Sep 17 00:00:00 2001 From: Aminda Suomalainen Date: Thu, 25 Sep 2025 16:00:45 +0300 Subject: [PATCH] bash: fix snapd support for non-classic installations --- bash/snap-browsers.bash | 8 ++++---- bash/usr-local-bin/bitwarden | 2 +- bash/usr-local-bin/brave | 2 +- bash/usr-local-bin/chromium | 2 +- bash/usr-local-bin/code | 2 +- bash/usr-local-bin/code-insiders | 2 +- bash/usr-local-bin/codium | 2 +- bash/usr-local-bin/firefox | 2 +- bash/usr-local-bin/fluffychat | 2 +- bash/usr-local-bin/go | 2 +- bash/usr-local-bin/joplin-desktop | 2 +- bash/usr-local-bin/nvim | 2 +- bash/usr-local-bin/signal-desktop | 2 +- bash/usr-local-bin/superproductivity | 2 +- bash/usr-local-bin/vivaldi | 2 +- bash/usr-local-bin/vlc-snap | 2 +- 16 files changed, 19 insertions(+), 19 deletions(-) diff --git a/bash/snap-browsers.bash b/bash/snap-browsers.bash index 5cf8c31..1dee462 100755 --- a/bash/snap-browsers.bash +++ b/bash/snap-browsers.bash @@ -43,7 +43,7 @@ fi # towards Mozilla and search engine policy support. Otherwise install Firefox # This is officially supported/published by Mozilla. if [[ ! -f "/usr/bin/firefox" ]] && [[ ! -f "/usr/bin/firefox-esr" ]]; then - if [ -f "/snap/bin/firefox" ]; then + if [ -f "/var/lib/snapd/snap/bin/firefox" ]; then snap refresh firefox --channel=esr/stable else snap install firefox --channel=esr/stable @@ -55,7 +55,7 @@ fi # Difficult to test Chromium policies without Chromium. And for testing edge is fine. # Published/supported by Canonical. if [[ ! -f "/usr/bin/chromium" ]] && [[ ! -f "/usr/bin/chromium-browser" ]]; then - if [ -f "/snap/bin/chromium" ]; then + if [ -f "/var/lib/snapd/snap/bin/chromium" ]; then snap refresh chromium --channel=edge else snap install chromium --edge @@ -67,7 +67,7 @@ fi # European/Norwegian freeware browser that I prefer to keep installed as an option. # Official snap. if [[ ! -f "/usr/bin/vivaldi" ]] && [[ ! -f "/usr/bin/vivaldi-snapshot" ]]; then - if [ -f "/snap/bin/vivaldi.vivaldi-stable" ]; then + if [ -f "/var/lib/snapd/snap/bin/vivaldi.vivaldi-stable" ]; then snap refresh vivaldi else snap install vivaldi @@ -79,7 +79,7 @@ fi # - 2025: https://news.ycombinator.com/item?id=43251203 # #if [[ ! -f "/usr/bin/brave-browser-stable" ]] && [[ ! -f "/usr/bin/brave-browser-beta" ]] && [[ ! -f "/usr/bin/brave-browser-nightly" ]]; then -# if [ -f "/snap/bin/brave" ]; then +# if [ -f "/var/lib/snapd/snap/bin/brave" ]; then # snap refresh brave # else # snap install brave diff --git a/bash/usr-local-bin/bitwarden b/bash/usr-local-bin/bitwarden index 476bcc7..270ab8c 100755 --- a/bash/usr-local-bin/bitwarden +++ b/bash/usr-local-bin/bitwarden @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -x -if [ -f /snap/bin/bitwarden ]; then +if [ -f /var/lib/snapd/snap/bin/bitwarden ]; then # https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/104 export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus snap run bitwarden --ozone-platform=x11 --enable-features=WaylandWindowDecorations "$@" diff --git a/bash/usr-local-bin/brave b/bash/usr-local-bin/brave index aad009c..2f3889f 100755 --- a/bash/usr-local-bin/brave +++ b/bash/usr-local-bin/brave @@ -5,7 +5,7 @@ if [[ -d "$HOME/.config/BraveSoftware/Brave-Browser-Nightly" && -d "$HOME/.cache /usr/bin/brave-browser-nightly --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@" elif [ -f /usr/bin/brave-browser-stable ]; then /usr/bin/brave-browser-stable --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@" -elif [ -f /snap/bin/brave ]; then +elif [ -f /var/lib/snapd/snap/bin/brave ]; then snap run brave --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable "$@" fi diff --git a/bash/usr-local-bin/chromium b/bash/usr-local-bin/chromium index 7fd39f5..1f31eaf 100755 --- a/bash/usr-local-bin/chromium +++ b/bash/usr-local-bin/chromium @@ -4,7 +4,7 @@ if [ -f /usr/bin/chromium-browser ]; then /usr/bin/chromium-browser --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@" elif [ -f /usr/bin/chromium ]; then /usr/bin/chromium --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@" -elif [ -f /snap/bin/chromium ]; then +elif [ -f /var/lib/snapd/snap/bin/chromium ]; then snap run chromium --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@" else flatpak run org.chromium.Chromium --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@" diff --git a/bash/usr-local-bin/code b/bash/usr-local-bin/code index 8c5c4e2..a0f8ba8 100755 --- a/bash/usr-local-bin/code +++ b/bash/usr-local-bin/code @@ -4,7 +4,7 @@ set -x if [ -f /usr/bin/code ]; then /usr/bin/code --verbose --enable-features=WaylandWindowDecorations,UseOzonePlatform --ozone-platform=wayland "$@" -elif [ -f /snap/bin/code ]; then +elif [ -f /var/lib/snapd/snap/bin/code ]; then # https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/104 #unset DBUS_SESSION_BUS_ADDRESS # https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/105 diff --git a/bash/usr-local-bin/code-insiders b/bash/usr-local-bin/code-insiders index fa53ef0..a1f4f6e 100755 --- a/bash/usr-local-bin/code-insiders +++ b/bash/usr-local-bin/code-insiders @@ -4,7 +4,7 @@ set -x if [ -f /usr/bin/code-insiders ]; then /usr/bin/code-insiders --verbose --enable-features=WaylandWindowDecorations,UseOzonePlatform --ozone-platform=wayland "$@" -elif [ -f /snap/bin/code-insiders ]; then +elif [ -f /var/lib/snapd/snap/bin/code-insiders ]; then # https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/104 #unset DBUS_SESSION_BUS_ADDRESS # https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/105 diff --git a/bash/usr-local-bin/codium b/bash/usr-local-bin/codium index 52dd8c7..179f720 100755 --- a/bash/usr-local-bin/codium +++ b/bash/usr-local-bin/codium @@ -4,7 +4,7 @@ set -x if [ -f /usr/bin/codium ]; then /usr/bin/codium --verbose --enable-features=WaylandWindowDecorations,UseOzonePlatform --ozone-platform=wayland "$@" -elif [ -f /snap/bin/codium ]; then +elif [ -f /var/lib/snapd/snap/bin/codium ]; then # https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/104 #unset DBUS_SESSION_BUS_ADDRESS # https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/105 diff --git a/bash/usr-local-bin/firefox b/bash/usr-local-bin/firefox index c4efb15..8630641 100755 --- a/bash/usr-local-bin/firefox +++ b/bash/usr-local-bin/firefox @@ -18,7 +18,7 @@ elif [ -f /usr/bin/firefox ]; then elif [ -f /usr/bin/firefox-esr ]; then /usr/bin/firefox-esr $FlagsForFirefox # Fallback to Snap which apparently follows /etc/policies.json -elif [ -f /snap/bin/firefox ]; then +elif [ -f /var/lib/snapd/snap/bin/firefox ]; then snap run firefox $FlagsForFirefox # Fallback to flatpak, don't care if it doesn't exist else diff --git a/bash/usr-local-bin/fluffychat b/bash/usr-local-bin/fluffychat index 89a4a9c..0e4eaac 100755 --- a/bash/usr-local-bin/fluffychat +++ b/bash/usr-local-bin/fluffychat @@ -3,7 +3,7 @@ # Flutter doesn't support flatpak, so Snap is the least bad Fluffy experience. set -x -if [ -f /snap/bin/fluffychat ]; then +if [ -f /var/lib/snapd/snap/bin/fluffychat ]; then # https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/104 unset DBUS_SESSION_BUS_ADDRESS # I am supposed to be a Finnish localizer so my eo over fi as protest diff --git a/bash/usr-local-bin/go b/bash/usr-local-bin/go index 74a5a43..cf82aa0 100755 --- a/bash/usr-local-bin/go +++ b/bash/usr-local-bin/go @@ -13,7 +13,7 @@ export GOVERSION=1.21 if [ -f /home/linuxbrew/.linuxbrew/bin/go ]; then /home/linuxbrew/.linuxbrew/bin/go "$@" -elif [ -f /snap/bin/go ]; then +elif [ -f /var/lib/snapd/snap/bin/go ]; then snap run go "$@" # Or if Debian hides it somewhere nice. diff --git a/bash/usr-local-bin/joplin-desktop b/bash/usr-local-bin/joplin-desktop index a4b66c9..d1838ae 100755 --- a/bash/usr-local-bin/joplin-desktop +++ b/bash/usr-local-bin/joplin-desktop @@ -6,7 +6,7 @@ # installed is fine... set -x -if [ -f /snap/bin/joplin-desktop ]; then +if [ -f /var/lib/snapd/snap/bin/joplin-desktop ]; then # https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/104 unset DBUS_SESSION_BUS_ADDRESS snap run joplin-desktop --ozone-platform=wayland "$@" diff --git a/bash/usr-local-bin/nvim b/bash/usr-local-bin/nvim index 5cd9401..f45ff3b 100755 --- a/bash/usr-local-bin/nvim +++ b/bash/usr-local-bin/nvim @@ -10,7 +10,7 @@ if [ -f /usr/bin/nvim ]; then #elif [ -f ~/.local/share/flatpak/exports/bin/io.neovim.nvim ]; then # flatpak run --user io.neovim.nvim "$@" # Snap -#elif [ -f /snap/bin/nvim ]; then +#elif [ -f /var/lib/snapd/snap/bin/nvim ]; then # snap run nvim "$@" # Fallback to vim, because this script breaks my alias/function elif [ -f /usr/bin/vim ]; then diff --git a/bash/usr-local-bin/signal-desktop b/bash/usr-local-bin/signal-desktop index c5a2e4d..f0b8717 100755 --- a/bash/usr-local-bin/signal-desktop +++ b/bash/usr-local-bin/signal-desktop @@ -5,7 +5,7 @@ set -x # --start-in-tray - would be nice, but then I cannot open it from there, thus --use-tray-icon (flatpak run org.signal.Signal --use-tray-icon --ozone-platform=wayland --enable-features=WaylandWindowDecorations "$@" &) -if [ -f /snap/bin/signal-desktop ]; then +if [ -f /var/lib/snapd/snap/bin/signal-desktop ]; then #snap set signal-desktop tray-icon=true (snap run signal-desktop --use-tray-icon --ozone-platform=wayland --enable-features=WaylandWindowDecorations "$@" &) fi diff --git a/bash/usr-local-bin/superproductivity b/bash/usr-local-bin/superproductivity index 510ca19..a38efb8 100755 --- a/bash/usr-local-bin/superproductivity +++ b/bash/usr-local-bin/superproductivity @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -x -if [ -f /snap/bin/superproductivity ]; then +if [ -f /var/lib/snapd/snap/bin/superproductivity ]; then # https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/105 export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus snap run superproductivity --ozone-platform=wayland --enable-features=WaylandWindowDecorations "$@" diff --git a/bash/usr-local-bin/vivaldi b/bash/usr-local-bin/vivaldi index 3767919..332eaae 100755 --- a/bash/usr-local-bin/vivaldi +++ b/bash/usr-local-bin/vivaldi @@ -4,7 +4,7 @@ if [[ -d "$HOME/.config/vivaldi-snapshot" && -d "$HOME/.cache/vivaldi-snapshot" /usr/bin/vivaldi-snapshot --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@" elif [ -f /usr/bin/vivaldi ]; then /usr/bin/vivaldi --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@" -elif [ -f /snap/bin/vivaldi.vivaldi-stable ]; then +elif [ -f /var/lib/snapd/snap/bin/vivaldi.vivaldi-stable ]; then snap run vivaldi.vivaldi-stable --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable "$@" fi set +x diff --git a/bash/usr-local-bin/vlc-snap b/bash/usr-local-bin/vlc-snap index 7244889..d5fad28 100755 --- a/bash/usr-local-bin/vlc-snap +++ b/bash/usr-local-bin/vlc-snap @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -x -if [ -f /snap/bin/vlc ]; then +if [ -f /var/lib/snapd/snap/bin/vlc ]; then # https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/105 export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus snap run vlc "$@"