mirror of
https://github.com/gryf/wmdocklib.git
synced 2025-12-19 12:28:10 +01:00
1293220: better format for action
finalmente ho deciso di levare la flessibilità e permettere solo mount/umount/eject. questo semplifica molto il file di configurazione, ovviamente.
This commit is contained in:
@@ -250,11 +250,29 @@ class PywmHDMon:
|
||||
elif event['type'] == 'buttonrelease':
|
||||
area = wmdocklib.checkMouseRegion(event['x'],event['y'])
|
||||
if area is not -1:
|
||||
action = self._pathsToMonitor[area-1+self._skipping][3]
|
||||
if action:
|
||||
os.spawnvp(os.P_NOWAIT, action[0], action)
|
||||
self.toggleMount(area-1+self._skipping)
|
||||
event = wmdocklib.getEvent()
|
||||
|
||||
def toggleMount(self, line):
|
||||
label, path, mode, action = self._pathsToMonitor[line]
|
||||
if action is None:
|
||||
return
|
||||
try:
|
||||
self.getHdInfo(path)
|
||||
mounted = True
|
||||
except NotMounted:
|
||||
mounted = False
|
||||
except OSError, e:
|
||||
return
|
||||
if mounted:
|
||||
if action == 'mount':
|
||||
os.spawnvp(os.P_NOWAIT, 'umount', ['umount', path])
|
||||
elif action == 'eject':
|
||||
os.spawnvp(os.P_WAIT, 'umount', ['umount', path])
|
||||
os.spawnvp(os.P_NOWAIT, 'eject', ['eject', path])
|
||||
else:
|
||||
os.spawnvp(os.P_NOWAIT, 'mount', ['mount', path])
|
||||
|
||||
def updateMonitoredPaths(self):
|
||||
index = 0
|
||||
pageoffset = self._skipping
|
||||
@@ -432,8 +450,9 @@ def main():
|
||||
label = config.get(labelStr)
|
||||
if not label: break
|
||||
path = config.get(pathStr)
|
||||
action = config.get(actionStr)
|
||||
if action: action=eval(action)
|
||||
action = config.get(actionStr, 'fixed').lower().strip()
|
||||
if action not in ['mount', 'eject']:
|
||||
action = None
|
||||
displayMode = config.get(modeStr, defaultMode)
|
||||
if not displayMode in displayModes:
|
||||
sys.stderr.write(
|
||||
|
||||
Reference in New Issue
Block a user