xiwrap

slightly higher-level container setup utility
git clone https://git.ce9e.org/xiwrap.git

commit
317b6ad68d1d91c027bdefb6af561cc536d6bf27
parent
4fb20964970f19c1438c7ac69cd6fec75a08548f
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2024-06-20 13:40
rename import to include

Diffstat

M PKGBUILD 2 +-
R rules/audio -> includes/audio 0
R rules/base -> includes/base 2 +-
A includes/default 3 +++
R rules/env-lang -> includes/env-lang 0
R rules/gui -> includes/gui 2 +-
R rules/host-os -> includes/host-os 0
R rules/network -> includes/network 0
R rules/portal -> includes/portal 0
D rules/default 3 ---
M xiwrap.py 19 +++++++++++--------

11 files changed, 17 insertions, 14 deletions


diff --git a/PKGBUILD b/PKGBUILD

@@ -15,7 +15,7 @@ depends=(
   15    15 package() {
   16    16 	install -Dm 755 xiwrap.py "$pkgdir/usr/bin/xiwrap"
   17    17 	install -Dm 644 README.md "$pkgdir/usr/share/docs/xiwrap/README.md"
   18    -1 	git ls-files rules | while read -r l; do
   -1    18 	git ls-files includes | while read -r l; do
   19    19 		install -Dm 644 "$l" "$pkgdir/etc/xiwrap/$l"
   20    20 	done
   21    21 }

diff --git a/rules/audio b/includes/audio

diff --git a/rules/base b/includes/base

@@ -1,4 +1,4 @@
    1    -1 import env-lang
   -1     1 include env-lang
    2     2 setenv TERM
    3     3 setenv USER
    4     4 setenv HOME

diff --git a/includes/default b/includes/default

@@ -0,0 +1,3 @@
   -1     1 include base
   -1     2 include host-os
   -1     3 include portal

diff --git a/rules/env-lang b/includes/env-lang

diff --git a/rules/gui b/includes/gui

@@ -20,4 +20,4 @@ bind-try $XDG_CACHE_HOME/thumbnails
   20    20 dbus-talk org.a11y.Bus
   21    21 
   22    22 setenv GTK_USE_PORTAL 1
   23    -1 import portal
   -1    23 include portal

diff --git a/rules/host-os b/includes/host-os

diff --git a/rules/network b/includes/network

diff --git a/rules/portal b/includes/portal

diff --git a/rules/default b/rules/default

@@ -1,3 +0,0 @@
    1    -1 import base
    2    -1 import host-os
    3    -1 import portal

diff --git a/xiwrap.py b/xiwrap.py

@@ -7,7 +7,7 @@ from pathlib import Path
    7     7 
    8     8 USAGE = """Usage: xiwrap [OPTION]... -- CMD
    9     9 
   10    -1 Example: xiwrap --import host-os --setenv TERM -- bash
   -1    10 Example: xiwrap --include host-os --setenv TERM -- bash
   11    11 
   12    12 The following options are available:
   13    13 
@@ -34,11 +34,12 @@ The following options are available:
   34    34 --dbus-call NAME=RULE   Set a rule for method calls on NAME.
   35    35 --dbus-broadcast NAME=RULE
   36    36                         Set a rule for broadcast signals from NAME.
   37    -1 --import FILE           Load additional options from FILE. FILE can be an
   -1    37 --include FILE          Load additional options from FILE. FILE can be an
   38    38                         absolute path or relative to the current directory,
   39    -1                         $XDG_CONFIG_HOME/xiwrap/ or /etc/xiwrap/. FILE must
   40    -1                         contain one option per line, without the leading --.
   41    -1                         Empty lines or lines starting with # are ignored.
   -1    39                         $XDG_CONFIG_HOME/xiwrap/includes/ or
   -1    40                         /etc/xiwrap/includes/. FILE must contain one option per
   -1    41                         line, without the leading --. Empty lines or lines
   -1    42                         starting with # are ignored.
   42    43 """
   43    44 
   44    45 DBUS_SRC = f'{os.environ["XDG_RUNTIME_DIR"]}/dbus-proxy-{os.getpid()}'
@@ -92,8 +93,10 @@ class RuleSet:
   92    93         self.sync_fds = None
   93    94         self.debug = False
   94    95         self.usage = False
   95    -1         self.userconfig = Path(expandvars('$XDG_CONFIG_HOME/xiwrap', os.environ))
   96    -1         self.sysconfig = Path('/etc/xiwrap')
   -1    96         self.userconfig = Path(
   -1    97             expandvars('$XDG_CONFIG_HOME/xiwrap/includes', os.environ)
   -1    98         )
   -1    99         self.sysconfig = Path('/etc/xiwrap/includes')
   97   100 
   98   101     def find_config_file(self, name, cwd):
   99   102         if name.startswith('/'):
@@ -129,7 +132,7 @@ class RuleSet:
  129   132         self.push_rule('ro-bind', [DBUS_SRC, DBUS_DEST], cwd=None)
  130   133 
  131   134     def push_rule(self, key, args, *, cwd):
  132    -1         if key == 'import':
   -1   135         if key == 'include':
  133   136             if len(args) != 1:
  134   137                 raise RuleError(key, args)
  135   138             path = self.find_config_file(args[0], cwd)