Skip to content

Instantly share code, notes, and snippets.

@asamofal
Created April 18, 2019 11:24
Show Gist options
  • Save asamofal/17a7915084d1e3595f8e228d56b0c582 to your computer and use it in GitHub Desktop.
Save asamofal/17a7915084d1e3595f8e228d56b0c582 to your computer and use it in GitHub Desktop.
#!/bin/bash
##################################################
# DeskTime updater v1.0
# Anton Samofal, 2019
##################################################
# design
txtbld=$(tput bold)
red=${txtbld}$(tput setaf 1)
green=${txtbld}$(tput setaf 2)
blue=${txtbld}$(tput setaf 4)
reset=$(tput sgr0)
toend=$(tput hpa $(tput cols))$(tput cub 6)
CMD=""
# check root permission
if [ "$(id -u)" != "0" ]; then
CMD="sudo"
fi
# Kill DeskTime
${CMD} kill -9 `pidof desktime-linux` &> /dev/null
echo "${green}Killing currently running instances of DeskTime...${toend}[OK]"
echo -n "${reset}"
# Remove current version of DeskTime
if which desktime-linux > /dev/null; then
echo "${green}Removing current version of DeskTime...${toend}[OK]"
echo -n "${reset}"
${CMD} apt-get remove desktime-linux -y > /dev/null
fi
# Remove Desktime congifs and cache
${CMD} rm -Rf ~/.desk-time ~/.config/DeskTime
echo "${green}Removing Desktime congifs and cache...${toend}[OK]"
echo -n "${reset}"
# Download the latest version of DeskTime client
echo "${green}Downloading the latest version of DeskTime...${toend}[OK]"
echo -n "${reset}"
wget -O desktime-linux.deb -q -U "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36" --show-progress https://desktime.com/updates/linux/install
# Install a new version of DeskTime
echo "${green}Installing a new version of DeskTime..."
echo -n "${reset}"
${CMD} apt-get install ./desktime-linux.deb -y > /dev/null
# Clean up
rm -f desktime-linux.deb
# Run a new version of DeskTime in background
desktime-linux & 2> /dev/null
echo "${blue}DeskTime is ready. Please, sign in."
echo -n "${reset}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment