/usr/share/pyshared/bootconfig/splashy.py is in startupmanager 1.9.13-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | # -*- coding: utf-8 -*-
# Copyright (c) 2007 Jimmy Rönnholm
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import os
import re
from subprocess import Popen, PIPE
from bootconfig import utils
class Splashy:
"""Represent the Splashy configuration."""
def __init__(self):
"""Set the variables"""
self.binary = '/sbin/splashy'
self.config_command = '/sbin/splashy_config'
self.config_file = '/etc/default/splashy'
self.update_initramfs_command = 'update-initramfs -uk all'
if not os.path.isfile(self.binary):
raise SystemExit('Splashy not found.')
self.update_initramfs = False
self.must_update_initramfs = False
def __get_info_lines(self):
"""Get info from splashy."""
cmd = self.config_command + ' --info'
pipe = Popen(cmd, shell=True, stdout=PIPE).stdout
return pipe.readlines()
def get_active_theme(self):
"""Return the name of the currently active Splashy theme."""
lines = self.__get_info_lines()
# This has the potential to break if splashy output change.
return lines[1].strip()
def set_active_theme(self, name):
"""Set the active Splashy theme."""
cmd = self.config_command + ' --set-theme ' + name
os.system(cmd)
self.update_initramfs = True
def get_all_themes(self):
"""Return a list of the available themes.
Return -1 if failed.
"""
lines = self.__get_info_lines()
lines.reverse()
themes = []
for line in lines:
if line[:4] != " ":
themes.reverse()
return themes
themes.append(line.strip())
return -1
def add_theme(self, path):
"""Add theme from path."""
path = utils.fix_filename_spaces(path)
cmd = self.config_command + ' --install-theme ' + path
os.system(cmd)
def remove_theme(self, name):
"""Remove theme."""
cmd = self.config_command + ' --remove-theme ' + name
os.system(cmd)
def show_preview(self):
"""Show a preview of splashy."""
cmd = self.binary + ' test'
os.system(cmd)
def get_use_initramfs(self):
"""Return whether Splashy is being put into initramfs."""
lines = utils.read_lines_from_file(self.config_file)
line_number = utils.get_line_number(self.config_file, 'ENABLE_INITRAMFS=')
if line_number != -1:
line = lines[line_number]
number_filter = re.compile('[0-9]+')
match = number_filter.search(line[17:])
if match:
if match.group() == '1':
return True
return False
def set_use_initramfs(self, active):
"""Set whether Splashy should be put into initramfs."""
identifier = 'ENABLE_INITRAMFS='
if active:
line_end = '1'
else:
line_end = '0'
lines = utils.read_lines_from_file(self.config_file)
line_number = utils.get_line_number(self.config_file, identifier)
if line_number == -1:
lines.append('\n')
line_number = len(lines) - 1
line = identifier + line_end + '\n'
lines[line_number] = line
utils.write_lines_to_file(self.config_file, lines)
self.must_update_initramfs = True
def do_shutdown_tasks(self):
"""Do any post-config tasks necessary."""
if self.must_update_initramfs:
os.system(self.update_initramfs_command)
elif self.get_use_initramfs():
if self.update_initramfs:
os.system(self.update_initramfs_command)
|