Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package fcitx5-lua-migration-reminder for openSUSE:Factory checked in at 2022-02-13 19:50:53 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/fcitx5-lua-migration-reminder (Old) and /work/SRC/openSUSE:Factory/.fcitx5-lua-migration-reminder.new.1956 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "fcitx5-lua-migration-reminder" Sun Feb 13 19:50:53 2022 rev:2 rq:954037 version:1.0.1 Changes: -------- --- /work/SRC/openSUSE:Factory/fcitx5-lua-migration-reminder/fcitx5-lua-migration-reminder.changes 2022-02-09 20:39:34.782430459 +0100 +++ /work/SRC/openSUSE:Factory/.fcitx5-lua-migration-reminder.new.1956/fcitx5-lua-migration-reminder.changes 2022-02-13 19:51:26.110275422 +0100 @@ -1,0 +2,10 @@ +Sun Feb 13 04:25:32 UTC 2022 - Marguerite Su <i...@marguerite.su> + +- update version 1.0.1 + * use $XDG_CONFIG_HOME instead of hard-coded $HOME/.config + * detect .config/fcitx/config instead of .config/fcitx, because + the later directory is alway there due to fcitx5's fcitx4frontend + module + * fix a memory leak with lua io.close() + +------------------------------------------------------------------- Old: ---- fcitx5-lua-migration-reminder-1.0.0.tar.gz New: ---- fcitx5-lua-migration-reminder-1.0.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ fcitx5-lua-migration-reminder.spec ++++++ --- /var/tmp/diff_new_pack.F6JeZR/_old 2022-02-13 19:51:26.638276830 +0100 +++ /var/tmp/diff_new_pack.F6JeZR/_new 2022-02-13 19:51:26.642276840 +0100 @@ -1,7 +1,7 @@ # # spec file for package fcitx5-lua-migration-reminder # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,15 +17,15 @@ Name: fcitx5-lua-migration-reminder -Version: 1.0.0 +Version: 1.0.1 Release: 0 Summary: Fcitx5 Lua addon to guide users to migrate their fcitx4 configurations License: GPL-3.0-or-later URL: https://github.com/openSUSE-zh/fcitx5-lua-migration-reminder Source: %{name}-%{version}.tar.gz BuildRequires: fcitx5-lua -Requires: fcitx5-lua Requires: fcitx5-configtool +Requires: fcitx5-lua Requires: lua54-lgi # fcitx5-lua was built with lua54 and requires /usr/lib64/liblua5.4.so Requires: lua54-devel ++++++ fcitx5-lua-migration-reminder-1.0.0.tar.gz -> fcitx5-lua-migration-reminder-1.0.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/fcitx5-lua-migration-reminder-1.0.1/LICENSE new/fcitx5-lua-migration-reminder-1.0.1/LICENSE --- old/fcitx5-lua-migration-reminder-1.0.1/LICENSE 1970-01-01 01:00:00.000000000 +0100 +++ new/fcitx5-lua-migration-reminder-1.0.1/LICENSE 2021-12-26 06:41:18.960123977 +0100 @@ -0,0 +1 @@ +GPL-2.0-or-later diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/fcitx5-lua-migration-reminder-1.0.1/README.md new/fcitx5-lua-migration-reminder-1.0.1/README.md --- old/fcitx5-lua-migration-reminder-1.0.1/README.md 1970-01-01 01:00:00.000000000 +0100 +++ new/fcitx5-lua-migration-reminder-1.0.1/README.md 2021-12-26 06:41:18.956123938 +0100 @@ -0,0 +1,15 @@ +## Fcitx5 migration reminder with fcitx5-lua + +This is a simple fcitx5 lua addon that show a reminder to run fcitx5-migrator when you start to type with fcitx5. + +If you click "ok", it will launch fcitx5-migrator, and never bother you any more. + +If you click "cancel", it will remind you the next day until you do the migration. + +It simply checks two files, "~/.config/fcitx4/.migration-complete" and "~/.config/fcitx5/lua/migration-reminder/.timestamp". + +If you have done the migration by yourself, you can just disable this addon :-D. + +This addon is used for openSUSE distribution for fcitx4 to fcitx5 migration. + +It requires "lua-lgi" to run. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/fcitx5-lua-migration-reminder-1.0.1/addon.lua new/fcitx5-lua-migration-reminder-1.0.1/addon.lua --- old/fcitx5-lua-migration-reminder-1.0.1/addon.lua 1970-01-01 01:00:00.000000000 +0100 +++ new/fcitx5-lua-migration-reminder-1.0.1/addon.lua 2022-02-13 05:24:47.043377463 +0100 @@ -0,0 +1,45 @@ +local fcitx = require("fcitx") + +fcitx.watchEvent(fcitx.EventType.KeyEvent, "migrate4to5") + +function migrate4to5(sym, state, release) + local xdg_config_home = os.getenv("XDG_CONFIG_HOME") + local home = os.getenv("HOME") + if xdg_config_home == nil then + xdg_config_home = home .. "/.config" + end + + local path = debug.getinfo(1).source:match("@?(.*/)") + local reminder = "lua " .. path .. "reminder.lua" + local f = io.open(xdg_config_home .. "/fcitx/config", "r") + if f == nil then + return false + else + io.close(f) + end + + f = io.open(xdg_config_home .. "/fcitx/.migration-complete", "r") + if f ~= nil then + io.close(f) + return false + end + + f = io.open(xdg_config_home .. "/fcitx5/.timestamp", "r") + if f ~= nil then + io.close(f) + local cmd = "stat -c %Y " .. xdg_config_home .. "/fcitx5/.timestamp" + local timestamp = io.popen(cmd) + local last_modified = timestamp:read() + local day = math.floor(os.difftime(os.time(), last_modified) / (24*60*60)) + if day > 0 then + if state == fcitx.KeyState.Ctrl and sym == 32 and not release then + io.popen(reminder) + end + end + else + if state == fcitx.KeyState.Ctrl and sym == 32 and not release then + io.popen(reminder) + end + end + return false +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/fcitx5-lua-migration-reminder-1.0.1/migration-reminder.conf.in new/fcitx5-lua-migration-reminder-1.0.1/migration-reminder.conf.in --- old/fcitx5-lua-migration-reminder-1.0.1/migration-reminder.conf.in 1970-01-01 01:00:00.000000000 +0100 +++ new/fcitx5-lua-migration-reminder-1.0.1/migration-reminder.conf.in 2021-12-26 06:41:18.960123977 +0100 @@ -0,0 +1,11 @@ +[Addon] +Name=migration-reminder +Comment=Reminder to migrate Fcitx4 configuration data to Fcitx5 +Category=Module +Type=Lua +OnDemand=False +Configurable=False +Library=addon.lua + +[Addon/Dependencies] +0=luaaddonloader diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/fcitx5-lua-migration-reminder-1.0.1/reminder.lua new/fcitx5-lua-migration-reminder-1.0.1/reminder.lua --- old/fcitx5-lua-migration-reminder-1.0.1/reminder.lua 1970-01-01 01:00:00.000000000 +0100 +++ new/fcitx5-lua-migration-reminder-1.0.1/reminder.lua 2021-12-26 06:41:18.960123977 +0100 @@ -0,0 +1,88 @@ +local lgi = require("lgi") +local Gtk = lgi.Gtk +local GdkPixbuf = lgi.GdkPixbuf + +local locales = {} +locales.en_US = { + window_title = "Fcitx4 configuration data migration reminder", + title = "Migration to Fcitx5", + text = "\nOur system detects that you have fcitx4 installed before,\nplease click 'ok' to migrate your configuration and data." +} +locales.zh_CN = { + window_title = "Fcitx4 ????????????????????????", + title = "????????? Fcitx5", + text = "\n????????????????????????????????? Fcitx4???????????? ok ??????????????????????????????????????????" +} + +local lang = os.getenv("LANG"):match("([%a_]+)") +if locales[lang] == nil then + lang = "en_US" +end +local window_title = locales[lang]["window_title"] +local title = locales[lang]["title"] +local text = locales[lang]["text"] + +local buffer = Gtk.TextBuffer {} +local pixbuf = GdkPixbuf.Pixbuf.new_from_file("/usr/share/icons/hicolor/scalable/apps/fcitx.svg") +local iter = buffer:get_iter_at_offset(0) +buffer:insert(iter, title, -1) +local offset = iter:get_offset() +iter = buffer:get_iter_at_offset(offset) +buffer:insert_pixbuf(iter, pixbuf:scale_simple(32, 32, "BILINEAR")) +offset = iter:get_offset() +iter = buffer:get_iter_at_offset(offset) +buffer:insert(iter, text, -1) + +local window = Gtk.Window { + title = window_title, + border_width = 10, + default_width = 200, + default_height = 100, + window_position = 'CENTER', + resizable = false, + icon = pixbuf:scale_simple(32, 32, "BILINEAR"), + Gtk.Box { + orientation = 'VERTICAL', + Gtk.Frame { + Gtk.TextView { + buffer = buffer, + editable = false, + } + }, + Gtk.Frame { + Gtk.ButtonBox { + orientation = 'HORIZONTAL', + border_width = 5, + spacing = 80, + Gtk.Button { + id = "ok_button", + use_stock = true, + label = Gtk.STOCK_OK + }, + Gtk.Button { + id = "cancel_button", + use_stock = true, + label = Gtk.STOCK_CANCEL + } + } + }, + }, + on_destroy = Gtk.main_quit +} + +local home = os.getenv("HOME") + +function window.child.ok_button:on_clicked() + io.popen("fcitx5-migrator") + local f = io.open(home .. "/.config/fcitx/.migration-complete", "w") + io.close(f) + window:destroy() +end + +function window.child.cancel_button:on_clicked() + local f = io.open(home .. "/.config/fcitx5/.timestamp", "w") + io.close(f) + window:destroy() +end +window:show_all() +Gtk.main() Binary files old/fcitx5-lua-migration-reminder-1.0.1/screenshot.png and new/fcitx5-lua-migration-reminder-1.0.1/screenshot.png differ