Created
June 11, 2024 17:37
-
-
Save KisaragiEffective/b17701eb3ae1ffbb37bbfd344d19176a to your computer and use it in GitHub Desktop.
Debian 12でDiscordが古いと文句を言ってくる問題を解決するシェルスクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# SPDX-License-Identifier: CC0-1.0 | |
# SPDX-FileCopyrightText: 2024 Kisaragi Marine | |
d="$(mktemp)" | |
if [ -t 1 ]; then | |
tty=1 | |
else | |
tty=0 | |
fi | |
if [ "$tty" = 0 ]; then | |
escalation=/usr/bin/pkexec | |
else | |
escalation=/usr/bin/sudo | |
fi | |
current_version="$(dpkg-query -f '${Version}' -W discord)" | |
latest_version="$(curl -sS --head 'https://discord.com/api/download/stable?platform=linux&format=deb' | grep -e '^location:' | cut -d: -f2-3 | cut -d/ -f6)" | |
if ! dpkg --compare-versions "$current_version" ge "$latest_version"; then | |
# outdated! update it. | |
curl -L 'https://discord.com/api/download/stable?platform=linux&format=deb' > "$d" | |
mv "$d" "$d.deb" | |
"$escalation" apt install "$d.deb" | |
rm "$d.deb" | |
cp /usr/share/applications/discord.desktop ~/.local/share/applications | |
"$escalation" rm /usr/share/applications/discord.desktop || true | |
sed -i -e "s%^Exec=/usr/share/discord/Discord$%Exec=/home/kisaragi/.local/bin/discord-update%" ~/.local/share/applications/discord.desktop | |
fi | |
/usr/share/discord/Discord |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment