Merge lp:~3v1n0/unity/migrate-lowgfx-settings into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 4264
Proposed branch: lp:~3v1n0/unity/migrate-lowgfx-settings
Merge into: lp:unity
Diff against target: 111 lines (+97/-1)
2 files modified
debian/unity.migrations (+2/-1)
tools/migration-scripts/06_unity_set_lowgfx_mode_settings_v1 (+95/-0)
To merge this branch: bzr merge lp:~3v1n0/unity/migrate-lowgfx-settings
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+333786@code.launchpad.net

Commit message

tools: add migration script to set the default values for unity-lowgfx profile

Compiz migration scripts are tricky and non always functional, this is safer
and known to work.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/unity.migrations'
2--- debian/unity.migrations 2017-10-02 19:13:36 +0000
3+++ debian/unity.migrations 2017-11-16 03:25:38 +0000
4@@ -2,4 +2,5 @@
5 tools/migration-scripts/02_unity_setup_text_scale_factor
6 tools/migration-scripts/03_unity_first_run_stamp_move
7 tools/migration-scripts/04_unity_update_software_center_desktop_file
8-tools/migration-scripts/05_unity_use_ubuntu_scaling_settings_schemas
9\ No newline at end of file
10+tools/migration-scripts/05_unity_use_ubuntu_scaling_settings_schemas
11+tools/migration-scripts/06_unity_set_lowgfx_mode_settings_v1
12
13=== added file 'tools/migration-scripts/06_unity_set_lowgfx_mode_settings_v1'
14--- tools/migration-scripts/06_unity_set_lowgfx_mode_settings_v1 1970-01-01 00:00:00 +0000
15+++ tools/migration-scripts/06_unity_set_lowgfx_mode_settings_v1 2017-11-16 03:25:38 +0000
16@@ -0,0 +1,95 @@
17+#!/usr/bin/python3
18+# -*- coding: utf-8 -*-
19+# Copyright (C) 2017 Canonical
20+#
21+# Authors:
22+# Marco Trevisan <marco.trevisan@canonical.com>
23+#
24+# This program is free software; you can redistribute it and/or modify it under
25+# the terms of the GNU General Public License as published by the Free Software
26+# Foundation; version 3.
27+#
28+# This program is distributed in the hope that it will be useful, but WITHOUTa
29+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
30+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
31+# details.
32+#
33+# You should have received a copy of the GNU General Public License along with
34+# this program; if not, write to the Free Software Foundation, Inc.,
35+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
36+
37+from gi.repository import Gio, GLib
38+import sys
39+
40+COMPIZ_SCHEMA = "org.compiz"
41+COMPIZ_PROFILE_PATH = "/org/compiz/profiles/unity-lowgfx/plugins/{}/"
42+LOWGFX_OPTIONS = {
43+ "ezoom": {"speed": 100.0},
44+
45+ "expo": {"expo-animation": 3},
46+
47+ "fade": {"fade-mode": 1,
48+ "fade-time": 1},
49+
50+ "grid": {"animation-duration": 0,
51+ "draw-stretched-window": False},
52+
53+ "move": {"mode": 2,
54+ "lazy-positioning": True,
55+ "increase-border-contrast": True},
56+
57+ "resize": {"mode": 2,
58+ "increase-border-contrast": True},
59+
60+ "opengl": {"texture-filter": 0},
61+
62+ "scale": {"skip-animation": True},
63+
64+ "unityshell": {"dash-blur-experimental": 0,
65+ "override-decoration-theme": True,
66+ "shadow-x-offset": 1,
67+ "shadow-y-offset": 1,
68+ "active-shadow-radius": 3,
69+ "inactive-shadow-radius": 2,
70+ "menus-fadein": 0,
71+ "menus-fadeout": 0,
72+ "menus-discovery-fadein": 0,
73+ "menus-discovery-fadeout": 0,
74+ "autohide-animation": 1},
75+
76+ "wall": {"slide-duration": 0.0},
77+
78+ "showdesktop": {"skip-animation": True},
79+}
80+
81+
82+def get_variant_from_python(value):
83+ if type(value) == str:
84+ return GLib.Variant.new_string(value)
85+ elif type(value) == bool:
86+ return GLib.Variant.new_boolean(value)
87+ elif type(value) == int:
88+ return GLib.Variant.new_int32(value)
89+ elif type(value) == float:
90+ return GLib.Variant.new_double(value)
91+
92+
93+if COMPIZ_SCHEMA not in Gio.Settings.list_schemas():
94+ print("No compiz schemas found, no migration needed")
95+ sys.exit(0)
96+
97+for plugin in LOWGFX_OPTIONS:
98+ plugin_options = LOWGFX_OPTIONS[plugin]
99+ plugin_path = COMPIZ_PROFILE_PATH.format(plugin)
100+
101+ try:
102+ plugin_settings = Gio.Settings(
103+ schema=COMPIZ_SCHEMA + ".{}".format(plugin), path=plugin_path)
104+
105+ for setting in plugin_options:
106+ value = get_variant_from_python(plugin_options[setting])
107+ plugin_settings.set_value(setting, value)
108+ except:
109+ print("Can't update settings for plugin '{}".format(plugin))
110+
111+Gio.Settings.sync()