Hardcode-Tray icon indicating copy to clipboard operation
Hardcode-Tray copied to clipboard

Arch linux pacman hook

Open flops opened this issue 7 years ago • 10 comments

It's not a bug, it's some kind of suggestion. I've tired to run a script after install any supported package so just fast added a hook for pacman to run after every install and run hardcode-tray if needed. It's dirty and there could be much cleaner way to use HardcodeTray.App class as is (i'm not a python dev at all). https://gist.github.com/flops/26e02c63dd1193332c3a5e060a05d565

But as an proof of concept. And would be great if some kind of near implementation will appear in package itself.

flops avatar Oct 24 '17 23:10 flops

It's definitely a great idea. But before working on this, I would like to improve the basic functionalities, and rewrite some code to fix some small issues. Once it's done i will work on this 👍

bilelmoussaoui avatar Oct 27 '17 09:10 bilelmoussaoui

@flops I've added hardcode-tray to the Manjaro Community repo with your hook. Let me know if there should be any adjustments. It's working great for me.

EDIT: I've removed it from the repo for now. I may add it again if I decide to also add papirus-icon-theme-git .

For now, use my hardcode-tray-git PKGBUILD and papirus-icon-theme-git from the AUR.

yochananmarqos avatar Jun 14 '20 15:06 yochananmarqos

It doesn't work for me. I see this error every time I'm installing anything by pamac-manager

Traceback (most recent call last):
  File "/usr/share/hardcode-tray/hook.py", line 11, in <module>
    from HardcodeTray.const import DB_FOLDER, USERHOME
  File "/usr/lib/python3.8/site-packages/HardcodeTray/const.py", line 28, in <module>
    USERHOME = path.expanduser("~" + USERNAME)
TypeError: can only concatenate str (not "NoneType") to str

It looks like USERNAME here is None, but I have no idea why. I've tried to write and execute test code to find out what is wrong with it.

from os import getenv, path
from platform import machine

USERNAME = getenv("SUDO_USER") or getenv("USER")
USERHOME = path.expanduser("~" + USERNAME)

print(getenv("SUDO_USER"))
print(getenv("USER"))
print(USERNAME)
print(USERHOME)

And it works the way it's supposed to. All of the variables are not empty no meter whether I'm running it with a user privilege or with sudo. Any ideas?

yuzvir avatar Jul 28 '20 08:07 yuzvir

@yuzvir How did you install Hardcode Tray? See my edited comment above.

yochananmarqos avatar Jul 28 '20 17:07 yochananmarqos

@yochananmarqos I uninstalled the old package, downloaded all the files from your repo folder and run

makepg
makepkg --install

still have the same issue

yuzvir avatar Jul 31 '20 21:07 yuzvir

@yuzvir

the old package

What old package? Use my hardcode-tray-git package from my GitHub like I mentioned above.

yochananmarqos avatar Jul 31 '20 21:07 yochananmarqos

I don't remember where I got the old one, but it doesn't meter since I've removed it. As I already said I tried your hardcode-tray-git without any success. sudo hardcode-tray --apply works as expected, but hook doesn't.

yuzvir avatar Jul 31 '20 22:07 yuzvir

Oh, I misunderstood about the old package bit.

I really have no idea why that would happen. It works for me using Pacman, Yay and Topgrade. I don't use Pamac.

yochananmarqos avatar Jul 31 '20 22:07 yochananmarqos

well... It is probably because hooks could be run with its own environment. I don't know the proper way to deal with it, so I just replaced

from HardcodeTray.const import DB_FOLDER, USERHOME

with

DB_FOLDER = path.join("/usr/share/hardcode-tray", "database", "")
USERHOME = '/home/user'  # path to my user home folder

in /usr/share/hardcode-tray/hook.py file

yuzvir avatar Aug 03 '20 09:08 yuzvir

also found this problem:

if not hook.execute():
    sys.exitsys.exit('Hook failed')

should be

if not hook.execute():
    sys.exit('Hook failed')

yuzvir avatar Aug 24 '20 11:08 yuzvir