Skip to content

Commit

Permalink
graphics/py-ueberzug: Add a new port
Browse files Browse the repository at this point in the history
  • Loading branch information
0mp committed Apr 17, 2021
1 parent 724bf7a commit 17de01a
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 0 deletions.
1 change: 1 addition & 0 deletions graphics/Makefile
Expand Up @@ -898,6 +898,7 @@
SUBDIR += py-tifffile
SUBDIR += py-toyplot
SUBDIR += py-traitsui
SUBDIR += py-ueberzug
SUBDIR += py-urbanaccess
SUBDIR += py-urbansim
SUBDIR += py-utm
Expand Down
36 changes: 36 additions & 0 deletions graphics/py-ueberzug/Makefile
@@ -0,0 +1,36 @@
PORTNAME= ueberzug
DISTVERSION= 18.1.8
CATEGORIES= graphics python
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}

MAINTAINER= 0mp@FreeBSD.org
COMMENT= Draw images on terminals with X11 child windows

LICENSE= GPLv3+
LICENSE_FILE= ${WRKSRC}/LICENSE

RUN_DEPENDS= ${PY_PILLOW} \
${PYTHON_PKGNAMEPREFIX}attrs>=18.2.0:devel/py-attrs@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}docopt>=0:devel/py-docopt@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}psutil>=0:sysutils/py-psutil@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}xlib>=0:x11-toolkits/py-xlib@${PY_FLAVOR}

USES= localbase python:3.6+ shebangfix xorg
USE_GITHUB= yes
GH_ACCOUNT= seebye
USE_PYTHON= autoplist concurrent distutils
USE_XORG= x11 xext
SHEBANG_GLOB= *.py *.sh

PORTEXAMPLES= fzfimg.sh mastodon.sh

OPTIONS_DEFINE= EXAMPLES

post-install:
${STRIP_CMD} ${STAGEDIR}${PYTHON_SITELIBDIR}/Xshm.so

post-install-EXAMPLES-on:
${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
${INSTALL_DATA} ${WRKSRC}/examples/* ${STAGEDIR}${EXAMPLESDIR}

.include <bsd.port.mk>
3 changes: 3 additions & 0 deletions graphics/py-ueberzug/distinfo
@@ -0,0 +1,3 @@
TIMESTAMP = 1618660681
SHA256 (seebye-ueberzug-18.1.8_GH0.tar.gz) = a9fbe22e2ad59f42b148f184af808d6106ae504d9b19797385f2714a6351dbcb
SIZE (seebye-ueberzug-18.1.8_GH0.tar.gz) = 50646
20 changes: 20 additions & 0 deletions graphics/py-ueberzug/files/patch-ueberzug_query__windows.py
@@ -0,0 +1,20 @@
--- ueberzug/query_windows.py.orig 2021-04-17 15:12:52 UTC
+++ ueberzug/query_windows.py
@@ -2,6 +2,7 @@ import os
import signal
import errno

+import psutil

def get_command(pid):
"""Figures out the associated command name
@@ -13,8 +14,7 @@ def get_command(pid):
Returns:
str: the associated command name
"""
- with open('/proc/{}/comm'.format(pid), 'r') as commfile:
- return '\n'.join(commfile.readlines())
+ psutil.Process(pid=pid).name()


def is_same_command(pid0, pid1):
16 changes: 16 additions & 0 deletions graphics/py-ueberzug/files/patch-ueberzug_xutil.py
@@ -0,0 +1,16 @@
--- ueberzug/xutil.py.orig 2021-04-17 13:57:48 UTC
+++ ueberzug/xutil.py
@@ -147,10 +147,9 @@ def get_first_pty(pids: list):
the first process in the passed list which owns one.
"""
for pid in pids:
- pty_candidate = '/proc/{pid}/fd/1'.format(pid=pid)
- with open(pty_candidate) as pty:
- if os.isatty(pty.fileno()):
- return pty_candidate
+ process = psutil.Process(pid=pid)
+ if process is not None and process.terminal() is not None:
+ return process.terminal()

return None

13 changes: 13 additions & 0 deletions graphics/py-ueberzug/pkg-descr
@@ -0,0 +1,13 @@
Überzug is a command line util which allows to draw images on terminals by
using child windows.

Advantages to w3mimgdisplay:
- no race conditions as a new window is created to display images
- expose events will be processed,
- so images will be redrawn on switch workspaces
- tmux support (excluding multi pane windows)
- terminals without the WINDOWID environment variable are supported
- chars are used as position - and size unit
- no memory leak (/ unlimited cache)

WWW: https://github.com/seebye/ueberzug

0 comments on commit 17de01a

Please sign in to comment.