Skip to content

Instantly share code, notes, and snippets.

@rightaditya
Created December 4, 2020 15:19
Show Gist options
  • Save rightaditya/c71885f742adc49c266fa367ef9543a8 to your computer and use it in GitHub Desktop.
Save rightaditya/c71885f742adc49c266fa367ef9543a8 to your computer and use it in GitHub Desktop.
script to replace 1password tray icon with the one from papirus
#!/bin/bash
# needs rsvg-convert (apt://librsvg2-bin), asar (snap://asar), and identify (apt://imagemagick)
ASAR=/opt/1Password/resources/app.asar
SRC="https://raw.githubusercontent.com/PapirusDevelopmentTeam/papirus-icon-theme/master/Papirus/22x22/panel/1password-panel.svg"
TMPDIR=./tmp
TGT="$TMPDIR/images/onepassword-128@2x.png"
if [[ -f "$ASAR".bak ]]
then
echo "$ASAR".bak already exists! Bailing.
exit 1
elif [[ -e "$TMPDIR" ]]
then
echo temporary directory \"$TMPDIR\" exists! Bailing.
exit 1
fi
echo Extracting...
asar e "$ASAR" "$TMPDIR"
echo Replacing icon...
W=$(identify -format %w "$TGT")
H=$(identify -format %h "$TGT")
rsvg-convert -f png -o "$TGT" -w $W -h $H <(curl -s "$SRC")
echo Backing up and replacing asar...
sudo mv "$ASAR" "$ASAR".bak
sudo asar p "$TMPDIR" "$ASAR"
echo Deleting temporary directory \"$TMPDIR\"...
rm -rf "$TMPDIR"
echo Done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment