Compare commits

...

3 Commits

@ -0,0 +1,8 @@
# Changelog
## [0.0.2] - 2020-11-03
- Fixed property tree cleaning
- Add simple verbose mode, only prints xfconf-query commands.
## [0.0.1] - 2020-10-01
- Refer to the README for initial features.

@ -1,6 +1,6 @@
[metadata]
name = xion
version = 0.0.1
version = 0.0.2
description = JSON interface to Xfconf
long_description = file: README.md
license = MIT

@ -28,9 +28,13 @@ def main():
"-y", "--yes", action="store_true",
help="Do not ask for confirmation"
)
argparser.add_argument(
"-v", "--verbose", action="store_true",
help="Verbose output"
)
args = argparser.parse_args()
xion = Xion(xq=args.xq_path)
xion = Xion(xq=args.xq_path, verbose=args.verbose)
if args.export:
channel, root, output = args.export
tree = xion.build_tree(channel, root)

@ -1,6 +1,5 @@
import re
import shutil
import string
import subprocess
from dataclasses import dataclass
@ -17,12 +16,15 @@ class Xfconf:
"gchararray": "string",
}
def __init__(self, xq=None):
def __init__(self, xq=None, verbose=False):
self._xq = xq or self.find_xq()
self.verbose = verbose
def xq(self, command, print_failures=True):
"""Run a xion-query command and return its output or None on error."""
command.insert(0, self._xq)
if self.verbose:
print(f"$ {' '.join(command)}")
try:
return subprocess.check_output(
command, stderr=subprocess.STDOUT
@ -107,6 +109,7 @@ class Xfconf:
def reset_root(self, channel, root):
"""Reset all channel properties under root, return True on success."""
root = root.rstrip("/")
output = self.xqs(f"-c {channel} -p {root} -r -R")
return output == ""

@ -6,8 +6,9 @@ from xion.xfconf import Xfconf
class Xion:
"""Manipulate Xfconf settings trees."""
def __init__(self, xq=None):
self.xfconf = Xfconf(xq=xq)
def __init__(self, xq=None, verbose=False):
self.xfconf = Xfconf(xq=xq, verbose=verbose)
self.verbose = verbose
def build_tree(self, channel, root="/"):
"""Return a dict of properties in this channel, filtering on root.

Loading…
Cancel
Save