Skip to content

Commit 7c431dd

Browse files
committed
Update version
1 parent 695b4a2 commit 7c431dd

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
setup(
1313
name=name,
14-
version='1.12',
14+
version='1.13',
1515
description='Program to run plugins to inhibit system '
1616
'sleep/suspend/hibernate',
1717
long_description=here.joinpath('README.md').read_text(),

sleep_inhibitor.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Plugin:
3030
loglock = threading.Lock()
3131
threads = []
3232

33-
def __init__(self, index, prog, conf, plugin_dir, inhibitor_prog):
33+
def __init__(self, index, prog, name, conf, plugin_dir, inhibitor_prog):
3434
'Constructor'
3535
pathstr = conf.get('path')
3636
if not pathstr:
@@ -69,7 +69,7 @@ def __init__(self, index, prog, conf, plugin_dir, inhibitor_prog):
6969
# While inhibiting, we run outself again via systemd-inhibit to
7070
# run the plugin in a loop which keeps the inhibit on while the
7171
# inhibit state is returned.
72-
self.icmd = shlex.split(f'{inhibitor_prog}{what} --who="{prog.name}" '
72+
self.icmd = shlex.split(f'{inhibitor_prog}{what} --who="{name}" '
7373
f'--why="{self.name}" {prog} -s {self.period} -i "{cmd}"')
7474

7575
print(f'{self.name} [{path}] configured @ {period} minutes')
@@ -137,6 +137,7 @@ def init():
137137
sys.exit(res.returncode)
138138

139139
prog = Path(sys.argv[0]).resolve()
140+
name = prog.stem.replace('_', '-')
140141

141142
# Work out what sleep inhibitor program to use
142143
inhibitor_prog = None
@@ -149,28 +150,28 @@ def init():
149150
continue
150151

151152
vers = res.stdout.split('\n')[0].strip()
152-
print(f'{prog.name} using {iprog}, {vers}')
153+
print(f'{name} using {iprog}, {vers}')
153154
inhibitor_prog = iprog
154155

155156
if not inhibitor_prog:
156157
opts = ' or '.join(SYSTEMD_SLEEP_PROGS)
157158
sys.exit(f'No systemd-inhibitor app installed from one of {opts}.')
158159

159160
# Work out plugin and base dirs for this installation
160-
plugin_dir = Path(sys.prefix) / 'share' / prog.name / 'plugins'
161+
plugin_dir = Path(sys.prefix) / 'share' / name / 'plugins'
161162
if plugin_dir.exists():
162163
base_dir = plugin_dir.parent
163164
else:
164165
plugin_dir = None
165166
base_dir = None
166167

167168
# Determine config file path
168-
cname = prog.name + '.conf'
169+
cname = name + '.conf'
169170
cfile = Path(args.config).expanduser() if args.config else \
170171
Path(f'/etc/{cname}')
171172

172173
if not cfile.exists():
173-
print(f'{prog.name} configuration file {cfile} does not exist.',
174+
print(f'{name} configuration file {cfile} does not exist.',
174175
file=sys.stderr)
175176
if base_dir and not args.config:
176177
print(f'Copy {base_dir}/{cname} to /etc and edit appropriately.',
@@ -189,7 +190,7 @@ def init():
189190

190191
# Iterate to create each configured plugins
191192
for index, plugin in enumerate(plugins, 1):
192-
Plugin(index, prog, plugin, plugin_dir, inhibitor_prog)
193+
Plugin(index, prog, name, plugin, plugin_dir, inhibitor_prog)
193194

194195
def main():
195196
'Main entry'

0 commit comments

Comments
 (0)