aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-03-08 23:54:13 +0100
committerMattias Andrée <maandree@operamail.com>2014-03-08 23:54:13 +0100
commit31ffb35e2dbae7ed5d40dac9932f9a538a782749 (patch)
tree6d0ea69641b7151d17954fa42cb202199c386708 /src
parentuptime demo (diff)
downloadxpybar-31ffb35e2dbae7ed5d40dac9932f9a538a782749.tar.gz
xpybar-31ffb35e2dbae7ed5d40dac9932f9a538a782749.tar.bz2
xpybar-31ffb35e2dbae7ed5d40dac9932f9a538a782749.tar.xz
fix xdisplay bug for the case where DISPLAY is not set + xdisplay demo
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/plugins/xdisplay.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/plugins/xdisplay.py b/src/plugins/xdisplay.py
index cba245a..907b6bf 100644
--- a/src/plugins/xdisplay.py
+++ b/src/plugins/xdisplay.py
@@ -26,13 +26,17 @@ from x import *
class XDisplay:
'''
- Retrieve information about the used X display
+ Retrieve information about the used X display as specified by the DISPLAY environment variable
@variable connection:str? The full X display information, `None` if X is not running
@variable host:str? The host, often `None` one local conncetions and "localhost" on remote oonnection
- @variable display:int The display number
- @variable screen:int? The screen number, often `None`
+ @variable display:int? The display number
+ @variable screen:int? The screen number, often `None` (default screen)
@varaible vt:int The VT the X display is allocated to
+
+ host, dispay and screen is None if connectiopn is None, which means that you
+ have started xpybar's DISPLAY environment variable is not set, and that a display
+ was configured in the settings.
'''
@@ -41,12 +45,17 @@ class XDisplay:
Constructor
'''
self.connection = os.environ['DISPLAY'] if 'DISPLAY' in os.environ else None
- self.host = self.connection.split(':')[0]
- if self.host == '':
+ if self.connection is None:
self.host = None
- self.display, self.screen = (self.connection.split(':')[1] + '.').split('.')[:2]
- self.display = int(self.display)
- self.screen = None if self.screen == '' else int(self.screen)
+ self.display = None
+ self.screen = None
+ else:
+ self.host = self.connection.split(':')[0]
+ if self.host == '':
+ self.host = None
+ self.display, self.screen = (self.connection.split(':')[1] + '.').split('.')[:2]
+ self.display = int(self.display)
+ self.screen = None if self.screen == '' else int(self.screen)
r = get_screen().root
d = get_display()
self.vt = r.get_full_property(d.get_atom('XFree86_VT'), Xlib.Xatom.INTEGER).value[0]