From 29ccd7fa312a45ed309cb06ecb1b420450099931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radovan=20Garab=C3=ADk?= Date: Wed, 20 Jul 2016 19:52:30 +0200 Subject: [PATCH 1/2] oping --- grc.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grc.conf b/grc.conf index e30814f..f446ddf 100644 --- a/grc.conf +++ b/grc.conf @@ -11,7 +11,7 @@ conf.log conf.configure # ping command -(^|[/\w\.]+/)ping6?\s +(^|[/\w\.]+/)o?ping6?\s conf.ping # traceroute command From 0928d0b936c670b345bf6e66b10516de480df4b1 Mon Sep 17 00:00:00 2001 From: Leonardo Brondani Schenkel Date: Sat, 24 Sep 2016 16:15:36 +0200 Subject: [PATCH 2/2] Support the XDG Base Directory Specification --- grc | 15 +++++++++++---- grcat | 19 ++++++++++++++++--- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/grc b/grc index e0ee182..0091ff3 100755 --- a/grc +++ b/grc @@ -71,10 +71,17 @@ if stdoutf == 1: conffile = None if cfile == "": - home = [] - if 'HOME' in os.environ: - home = [os.environ['HOME']+"/.grc/grc.conf"] - conffilenames = home + ["/etc/grc.conf"] + home = os.environ.get('HOME') + xdg = os.environ.get('XDG_CONFIG_HOME') + if not xdg and home: + xdg = home + '/.config' + + conffilenames = [] + if xdg: + conffilenames += [xdg + '/grc/grc.conf'] + if home: + conffilenames += [home + '/.grc/grc.conf'] + conffilenames += ['/usr/local/etc/grc.conf', '/etc/grc.conf'] for i in conffilenames: if os.path.isfile(i): conffile = i diff --git a/grcat b/grcat index 4187142..5aed820 100755 --- a/grcat +++ b/grcat @@ -84,9 +84,22 @@ def get_colour(x): home = [] conffile = None -if 'HOME' in os.environ: - home = [os.environ['HOME']+"/.grc/"] -conffilepath = [""] + home + ["/usr/local/share/grc/", "/usr/share/grc/"] +xdg_config = os.environ.get('XDG_CONFIG_HOME') +xdg_data = os.environ.get('XDG_DATA_HOME') +home = os.environ.get('HOME') +if home and not xdg_config: + xdg_config = home + '/.config' +if home and not xdg_data: + xdg_data = home + '/.local/share' + +conffilepath = [""] +if xdg_data: + conffilepath += [xdg_data + '/grc/'] +if xdg_config: + conffilepath += [xdg_config + '/grc/'] +if home: + conffilepath += [home + '/.grc/'] +conffilepath += ['/usr/local/share/grc/', '/usr/share/grc/'] if len(sys.argv) != 2: sys.stderr.write("You are not supposed to call grcat directly, but the usage is: grcat conffile\n") sys.exit(1)