Skip to content

Instantly share code, notes, and snippets.

@gourytch
Created April 15, 2019 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gourytch/766f0227e86f8f48e7f3fc72f9e98584 to your computer and use it in GitHub Desktop.
Save gourytch/766f0227e86f8f48e7f3fc72f9e98584 to your computer and use it in GitHub Desktop.
launch separate Telegram instance from /snap
#! /bin/sh
set -e
set -x
ulimit -v 4000000
ulimit -c 2000000
export BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/telegram-desktop_telegramdesktop.desktop
telegram="/snap/bin/telegram-desktop"
tgid="$(basename $0 .sh)"
if [ -n "$tgid" ]; then
workdir="$HOME/snap/telegram-desktop/current/.local/share/$tgid"
if ( ps -ax | grep -v grep | grep 'Telegram' | grep -qF "$workdir" ) ; then
echo "telegram instance $tgid seems already started"
exit
fi
test -d "$workdir" || mkdir -p "$workdir"
wd="-workdir $workdir"
else
if ( ps -ax | grep -v grep | grep -qF Telegram ) ; then
echo "telegram instance seems already started"
exit
fi
fi
echo "start telegram instance $tgid ..."
if [ -z "$*" ]; then
$telegram -noupdate -many $wd &>/dev/null &
else
$telegram -noupdate -many $wd $*
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment