mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-29 02:15:36 -04:00
[displaymanager] Begin refactoring DM
- Introduce a base-class to "do the stuff" for one specific display manager / desktop environment.
This commit is contained in:
parent
c3cef4d919
commit
76a7c439c1
1 changed files with 30 additions and 12 deletions
|
@ -23,16 +23,41 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import abc
|
||||||
import os
|
import os
|
||||||
import collections
|
|
||||||
import re
|
import re
|
||||||
import libcalamares
|
import libcalamares
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
|
|
||||||
DesktopEnvironment = collections.namedtuple(
|
class DesktopEnvironment(metaclass=abc.ABCMeta):
|
||||||
'DesktopEnvironment', ['executable', 'desktop_file']
|
"""
|
||||||
)
|
Desktop Environment base class. A subclass
|
||||||
|
implements DE maintainence for a specific DE.
|
||||||
|
"""
|
||||||
|
executable = None
|
||||||
|
desktop_file = None
|
||||||
|
|
||||||
|
def find_desktop_environment(self, root_mount_point):
|
||||||
|
"""
|
||||||
|
Check if this environment is installed in the
|
||||||
|
target system at @p root_mount_point.
|
||||||
|
"""
|
||||||
|
return (
|
||||||
|
os.path.exists("{!s}{!s}".format(root_mount_point, self.executable)) and
|
||||||
|
os.path.exists("{!s}/usr/share/xsessions/{!s}.desktop".format(root_mount_point, self.desktop_file))
|
||||||
|
)
|
||||||
|
|
||||||
|
def __init__(self, exec, desktop):
|
||||||
|
self.executable = exec
|
||||||
|
self.desktop_file = desktop
|
||||||
|
|
||||||
|
# Collect all the subclasses of DesktopEnvironment defined above,
|
||||||
|
desktop_environments = [
|
||||||
|
c for c in globals().values()
|
||||||
|
if type(c) is abc.ABCMeta and issubclass(c, DesktopEnvironment) and c.desktop_file
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
desktop_environments = [
|
desktop_environments = [
|
||||||
DesktopEnvironment('/usr/bin/startkde', 'plasma'), # KDE Plasma 5
|
DesktopEnvironment('/usr/bin/startkde', 'plasma'), # KDE Plasma 5
|
||||||
|
@ -63,14 +88,7 @@ def find_desktop_environment(root_mount_point):
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
for desktop_environment in desktop_environments:
|
for desktop_environment in desktop_environments:
|
||||||
if (os.path.exists("{!s}{!s}".format(
|
if desktop_environment.find_desktop_environment(root_mount_point):
|
||||||
root_mount_point, desktop_environment.executable
|
|
||||||
)
|
|
||||||
) and os.path.exists(
|
|
||||||
"{!s}/usr/share/xsessions/{!s}.desktop".format(
|
|
||||||
root_mount_point, desktop_environment.desktop_file
|
|
||||||
)
|
|
||||||
)):
|
|
||||||
return desktop_environment
|
return desktop_environment
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue