summaryrefslogtreecommitdiff
diff options
-rw-r--r--debian/unity.migrations3
-rwxr-xr-xtools/migration-scripts/06_unity_set_lowgfx_mode_settings_v195
2 files changed, 97 insertions, 1 deletions
diff --git a/debian/unity.migrations b/debian/unity.migrations
index 98ba87204..0c1cf8887 100644
--- a/debian/unity.migrations
+++ b/debian/unity.migrations
@@ -2,4 +2,5 @@ tools/migration-scripts/01_unity_change_dconf_path
tools/migration-scripts/02_unity_setup_text_scale_factor
tools/migration-scripts/03_unity_first_run_stamp_move
tools/migration-scripts/04_unity_update_software_center_desktop_file
-tools/migration-scripts/05_unity_use_ubuntu_scaling_settings_schemas \ No newline at end of file
+tools/migration-scripts/05_unity_use_ubuntu_scaling_settings_schemas
+tools/migration-scripts/06_unity_set_lowgfx_mode_settings_v1
diff --git a/tools/migration-scripts/06_unity_set_lowgfx_mode_settings_v1 b/tools/migration-scripts/06_unity_set_lowgfx_mode_settings_v1
new file mode 100755
index 000000000..c1313fc52
--- /dev/null
+++ b/tools/migration-scripts/06_unity_set_lowgfx_mode_settings_v1
@@ -0,0 +1,95 @@
+#!/usr/bin/python3
+# -*- coding: utf-8 -*-
+# Copyright (C) 2017 Canonical
+#
+# Authors:
+# Marco Trevisan <marco.trevisan@canonical.com>
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; version 3.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUTa
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+from gi.repository import Gio, GLib
+import sys
+
+COMPIZ_SCHEMA = "org.compiz"
+COMPIZ_PROFILE_PATH = "/org/compiz/profiles/unity-lowgfx/plugins/{}/"
+LOWGFX_OPTIONS = {
+ "ezoom": {"speed": 100.0},
+
+ "expo": {"expo-animation": 3},
+
+ "fade": {"fade-mode": 1,
+ "fade-time": 1},
+
+ "grid": {"animation-duration": 0,
+ "draw-stretched-window": False},
+
+ "move": {"mode": 2,
+ "lazy-positioning": True,
+ "increase-border-contrast": True},
+
+ "resize": {"mode": 2,
+ "increase-border-contrast": True},
+
+ "opengl": {"texture-filter": 0},
+
+ "scale": {"skip-animation": True},
+
+ "unityshell": {"dash-blur-experimental": 0,
+ "override-decoration-theme": True,
+ "shadow-x-offset": 1,
+ "shadow-y-offset": 1,
+ "active-shadow-radius": 3,
+ "inactive-shadow-radius": 2,
+ "menus-fadein": 0,
+ "menus-fadeout": 0,
+ "menus-discovery-fadein": 0,
+ "menus-discovery-fadeout": 0,
+ "autohide-animation": 1},
+
+ "wall": {"slide-duration": 0.0},
+
+ "showdesktop": {"skip-animation": True},
+}
+
+
+def get_variant_from_python(value):
+ if type(value) == str:
+ return GLib.Variant.new_string(value)
+ elif type(value) == bool:
+ return GLib.Variant.new_boolean(value)
+ elif type(value) == int:
+ return GLib.Variant.new_int32(value)
+ elif type(value) == float:
+ return GLib.Variant.new_double(value)
+
+
+if COMPIZ_SCHEMA not in Gio.Settings.list_schemas():
+ print("No compiz schemas found, no migration needed")
+ sys.exit(0)
+
+for plugin in LOWGFX_OPTIONS:
+ plugin_options = LOWGFX_OPTIONS[plugin]
+ plugin_path = COMPIZ_PROFILE_PATH.format(plugin)
+
+ try:
+ plugin_settings = Gio.Settings(
+ schema=COMPIZ_SCHEMA + ".{}".format(plugin), path=plugin_path)
+
+ for setting in plugin_options:
+ value = get_variant_from_python(plugin_options[setting])
+ plugin_settings.set_value(setting, value)
+ except:
+ print("Can't update settings for plugin '{}".format(plugin))
+
+Gio.Settings.sync()