Compare commits

...

10 commits

Author SHA1 Message Date
Jacob Parnell d68a0d42c3 Add doas support 2023-05-11 23:20:18 -05:00
Mark Wagie 7d46ba7a27 Correct app.asar path for community bitwarden package 2022-06-09 13:33:25 -06:00
Mark Wagie 331889d01c compile Python bytecode, install pacman hook 2022-02-26 17:33:30 -07:00
Yuanji 4ab3a194e7
update makedepends 2019-01-08 17:01:41 +09:00
Bilal Elmoussaoui 127c483b86 add gobject-inter depen 2017-08-19 11:45:34 +02:00
Bilal Elmoussaoui a2d42edde0 update build system 2017-06-24 20:52:24 +02:00
Bilal Elmoussaoui 0e4b5fa430 small fixe 2017-05-23 12:15:21 +02:00
Bilal Elmoussaoui 7109ded1d3 bump version number 2017-05-23 12:02:40 +02:00
Bilal Elmoussaoui b866c880e6 bump version number 2017-05-23 12:01:35 +02:00
Edgard Castro 5b02dbe51f use un-annotated tags for pkgver 2017-01-26 13:52:38 -02:00
6 changed files with 239 additions and 44 deletions

View file

@ -1,25 +1,27 @@
pkgbase = hardcode-tray-git
pkgdesc = Fixes Hardcoded Tray Icons
pkgver = 3.6.5
pkgrel = 1
pkgdesc = Fixes hardcoded tray icons
pkgver = 4.3.r224.ga91b4b7
pkgrel = 2
url = https://github.com/bil-elmoussaoui/Hardcode-Tray
arch = i686
arch = x86_64
license = GPL
license = GPL3
makedepends = git
depends = python
depends = python-gobject
depends = python-cairosvg
depends = librsvg
makedepends = gobject-introspection
makedepends = meson
depends = gtk3
optdepends = sni-qt-patched-git: patched qt4 sni plugin to enable icon modification
optdepends = inkscape: to convert svg to png with inkscape
optdepends = lib32-sni-qt-patched-git: 32-bit patched qt4 sni plugin to enable icon modification
provides = hardcode-tray-git
conflicts = hardcode-tray-fixer-git
depends = librsvg
depends = python-cairosvg
depends = python-gobject
optdepends = nodejs-svgexport: option to convert svg to png
optdepends = imagemagick: option to convert svg to png
optdepends = inkscape: option to convert svg to png
provides = hardcode-tray
conflicts = hardcode-tray
source = git://github.com/bil-elmoussaoui/Hardcode-Tray
source = hardcode-tray::git+https://github.com/bil-elmoussaoui/Hardcode-Tray.git
source = 90-hardcode-tray.hook
source = hook.py
sha256sums = SKIP
sha256sums = c16ba6a82d4fe523cb91bf472b44296db82ff301866e3bce18bb4149d0aae5ea
sha256sums = 64a9907f74c5c04fb9f32b2b0684a3ce040d3bc2baacabb3ca1e914d70f24c81
pkgname = hardcode-tray-git

10
.gitignore vendored Normal file
View file

@ -0,0 +1,10 @@
# Ignore everything
*
# But not these files...
!.gitignore
!PKGBUILD
!.SRCINFO
!90-hardcode-tray.hook
!hook.py
!doasuser.patch

12
90-hardcode-tray.hook Normal file
View file

@ -0,0 +1,12 @@
[Trigger]
Operation = Install
Operation = Upgrade
Type = Package
Target = *
[Action]
Description = Updating tray icons...
Depends = hardcode-tray-git
When = PostTransaction
Exec = /usr/bin/python /usr/share/hardcode-tray/hook.py
NeedsTargets

View file

@ -1,36 +1,60 @@
# Maintainer: Bilal Elmoussaoui <bil.elmoussaoui@gmail.com>
_pkgbase=hardcode-tray-git
_gitname=Hardcode-Tray
pkgname=$_pkgbase
pkgver=3.6.5
# Maintainer: Mark Wagie <mark dot wagie at tutanota dot com>
# Contributor: Yuanji <self@gimo.me>
# Contributor: Bilal Elmoussaoui <bil.elmoussaoui@gmail.com>
pkgname=hardcode-tray-git
pkgver=4.3.r246.g1d52b2c
pkgrel=1
pkgdesc="Fixes Hardcoded Tray Icons"
arch=('i686' 'x86_64')
pkgdesc="Fixes hardcoded tray icons"
arch=('x86_64')
url="https://github.com/bil-elmoussaoui/Hardcode-Tray"
license=('GPL')
provides=("$_pkgbase")
makedepends=("git")
conflicts=("hardcode-tray-fixer-git" "hardcode-tray")
depends=('python' 'python-gobject' 'python-cairosvg' 'librsvg' 'gtk3')
optdepends=('sni-qt-patched-git: patched qt4 sni plugin to enable icon modification' 'inkscape: to convert svg to png with inkscape')
optdepends_x86_64=('lib32-sni-qt-patched-git: 32-bit patched qt4 sni plugin to enable icon modification')
source=("git://github.com/bil-elmoussaoui/Hardcode-Tray")
sha256sums=('SKIP')
license=('GPL3')
depends=('gtk3' 'librsvg' 'python-cairosvg' 'python-gobject')
makedepends=('git' 'gobject-introspection' 'meson')
optdepends=('nodejs-svgexport: option to convert svg to png'
'imagemagick: option to convert svg to png'
'inkscape: option to convert svg to png')
provides=("${pkgname%-git}")
conflicts=("${pkgname%-git}")
source=("${pkgname%-git}::git+https://github.com/bil-elmoussaoui/Hardcode-Tray.git"
"90-${pkgname%-git}.hook"
"hook.py"
"doasuser.patch")
sha256sums=('SKIP'
'c16ba6a82d4fe523cb91bf472b44296db82ff301866e3bce18bb4149d0aae5ea'
'64a9907f74c5c04fb9f32b2b0684a3ce040d3bc2baacabb3ca1e914d70f24c81'
'8f567656707f3e1bc534f2b30b0f87a1b9df9372be27788b61044a54fec90045')
pkgver() {
cd "$srcdir/$_gitname"
( set -o pipefail
git describe --long 2>/dev/null | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' ||
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
)
cd "$srcdir/${pkgname%-git}"
git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}
prepare() {
cd "$srcdir/${pkgname%-git}"
# Correct app.asar path for community bitwarden package
sed -i 's|/usr/lib/bitwarden/resources/|/usr/lib/bitwarden/|g' \
data/database/bitwarden.electron.json
# Add doas support
patch --forward --strip=1 --input="${srcdir}/doasuser.patch"
}
build() {
arch-meson "${pkgname%-git}" build
meson compile -C build
}
package() {
install -Dm755 "$srcdir/$_gitname/script.py" "$pkgdir/opt/$_gitname/script.py"
install -Dm755 "$srcdir/$_gitname/hardcode-tray" "$pkgdir/usr/bin/hardcode-tray"
install -d "$pkgdir/opt/$_gitname"
cp -r -f "$srcdir/$_gitname/database" "$pkgdir/opt/$_gitname"
cp -r -f "$srcdir/$_gitname/modules" "$pkgdir/opt/$_gitname"
meson install -C build --destdir "$pkgdir"
# Compile Python bytecode:
local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
python -m compileall -d "$site_packages" "$pkgdir$site_packages"
python -O -m compileall -d "$site_packages" "$pkgdir$site_packages"
# Add pacman hook
# https://github.com/bilelmoussaoui/Hardcode-Tray/issues/454
install -Dm644 "$srcdir/90-${pkgname%-git}.hook" -t "$pkgdir/etc/pacman.d/hooks"
install -Dm644 "$srcdir/hook.py" -t "$pkgdir/usr/share/${pkgname%-git}"
}

12
doasuser.patch Normal file
View file

@ -0,0 +1,12 @@
diff --unified --recursive --text --color hardcode-tray.orig/const.py.in hardcode-tray.new/const.py.in
--- hardcode-tray.orig/const.py.in 2023-05-04 15:16:47.519709571 -0500
+++ hardcode-tray.new/const.py.in 2023-05-04 15:19:08.596711509 -0500
@@ -24,7 +24,7 @@
from HardcodeTray.tools import detect_de, get_themes
DB_FOLDER = path.join("@DATA_DIR@", "database", "")
-USERNAME = getenv("SUDO_USER") or getenv("USER")
+USERNAME = getenv("SUDO_USER") or getenv("DOAS_USER") or getenv("USER")
USERHOME = path.expanduser("~" + USERNAME)
BACKUP_FOLDER = path.join(USERHOME, ".config", "Hardcode-Tray", "")
CONFIG_FILE = path.join(USERHOME, ".config", "hardcode-tray.json")

135
hook.py Normal file
View file

@ -0,0 +1,135 @@
#!/usr/bin/env python3
import json
import re
import sys
from subprocess import run, PIPE
from glob import glob
from os import path
from HardcodeTray.const import DB_FOLDER, USERHOME
HARDCORE_TRAY_PACKAGES = ['hardcode-tray-git', 'hardcode-tray']
BLACKLIST = ['mullvad'] # Added cause got /usr/bin in it paths
CONVERSION_TOOL = 'RSVGConvert' # None if not needed
THEME = 'Papirus-Dark' # None if not needed
class Hook:
userhome_re = r"{userhome}"
def __init__(self, packages):
self.__packages = packages
self.__db = self.read_db_files()
def read_db_files(self):
""" Reading all package paths """
files = glob("{0}*.json".format(path.join(DB_FOLDER, "")))
db = {}
for db_file in files:
script_name = path.splitext(path.basename(db_file))[0]
if script_name in BLACKLIST:
continue
with open(db_file, 'r') as db_file:
app_path = json.load(db_file)['app_path']
db[script_name] = [re.sub(Hook.userhome_re, USERHOME, sctipt_path) for sctipt_path in app_path]
return db
def get_package_paths(self, package):
""" Reading all package paths from pacman """
regex = r"^%s\s+" % re.escape(package)
proc = run(
[
"pacman", "-Ql",
package
],
stdout=PIPE,
stderr=PIPE,
)
if proc.returncode == 0:
output = str(proc.stdout, "utf-8").split('\n')
return [re.sub(regex, '',line) for line in output if re.match(regex, line)]
else:
return []
def get_supported_scripts(self):
""" Finding supported scripts """
supported_scripts = [];
for package in self.__packages:
package_paths = self.get_package_paths(package)
for path in package_paths:
for script_name, script_paths in self.__db.items():
if path in script_paths:
supported_scripts.append(script_name)
return set(supported_scripts)
def run_hadcode_tray(self, packages = None):
""" Hardcode tray bit execution """
args = ["hardcode-tray"]
if CONVERSION_TOOL != None:
args += ["--conversion-tool", CONVERSION_TOOL]
if THEME != None:
args += ["--theme", THEME]
if packages != None:
args += ["--only", ','.join(packages)]
args.append("--apply")
proc = run(
args,
stdout=PIPE,
stderr=PIPE,
)
return (proc.returncode == 0)
def execute(self):
""" Execution method running hardcode-tray for supported apps"""
for package in self.__packages:
if package in HARDCORE_TRAY_PACKAGES:
if self.run_hadcode_tray():
print("All packages are updated.")
return True
else:
print("Packages update failed.")
return False
packages_for_update = self.get_supported_scripts()
if len(packages_for_update) == 0:
print("No packages for update has been found.")
return True
else:
if self.run_hadcode_tray(packages_for_update):
print("Packages: %s - updated." % ', '.join(packages_for_update))
return True
else:
print("Packages: %s - failed." % ', '.join(packages_for_update))
return False
return True
input_str = sys.stdin.read()
packages = [x for x in input_str.split('\n') if x]
hook = Hook(packages)
if not hook.execute():
sys.exit('Hook failed')