bash: fix snapd support for non-classic installations

This commit is contained in:
Aminda Suomalainen 2025-09-25 16:00:45 +03:00
parent 3ad49bffd3
commit cd4dc28b18
Signed by: Mikaela
GPG Key ID: 99392F62BAE30723
16 changed files with 19 additions and 19 deletions

View File

@ -43,7 +43,7 @@ fi
# towards Mozilla and search engine policy support. Otherwise install Firefox # towards Mozilla and search engine policy support. Otherwise install Firefox
# This is officially supported/published by Mozilla. # This is officially supported/published by Mozilla.
if [[ ! -f "/usr/bin/firefox" ]] && [[ ! -f "/usr/bin/firefox-esr" ]]; then 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 snap refresh firefox --channel=esr/stable
else else
snap install firefox --channel=esr/stable snap install firefox --channel=esr/stable
@ -55,7 +55,7 @@ fi
# Difficult to test Chromium policies without Chromium. And for testing edge is fine. # Difficult to test Chromium policies without Chromium. And for testing edge is fine.
# Published/supported by Canonical. # Published/supported by Canonical.
if [[ ! -f "/usr/bin/chromium" ]] && [[ ! -f "/usr/bin/chromium-browser" ]]; then 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 snap refresh chromium --channel=edge
else else
snap install chromium --edge snap install chromium --edge
@ -67,7 +67,7 @@ fi
# European/Norwegian freeware browser that I prefer to keep installed as an option. # European/Norwegian freeware browser that I prefer to keep installed as an option.
# Official snap. # Official snap.
if [[ ! -f "/usr/bin/vivaldi" ]] && [[ ! -f "/usr/bin/vivaldi-snapshot" ]]; then 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 snap refresh vivaldi
else else
snap install vivaldi snap install vivaldi
@ -79,7 +79,7 @@ fi
# - 2025: https://news.ycombinator.com/item?id=43251203 # - 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 "/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 # snap refresh brave
# else # else
# snap install brave # snap install brave

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -x 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 # https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/104
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
snap run bitwarden --ozone-platform=x11 --enable-features=WaylandWindowDecorations "$@" snap run bitwarden --ozone-platform=x11 --enable-features=WaylandWindowDecorations "$@"

View File

@ -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 "$@" /usr/bin/brave-browser-nightly --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@"
elif [ -f /usr/bin/brave-browser-stable ]; then elif [ -f /usr/bin/brave-browser-stable ]; then
/usr/bin/brave-browser-stable --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@" /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 "$@" snap run brave --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable "$@"
fi fi

View File

@ -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 "$@" /usr/bin/chromium-browser --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@"
elif [ -f /usr/bin/chromium ]; then elif [ -f /usr/bin/chromium ]; then
/usr/bin/chromium --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@" /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 "$@" snap run chromium --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@"
else else
flatpak run org.chromium.Chromium --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@" flatpak run org.chromium.Chromium --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@"

View File

@ -4,7 +4,7 @@ set -x
if [ -f /usr/bin/code ]; then if [ -f /usr/bin/code ]; then
/usr/bin/code --verbose --enable-features=WaylandWindowDecorations,UseOzonePlatform --ozone-platform=wayland "$@" /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 # https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/104
#unset DBUS_SESSION_BUS_ADDRESS #unset DBUS_SESSION_BUS_ADDRESS
# https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/105 # https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/105

View File

@ -4,7 +4,7 @@ set -x
if [ -f /usr/bin/code-insiders ]; then if [ -f /usr/bin/code-insiders ]; then
/usr/bin/code-insiders --verbose --enable-features=WaylandWindowDecorations,UseOzonePlatform --ozone-platform=wayland "$@" /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 # https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/104
#unset DBUS_SESSION_BUS_ADDRESS #unset DBUS_SESSION_BUS_ADDRESS
# https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/105 # https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/105

View File

@ -4,7 +4,7 @@ set -x
if [ -f /usr/bin/codium ]; then if [ -f /usr/bin/codium ]; then
/usr/bin/codium --verbose --enable-features=WaylandWindowDecorations,UseOzonePlatform --ozone-platform=wayland "$@" /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 # https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/104
#unset DBUS_SESSION_BUS_ADDRESS #unset DBUS_SESSION_BUS_ADDRESS
# https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/105 # https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/105

View File

@ -18,7 +18,7 @@ elif [ -f /usr/bin/firefox ]; then
elif [ -f /usr/bin/firefox-esr ]; then elif [ -f /usr/bin/firefox-esr ]; then
/usr/bin/firefox-esr $FlagsForFirefox /usr/bin/firefox-esr $FlagsForFirefox
# Fallback to Snap which apparently follows /etc/policies.json # 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 snap run firefox $FlagsForFirefox
# Fallback to flatpak, don't care if it doesn't exist # Fallback to flatpak, don't care if it doesn't exist
else else

View File

@ -3,7 +3,7 @@
# Flutter doesn't support flatpak, so Snap is the least bad Fluffy experience. # Flutter doesn't support flatpak, so Snap is the least bad Fluffy experience.
set -x 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 # https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/104
unset DBUS_SESSION_BUS_ADDRESS unset DBUS_SESSION_BUS_ADDRESS
# I am supposed to be a Finnish localizer so my eo over fi as protest # I am supposed to be a Finnish localizer so my eo over fi as protest

View File

@ -13,7 +13,7 @@ export GOVERSION=1.21
if [ -f /home/linuxbrew/.linuxbrew/bin/go ]; then if [ -f /home/linuxbrew/.linuxbrew/bin/go ]; then
/home/linuxbrew/.linuxbrew/bin/go "$@" /home/linuxbrew/.linuxbrew/bin/go "$@"
elif [ -f /snap/bin/go ]; then elif [ -f /var/lib/snapd/snap/bin/go ]; then
snap run go "$@" snap run go "$@"
# Or if Debian hides it somewhere nice. # Or if Debian hides it somewhere nice.

View File

@ -6,7 +6,7 @@
# installed is fine... # installed is fine...
set -x 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 # https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/104
unset DBUS_SESSION_BUS_ADDRESS unset DBUS_SESSION_BUS_ADDRESS
snap run joplin-desktop --ozone-platform=wayland "$@" snap run joplin-desktop --ozone-platform=wayland "$@"

View File

@ -10,7 +10,7 @@ if [ -f /usr/bin/nvim ]; then
#elif [ -f ~/.local/share/flatpak/exports/bin/io.neovim.nvim ]; then #elif [ -f ~/.local/share/flatpak/exports/bin/io.neovim.nvim ]; then
# flatpak run --user io.neovim.nvim "$@" # flatpak run --user io.neovim.nvim "$@"
# Snap # Snap
#elif [ -f /snap/bin/nvim ]; then #elif [ -f /var/lib/snapd/snap/bin/nvim ]; then
# snap run nvim "$@" # snap run nvim "$@"
# Fallback to vim, because this script breaks my alias/function # Fallback to vim, because this script breaks my alias/function
elif [ -f /usr/bin/vim ]; then elif [ -f /usr/bin/vim ]; then

View File

@ -5,7 +5,7 @@
set -x set -x
# --start-in-tray - would be nice, but then I cannot open it from there, thus --use-tray-icon # --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 "$@" &) (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 set signal-desktop tray-icon=true
(snap run signal-desktop --use-tray-icon --ozone-platform=wayland --enable-features=WaylandWindowDecorations "$@" &) (snap run signal-desktop --use-tray-icon --ozone-platform=wayland --enable-features=WaylandWindowDecorations "$@" &)
fi fi

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -x 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 # https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/105
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
snap run superproductivity --ozone-platform=wayland --enable-features=WaylandWindowDecorations "$@" snap run superproductivity --ozone-platform=wayland --enable-features=WaylandWindowDecorations "$@"

View File

@ -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 "$@" /usr/bin/vivaldi-snapshot --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@"
elif [ -f /usr/bin/vivaldi ]; then elif [ -f /usr/bin/vivaldi ]; then
/usr/bin/vivaldi --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@" /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 "$@" snap run vivaldi.vivaldi-stable --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable "$@"
fi fi
set +x set +x

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -x 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 # https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491/comments/105
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
snap run vlc "$@" snap run vlc "$@"