mirror of
https://github.com/gryf/wmdocklib.git
synced 2025-12-19 20:38:03 +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(
|
||||
|
||||
@@ -18,27 +18,27 @@
|
||||
4.label=cd
|
||||
4.path=/mnt/cd
|
||||
4.displaymode=used
|
||||
4.action=['/home/mario/bin/tmount', '/mnt/cd', 'eject']
|
||||
4.action=eject
|
||||
|
||||
5.label=jr
|
||||
5.path=/mnt/jr
|
||||
5.displaymode=used
|
||||
5.action=['/home/mario/bin/tmount', '/mnt/jr', 'eject']
|
||||
5.action=eject
|
||||
|
||||
6.label=sm
|
||||
6.path=/mnt/sm
|
||||
6.displaymode=free
|
||||
6.action=['/home/mario/bin/tmount', '/mnt/sm']
|
||||
6.action=mount
|
||||
|
||||
7.label=cf
|
||||
7.path=/mnt/cf
|
||||
7.displaymode=free
|
||||
7.action=['/home/mario/bin/tmount', '/mnt/cf']
|
||||
7.action=mount
|
||||
|
||||
8.label=flo
|
||||
8.path=/mnt/flo
|
||||
8.displaymode=free
|
||||
8.action=['/home/mario/bin/tmount', '/mnt/flo']
|
||||
8.action=mount
|
||||
|
||||
textcolor=light sea green
|
||||
background=black
|
||||
|
||||
Reference in New Issue
Block a user