@@ -30,7 +30,7 @@ class Plugin:
30
30
loglock = threading .Lock ()
31
31
threads = []
32
32
33
- def __init__ (self , index , prog , name , conf , plugin_dir , inhibitor_prog ):
33
+ def __init__ (self , index , prog , progname , conf , plugin_dir , inhibitor_prog ):
34
34
'Constructor'
35
35
pathstr = conf .get ('path' )
36
36
if not pathstr :
@@ -69,7 +69,7 @@ def __init__(self, index, prog, name, conf, plugin_dir, inhibitor_prog):
69
69
# While inhibiting, we run outself again via systemd-inhibit to
70
70
# run the plugin in a loop which keeps the inhibit on while the
71
71
# inhibit state is returned.
72
- self .icmd = shlex .split (f'{ inhibitor_prog } { what } --who="{ name } " '
72
+ self .icmd = shlex .split (f'{ inhibitor_prog } { what } --who="{ progname } " '
73
73
f'--why="{ self .name } " { prog } -s { self .period } -i "{ cmd } "' )
74
74
75
75
print (f'{ self .name } [{ path } ] configured @ { period } minutes' )
@@ -137,7 +137,7 @@ def init():
137
137
sys .exit (res .returncode )
138
138
139
139
prog = Path (sys .argv [0 ]).resolve ()
140
- name = prog .stem .replace ('_' , '-' )
140
+ progname = prog .stem .replace ('_' , '-' )
141
141
142
142
# Work out what sleep inhibitor program to use
143
143
inhibitor_prog = None
@@ -150,29 +150,28 @@ def init():
150
150
continue
151
151
152
152
vers = res .stdout .split ('\n ' )[0 ].strip ()
153
- print (f'{ name } using { iprog } , { vers } ' )
153
+ print (f'{ progname } using { iprog } , { vers } ' )
154
154
inhibitor_prog = iprog
155
155
156
156
if not inhibitor_prog :
157
157
opts = ' or ' .join (SYSTEMD_SLEEP_PROGS )
158
158
sys .exit (f'No systemd-inhibitor app installed from one of { opts } .' )
159
159
160
160
# Work out plugin and base dirs for this installation
161
- plugin_dir = Path (sys .prefix ) / 'share' / name / 'plugins'
161
+ plugin_dir = Path (sys .prefix ) / 'share' / progname / 'plugins'
162
162
if plugin_dir .exists ():
163
163
base_dir = plugin_dir .parent
164
164
else :
165
165
plugin_dir = None
166
166
base_dir = None
167
167
168
168
# Determine config file path
169
- cname = name + '.conf'
169
+ cname = progname + '.conf'
170
170
cfile = Path (args .config ).expanduser () if args .config else \
171
171
Path (f'/etc/{ cname } ' )
172
172
173
173
if not cfile .exists ():
174
- print (f'{ name } configuration file { cfile } does not exist.' ,
175
- file = sys .stderr )
174
+ print (f'Configuration file { cfile } does not exist.' , file = sys .stderr )
176
175
if base_dir and not args .config :
177
176
print (f'Copy { base_dir } /{ cname } to /etc and edit appropriately.' ,
178
177
file = sys .stderr )
@@ -190,7 +189,7 @@ def init():
190
189
191
190
# Iterate to create each configured plugins
192
191
for index , plugin in enumerate (plugins , 1 ):
193
- Plugin (index , prog , name , plugin , plugin_dir , inhibitor_prog )
192
+ Plugin (index , prog , progname , plugin , plugin_dir , inhibitor_prog )
194
193
195
194
def main ():
196
195
'Main entry'
0 commit comments