lemonbar: Attempt to restart i3ws connection 5 times with increasing delay
This commit is contained in:
@@ -414,7 +414,10 @@ class i3Module(LemonModule):
|
|||||||
common.logger.info('Started module {}'.format(self.__class__.__name__))
|
common.logger.info('Started module {}'.format(self.__class__.__name__))
|
||||||
common.health_logger.info('Module {} up'.format(self.__class__.__name__))
|
common.health_logger.info('Module {} up'.format(self.__class__.__name__))
|
||||||
|
|
||||||
self.i3_ws_obj.work() # This is a blocking command
|
try:
|
||||||
|
self.i3_ws_obj.work() # This is a blocking command
|
||||||
|
except ConnectionError:
|
||||||
|
common.logger.info('i3ws failed connecting to i3 socket')
|
||||||
|
|
||||||
common.logger.info('Reached end of module {}'.format(self.__class__.__name__))
|
common.logger.info('Reached end of module {}'.format(self.__class__.__name__))
|
||||||
common.health_logger.info('Module {} down'.format(self.__class__.__name__))
|
common.health_logger.info('Module {} down'.format(self.__class__.__name__))
|
||||||
@@ -533,7 +536,7 @@ class i3Module(LemonModule):
|
|||||||
else:
|
else:
|
||||||
new_km = self.def_keymap
|
new_km = self.def_keymap
|
||||||
common.logger.debug('Setting default keymap {} for {}'.format(new_km, wclass))
|
common.logger.debug('Setting default keymap {} for {}'.format(new_km, wclass))
|
||||||
subprocess.call(['/home/kuba/.i3/scripts/lang.sh', 'qset', new_km])
|
subprocess.call(['/home/kuba/.i3/scripts/lang.sh', 'qset', new_km]) # TODO it is this script that writes to fifo, triggering the formatting
|
||||||
|
|
||||||
def i3msg_comm(self, *cmd):
|
def i3msg_comm(self, *cmd):
|
||||||
self.i3_ws_obj.command(' '.join(cmd))
|
self.i3_ws_obj.command(' '.join(cmd))
|
||||||
|
|||||||
@@ -68,10 +68,21 @@ class i3ws(object):
|
|||||||
self.logger.debug('Started i3 workspaces manager')
|
self.logger.debug('Started i3 workspaces manager')
|
||||||
self.enterMain()
|
self.enterMain()
|
||||||
self.logger.debug('Finished i3 workspaces manager')
|
self.logger.debug('Finished i3 workspaces manager')
|
||||||
time.sleep(0.5) # TODO max number of attempts + catch exception instead
|
|
||||||
|
|
||||||
def resetConn(self):
|
def resetConn(self):
|
||||||
self.conn = i3ipc.Connection()
|
|
||||||
|
def attempt_connection(attempt):
|
||||||
|
try:
|
||||||
|
self.conn = i3ipc.Connection()
|
||||||
|
except FileNotFoundError:
|
||||||
|
# Thrown when i3 is not up. Should try again in the case of a restart
|
||||||
|
self.logger.debug('Attempt {}: Failed connecting to i3 socket'.format(attempt))
|
||||||
|
if attempt > 5:
|
||||||
|
raise ConnectionError('Could not connect to i3 socked, quitting')
|
||||||
|
time.sleep(0.1 if attempt < 3 else 0.5)
|
||||||
|
attempt_connection(attempt + 1)
|
||||||
|
|
||||||
|
attempt_connection(attempt=1)
|
||||||
self.outputs = self.conn.get_outputs()
|
self.outputs = self.conn.get_outputs()
|
||||||
|
|
||||||
self.conn.on('workspace::focus' , self.change)
|
self.conn.on('workspace::focus' , self.change)
|
||||||
|
|||||||
Reference in New Issue
Block a user