Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customise tray icon? #1130

Closed
andoruB opened this issue Oct 26, 2017 · 11 comments
Closed

Customise tray icon? #1130

andoruB opened this issue Oct 26, 2017 · 11 comments

Comments

@andoruB
Copy link

andoruB commented Oct 26, 2017

This is not a bug, but I was unsure where I could ask this.
I'm using OpenBox and Tint2 on Debian Sid, and I wanted to know if there's a way to change the default tray icon(s) for KeePassXC. XC's icon is fine, just that it looks jarring in the tray compared to how the rest of the icons look. IIRC Tint2 uses 22x22 icons.
I've tried replacing everything under /usr/share/keepassxc/icons/application/*/apps/, to no avail, still the same default tray icon is shown. I tried to make an apps folder under /usr/share/keepassxc/icons/application/22x22/, and copy the resized icons there with the correct name, but still no dice.
Does anyone know of any other way of changing the icon?

@droidmonkey
Copy link
Member

I believe it uses the SVG icons.

@andoruB
Copy link
Author

andoruB commented Oct 27, 2017

I replaced those as well (and the other sizes, hence the asterisk in the path above), still no dice.

@droidmonkey
Copy link
Member

Did you build and install yourself? Are you using the snap?

@andoruB
Copy link
Author

andoruB commented Oct 27, 2017

I'm using this: https://github.com/magkopian/keepassxc-debian, so partly yes to the first question.

@mrjovanovic
Copy link

The right solution, in my opinion, would be that the app follows the system theme for the icons. This is standard behavior on GNU/Linux applications.. See also #756 .. (there might be hints there how to make this possible)

Would really like to be able to do the same, as I have been similarly unsuccessful.

@phoerious
Copy link
Member

The problem with that is that we had serious bugs in our AppImage in Unity/Gnome and Snap releases which could only be fixed by forcing our own icon instead of allowing the system to override it.

@mrjovanovic
Copy link

@phoerious Any way to have the code optional? It's a really small code change, I believe. That way, it could be default for distro packages, and hardcoded icons for AppImage/Snap? Any way you could perhaps refer to those bugs?

@droidmonkey
Copy link
Member

@phoerious I fixed that forced icon behavior in the snap using the sed trick on build.

@phoerious
Copy link
Member

phoerious commented Oct 30, 2017

Just search for "AppImage tray icon" or "snap tray icon".
We do have compile flags for AppImages and Snaps, which we could use, although at least a part of the fix lies already in the AppImage startup script.

@mrjovanovic
Copy link

Just a note for anyone who is coming into this thread, looking for consistency in their theming. You want to theme keepassxc-locked.png and keepassxc-unlocked.png in the 16x16/apps/. and 24x24/apps/. folders of your chosen theme.

@Pandiora
Copy link

Pandiora commented Oct 30, 2018

Thanks for your hint @mrjovanovic you pointed me in the right direction. After digging deeper I found out my current theme (Flat-Remix-Dark from Cinnamon-Spices) inherits other themes like "hi-color". I've done a lot of trial and error, just to find out it was the hi-color theme that provides keepassxc with its tray-icons.

The next problem: My theme is really dark and I want all tray-icons to be mostly white. I found some nice white icons in the panel folder of my theme (~/.icons/Flat-Remix-Dark/panel/keepassxc-locked.svg). And since this wasn't enough of a headache, the icons didn't resized "correctly" when saved as png for me -> so I saved them as svg. Those are the icons (png since github doesn't allow svg):

lockedunlocked

So, for all you guys who want a clean look and for my future me, I've created a shell-script for this task:

#!/bin/bash
# Replace keepassxc tray icons with white icons for dark themes
# save this script, make it executable by "chmod +x" and run it by sudo

# Icons for dark themes
KEEPASSXC_LOCKED="<?xml version=\"1.0\" encoding=\"UTF-8\"?><svg version=\"1.1\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><defs><style type=\"text/css\">.ColorScheme-Text { color:#ffffff; } .ColorScheme-Highlight { color:#5294e2; }</style></defs><path class=\"ColorScheme-Text\" d=\"m12 4a5 5 0 0 0 -5 5 5 5 0 0 0 3 4.5762v5.4238l2 2 1-1v-5h1.0137c0.0034-0.27972 0.05612-0.54625 0.13086-0.80469l-0.14453-0.14453v-0.4707a5 5 0 0 0 0.58203 -0.30664c0.30116-0.42508 0.7061-0.76778 1.1797-0.99024a5 5 0 0 0 1.2383 -3.2832 5 5 0 0 0 -5 -5zm0 1a2 2 0 0 1 2 2 2 2 0 0 1 -2 2 2 2 0 0 1 -2 -2 2 2 0 0 1 2 -2zm-1 9h1v4h-1z\" fill=\"currentColor\"/><path class=\"ColorScheme-Text\" d=\"m17 13c-1.108 0-2 0.91085-2 2.0312v0.96875h-1v4h6v-4h-1v-0.96875c0-1.1199-0.892-2.0312-2-2.0312zm0 1c0.554 0 1 0.4424 1 1v1h-2v-1c0-0.5576 0.446-1 1-1z\" fill=\"currentColor\"/></svg>"
KEEPASSXC_UNLOCKED="<?xml version=\"1.0\" encoding=\"UTF-8\"?><svg version=\"1.1\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><defs><style type=\"text/css\">.ColorScheme-Text { color:#ffffff; } .ColorScheme-Highlight { color:#5294e2; }</style></defs><path class=\"ColorScheme-Text\" d=\"m12 4a5 5 0 0 0 -5 5 5 5 0 0 0 3 4.5762v5.4238l2 2 2-2v-0.69922l1-0.75-1-0.75v-0.75l1-1-1-1v-0.4707a5 5 0 0 0 3 -4.5801 5 5 0 0 0 -5 -5zm0 1a2 2 0 0 1 2 2 2 2 0 0 1 -2 2 2 2 0 0 1 -2 -2 2 2 0 0 1 2 -2zm-1 9h1v4h-1z\" fill=\"currentColor\"/></svg>"

# Icon-Paths
ICON_PATH[0]="/usr/share/icons/hicolor/"
ICON_PATH[1]="/usr/share/keepassxc/icons/application/"
ICON_PATH[2]="/usr/local/share/keepassxc/icons/application/"

# Icon-Sizes
ICON_SIZE[0]="16x16"
ICON_SIZE[1]="24x24"

# Icon-Names
ICON_NAME[0]="keepassxc-locked"
ICON_NAME[1]="keepassxc-unlocked"
ICON_NAME[2]="keepassxc-dark"

for i in "${ICON_PATH[@]}"
do
	for j in "${ICON_SIZE[@]}"
	do
		for k in "${ICON_NAME[@]}"
		do
		    if [ "$k" == "keepassxc-locked" ]
		    then
		    	echo ${KEEPASSXC_LOCKED} > $i$j"/apps/"$k".png"
		    else
		    	echo ${KEEPASSXC_UNLOCKED} > $i$j"/apps/"$k".png"
		    fi
		    mv $i$j"/apps/"$k".png" $i$j"/apps/"$k".svg"
			echo "Replaced "$i$j"/apps/"$k".png"
		done
	done
done
echo "Done!"

Don't blame me, this is my first shell-script and I had to stackoverflow a bit. Icons are attached - I'm only using the locked and unlocked version - no color, just white. This script replaces the icons for 16x16 and 24x24 with svg-images. Script may crash if you don't have keepassxc installed in one of the paths. Then you just have to delete the corresponding "ICON_PATH" and set the other array-integers correctly. (0 -> 1) Same for the theme-folder, since I can't know which theme you're using -> change the path then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants