~chromium-team/chromium-browser/focal-stable

1494.1.1 by Olivier Tilloy
* Upstream release: 75.0.3770.80
1
#!/bin/sh
2
if ! [ -x /snap/bin/chromium ]; then
3
    echo "" >&2
4
    echo "Command '$0' requires the chromium snap to be installed." >&2
5
    echo "Please install it with:" >&2
6
    echo "" >&2
7
    echo "snap install chromium" >&2
8
    echo "" >&2
9
    exit 1
10
fi
1494.1.3 by Olivier Tilloy
* Add back the original desktop file and the corresponding icons, and make the wrapper script rename the desktop file in well-known desktop launchers (currently GNOME Shell and Unity)
11
1528 by Olivier Tilloy
* New upstream release: 78.0.3904.108
12
if [ "$(xdg-settings get default-web-browser)" = "chromium-browser.desktop" ]; then
1506 by Olivier Tilloy
* Make the wrapper script update the default web browser if needed
13
  xdg-settings set default-web-browser chromium_chromium.desktop
14
fi
15
1494.1.3 by Olivier Tilloy
* Add back the original desktop file and the corresponding icons, and make the wrapper script rename the desktop file in well-known desktop launchers (currently GNOME Shell and Unity)
16
# GNOME Shell
17
OLD="chromium-browser.desktop"
18
NEW="chromium_chromium.desktop"
1516 by Olivier Tilloy
* chromium-browser: avoid printing spurious warnings if the gsettings schemas do not exist
19
FAVS=$(gsettings get org.gnome.shell favorite-apps 2> /dev/null)
1494.1.3 by Olivier Tilloy
* Add back the original desktop file and the corresponding icons, and make the wrapper script rename the desktop file in well-known desktop launchers (currently GNOME Shell and Unity)
20
if echo "$FAVS" | grep -q "'$OLD'"; then
21
  NEWFAVS=$(echo $FAVS | sed -e "s#'$OLD'#'$NEW'#")
22
  gsettings set org.gnome.shell favorite-apps "$NEWFAVS"
23
fi
24
25
# Unity
26
OLD="application://chromium-browser.desktop"
27
NEW="application://chromium_chromium.desktop"
1516 by Olivier Tilloy
* chromium-browser: avoid printing spurious warnings if the gsettings schemas do not exist
28
FAVS=$(gsettings get com.canonical.Unity.Launcher favorites 2> /dev/null)
1494.1.3 by Olivier Tilloy
* Add back the original desktop file and the corresponding icons, and make the wrapper script rename the desktop file in well-known desktop launchers (currently GNOME Shell and Unity)
29
if echo "$FAVS" | grep -q "'$OLD'"; then
30
  NEWFAVS=$(echo $FAVS | sed -e "s#'$OLD'#'$NEW'#")
31
  gsettings set com.canonical.Unity.Launcher favorites "$NEWFAVS"
32
fi
33
1517 by Olivier Tilloy
* chromium-browser: make the wrapper script rename the desktop file in MATE
34
# MATE
35
OLD="/usr/share/applications/chromium-browser.desktop"
36
NEW="/var/lib/snapd/desktop/applications/chromium_chromium.desktop"
37
OBJECTS=$(gsettings get org.mate.panel object-id-list 2> /dev/null)
38
for object in $OBJECTS; do
39
  object=$(echo $object | cut -d\' -f2)
40
  launcher=$(gsettings get org.mate.panel.object:/org/mate/panel/objects/$object/ launcher-location)
41
  if [ "$launcher" = "'$OLD'" ]; then
42
    gsettings set org.mate.panel.object:/org/mate/panel/objects/$object/ launcher-location "'$NEW'"
43
  fi
44
done
45
1518 by Olivier Tilloy
* chromium-browser: make the wrapper script rename the desktop file in KDE Plasma
46
# KDE Plasma
47
if which qdbus > /dev/null; then
48
  SCRIPT="$(cat <<-EOF
49
    for (var i = 0; i < panelIds.length; ++i) {
50
      var panel = panelById(panelIds[i]);
51
      var widgets = panel.widgets();
52
      for (var j = 0; j < widgets.length; ++j) {
53
        var widget = widgets[j];
54
        if (widget.type == "org.kde.plasma.taskmanager") {
55
          widget.currentConfigGroup = "General";
56
          var launchers = widget.readConfig("launchers");
57
          if (launchers.includes("chromium-browser.desktop")) {
58
            widget.writeConfig("launchers", launchers.replace(/chromium-browser.desktop/g, "chromium_chromium.desktop"));
59
          }
60
        }
61
      }
62
    }
63
EOF
64
  )"
65
  qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript "$SCRIPT" 2> /dev/null
66
fi
67
68
# TODO: handle other desktop environments
1494.1.3 by Olivier Tilloy
* Add back the original desktop file and the corresponding icons, and make the wrapper script rename the desktop file in well-known desktop launchers (currently GNOME Shell and Unity)
69
1520 by Olivier Tilloy
Revert the previous commit as this is better addressed from the snap side
70
exec /snap/bin/chromium "$@"