From d57dc94d9e999594cdcab432b9222b5c25330557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 18 Jul 2018 19:27:29 +0200 Subject: [PATCH] tools: Migrate changed overrides settings While the new per-desktop overrides in GIO are easier to use for both developers and users, it is still inconvenient for everyone who changed the defaults using the old overrides hack to lose their settings. Address this by running a small script on startup that migrates existing settings. https://bugzilla.gnome.org/show_bug.cgi?id=786496 --- ...gnome-shell-overrides-migration.desktop.in | 5 +++ data/meson.build | 9 +++++ meson.build | 3 ++ tools/gnome-shell-overrides-migration.sh | 38 +++++++++++++++++++ tools/meson.build | 4 ++ 5 files changed, 59 insertions(+) create mode 100644 data/gnome-shell-overrides-migration.desktop.in create mode 100755 tools/gnome-shell-overrides-migration.sh create mode 100644 tools/meson.build diff --git a/data/gnome-shell-overrides-migration.desktop.in b/data/gnome-shell-overrides-migration.desktop.in new file mode 100644 index 000000000..8ef86ac34 --- /dev/null +++ b/data/gnome-shell-overrides-migration.desktop.in @@ -0,0 +1,5 @@ +[Desktop Entry] +Type=Application +Name=GNOME settings overrides migration +NoDisplay=True +Exec=@libexecdir@/gnome-shell-overrides-migration.sh diff --git a/data/meson.build b/data/meson.build index de2e2053c..68e3ab81f 100644 --- a/data/meson.build +++ b/data/meson.build @@ -94,6 +94,15 @@ schema = configure_file( ) install_data('00_org.gnome.shell.gschema.override', install_dir: schemadir) +overrides_migration_conf = configuration_data() +overrides_migration_conf.set('libexecdir', libexecdir) +overrides_migration = configure_file( + input: 'gnome-shell-overrides-migration.desktop.in', + output: 'gnome-shell-overrides-migration.desktop', + configuration: overrides_migration_conf, + install_dir: autostartdir +) + if have_systemd unitconf = configuration_data() unitconf.set('bindir', bindir) diff --git a/meson.build b/meson.build index ad513a665..045684902 100644 --- a/meson.build +++ b/meson.build @@ -44,10 +44,12 @@ datadir = join_paths(prefix, get_option('datadir')) libdir = join_paths(prefix, get_option('libdir')) libexecdir = join_paths(prefix, get_option('libexecdir')) mandir = join_paths(prefix, get_option('mandir')) +sysconfdir = join_paths(prefix, get_option('sysconfdir')) pkgdatadir = join_paths(datadir, meson.project_name()) pkglibdir = join_paths(libdir, meson.project_name()) +autostartdir = join_paths(sysconfdir, 'xdg', 'autostart') convertdir = join_paths(datadir, 'GConf', 'gsettings') desktopdir = join_paths(datadir, 'applications') ifacedir = join_paths(datadir, 'dbus-1', 'interfaces') @@ -203,6 +205,7 @@ subdir('src') subdir('po') subdir('data') subdir('tests') +subdir('tools') if get_option('gtk_doc') subdir('docs/reference') diff --git a/tools/gnome-shell-overrides-migration.sh b/tools/gnome-shell-overrides-migration.sh new file mode 100755 index 000000000..a1b4cb633 --- /dev/null +++ b/tools/gnome-shell-overrides-migration.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +PKG_DATA_DIR=${XDG_DATA_HOME:-$HOME/.local/share}/gnome-shell + +MIGRATION_GUARD=$PKG_DATA_DIR/gnome-overrides-migrated +OVERRIDE_SCHEMA= + +if [ -f $MIGRATION_GUARD ]; then + exit # already migrated +fi + +# Find the right session +if echo $XDG_CURRENT_DESKTOP | grep -q -v GNOME; then + exit # not a GNOME session +fi + +if echo $XDG_CURRENT_DESKTOP | grep -q Classic; then + OVERRIDE_SCHEMA=org.gnome.shell.extensions.classic-overrides +else + OVERRIDE_SCHEMA=org.gnome.shell.overrides +fi + +mkdir -p $PKG_DATA_DIR + +for k in `gsettings list-keys $OVERRIDE_SCHEMA` +do + if [ $k = button-layout ]; then + orig_schema=org.gnome.desktop.wm.preferences + else + orig_schema=org.gnome.mutter + fi + + oldValue=`gsettings get $OVERRIDE_SCHEMA $k` + curValue=`gsettings get $orig_schema $k` + if [ $oldValue != $curValue ]; then + gsettings set $orig_schema $k $oldValue + fi +done && touch $MIGRATION_GUARD diff --git a/tools/meson.build b/tools/meson.build new file mode 100644 index 000000000..d8e217cc4 --- /dev/null +++ b/tools/meson.build @@ -0,0 +1,4 @@ +install_data('gnome-shell-overrides-migration.sh', + install_dir: libexecdir, + install_mode: 'rwxr-xr-x' +)