gui.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #
  2. # The Qubes OS Project, https://www.qubes-os.org/
  3. #
  4. # Copyright (C) 2010-2016 Joanna Rutkowska <joanna@invisiblethingslab.com>
  5. # Copyright (C) 2013-2016 Marek Marczykowski-Górecki
  6. # <marmarek@invisiblethingslab.com>
  7. # Copyright (C) 2014-2016 Wojtek Porczyk <woju@invisiblethingslab.com>
  8. #
  9. # This program is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation; either version 2 of the License, or
  12. # (at your option) any later version.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU General Public License along
  20. # with this program; if not, write to the Free Software Foundation, Inc.,
  21. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  22. #
  23. import os
  24. import qubes.config
  25. import qubes.ext
  26. class GUI(qubes.ext.Extension):
  27. @staticmethod
  28. def send_gui_mode(vm):
  29. vm.run_service('qubes.SetGuiMode',
  30. input=('SEAMLESS'
  31. if vm.features.get('gui-seamless', False)
  32. else 'FULLSCREEN'))
  33. @staticmethod
  34. def is_guid_running(vm):
  35. '''Check whether gui daemon for this domain is available.
  36. Notice: this will be irrelevant here, after real splitting GUI/Admin.
  37. :returns: :py:obj:`True` if guid is running, \
  38. :py:obj:`False` otherwise.
  39. :rtype: bool
  40. '''
  41. xid = vm.xid
  42. if xid < 0:
  43. return False
  44. if not os.path.exists('/var/run/qubes/guid-running.{}'.format(xid)):
  45. return False
  46. return True
  47. @qubes.ext.handler('domain-is-fully-usable')
  48. def on_domain_is_fully_usable(self, vm, event):
  49. # pylint: disable=unused-argument
  50. if not self.is_guid_running(vm):
  51. yield False