File size: 3,033 Bytes
92f480e | 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 | """Restrict the agent's XFCE desktop to Friction and the captioned tutorial."""
from pathlib import Path
import xml.etree.ElementTree as ET
ALLOWED = {"friction.desktop", "tutorial.desktop"}
root = Path("/etc/xdg/xfce4/xfconf/xfce-perchannel-xml")
keyboard = root / "xfce4-keyboard-shortcuts.xml"
tree = ET.parse(keyboard)
tree.getroot().set("locked", "root")
commands = tree.getroot().find("property[@name='commands']")
if commands is not None:
for child in list(commands):
commands.remove(child)
ET.SubElement(commands, "property", name="default", type="empty")
tree.write(keyboard, encoding="UTF-8", xml_declaration=True)
panel = '''<?xml version="1.0" encoding="UTF-8"?>
<channel name="xfce4-panel" version="1.0" locked="root">
<property name="configver" type="int" value="2"/>
<property name="panels" type="array"><value type="int" value="1"/>
<property name="panel-1" type="empty">
<property name="position" type="string" value="p=6;x=0;y=0"/>
<property name="length" type="uint" value="100"/>
<property name="position-locked" type="bool" value="true"/>
<property name="size" type="uint" value="30"/>
<property name="plugin-ids" type="array"><value type="int" value="1"/><value type="int" value="2"/><value type="int" value="3"/></property>
</property>
</property>
<property name="plugins" type="empty">
<property name="plugin-1" type="string" value="launcher"><property name="items" type="array"><value type="string" value="friction.desktop"/></property></property>
<property name="plugin-2" type="string" value="launcher"><property name="items" type="array"><value type="string" value="tutorial.desktop"/></property></property>
<property name="plugin-3" type="string" value="tasklist"><property name="expand" type="bool" value="true"/></property>
</property>
</channel>
'''
(Path("/etc/xdg/xfce4/panel/default.xml")).write_text(panel)
(root / "xfce4-panel.xml").write_text(panel)
(root / "xfce4-desktop.xml").write_text('''<?xml version="1.0" encoding="UTF-8"?>
<channel name="xfce4-desktop" version="1.0" locked="root">
<property name="desktop-menu" type="empty"><property name="show" type="bool" value="false"/></property>
<property name="windowlist-menu" type="empty"><property name="show" type="bool" value="false"/></property>
<property name="desktop-icons" type="empty"><property name="style" type="int" value="2"/></property>
</channel>
''')
user = Path("/root/.config/xfce4/xfconf/xfce-perchannel-xml")
user.mkdir(parents=True, exist_ok=True)
for name in ("xfce4-keyboard-shortcuts.xml", "xfce4-panel.xml", "xfce4-desktop.xml"):
(user / name).write_bytes((root / name).read_bytes())
for folder in ("/usr/share/applications", "/usr/local/share/applications", "/root/Desktop"):
for file in Path(folder).glob("*.desktop"):
if file.name not in ALLOWED:
file.unlink()
for folder in ("/opt/autostart", "/root/.config/autostart"):
for file in Path(folder).glob("*.desktop"):
if "friction" not in file.name:
file.unlink()
|