home: services: fcitx5: Add wayland-frontend? option.

* modules/rosenthal/services/desktop.scm (maybe-boolean?): New procedure.
(home-fcitx5-configuration) [wayland-frontend?]: New field.
[gtk-im-module?, qt-im-module?, xim?]: Deprecate fields.
(%home-fcitx5-environment-variables): Adjust accordingly.
(%home-fcitx5-profile): Install fcitx5-gtk and fcitx5-qt unconditionally.
(home-fcitx5-gtk2, home-fcitx5-gtk3): New procedures.
(home-fcitx5-service-type) [extensions]: Extend home-gtk[234]-service-type.
This commit is contained in:
Hilton Chain 2026-04-10 11:49:37 +08:00
parent d74dd005cf
commit 2b04665af0
No known key found for this signature in database
GPG Key ID: ACC66D09CA528292

View File

@ -4,7 +4,9 @@
(define-module (rosenthal services desktop) (define-module (rosenthal services desktop)
;; Utilities ;; Utilities
#:use-module (guix deprecation) #:use-module (guix deprecation)
#:use-module (guix diagnostics)
#:use-module (guix gexp) #:use-module (guix gexp)
#:use-module (guix i18n)
#:use-module (guix modules) #:use-module (guix modules)
#:use-module (guix packages) #:use-module (guix packages)
#:use-module (guix records) #:use-module (guix records)
@ -131,6 +133,7 @@
(define list-of-file-likes? (define list-of-file-likes?
(list-of file-like?)) (list-of file-like?))
(define-maybe file-like) (define-maybe file-like)
(define-maybe boolean)
(define-configuration/no-serialization home-fcitx5-configuration (define-configuration/no-serialization home-fcitx5-configuration
(fcitx5 (fcitx5
@ -145,42 +148,74 @@
(input-method-editors (input-method-editors
(list-of-file-likes '()) (list-of-file-likes '())
"") "")
(wayland-frontend?
(boolean #f)
"")
;; deprecated
(gtk-im-module? (gtk-im-module?
(boolean #f) maybe-boolean
"") ""
(sanitizer
(lambda (config)
(if (maybe-value-set? config)
(warning
(G_ "'~a': option '~a' is deprecated, please use '~a' instead.~%")
"home-fcitx5-configuration"
"gtk-im-module?"
"wayland-frontend?")))))
(qt-im-module? (qt-im-module?
(boolean #f) maybe-boolean
"") ""
(sanitizer
(lambda (config)
(if (maybe-value-set? config)
(warning
(G_ "'~a': option '~a' is deprecated, please use '~a' instead.~%")
"home-fcitx5-configuration"
"qt-im-module?"
"wayland-frontend?")))))
(xim? (xim?
(boolean #t) maybe-boolean
"")) ""
(sanitizer
(lambda (config)
(if (maybe-value-set? config)
(warning
(G_ "'~a': option '~a' is deprecated.~%")
"home-fcitx5-configuration"
"xim?"))))))
;; https://fcitx-im.org/wiki/Using_Fcitx_5_on_Wayland
(define %home-fcitx5-environment-variables (define %home-fcitx5-environment-variables
(match-record-lambda <home-fcitx5-configuration> (match-record-lambda <home-fcitx5-configuration>
(gtk-im-module? qt-im-module? xim?) (wayland-frontend?)
`(,@(if gtk-im-module? `(("XMODIFIERS" . "@im=fcitx")
'(("GTK_IM_MODULE" . "fcitx")) ("QT_IM_MODULE" . "fcitx")
'()) ,@(if wayland-frontend?
,@(if qt-im-module? '(("QT_IM_MODULES" . "wayland;fcitx"))
'(("QT_IM_MODULE" . "fcitx")) '(("GTK_IM_MODULE" . "fcitx"))))))
'())
,@(if xim? (define home-fcitx5-gtk2
'(("XMODIFIERS" . "@im=fcitx")) (match-record-lambda <home-fcitx5-configuration>
'())))) (wayland-frontend?)
(if wayland-frontend?
`(("gtk-im-module" . ,(format #f "~s" "fcitx")))
'())))
(define home-fcitx5-gtk3
(match-record-lambda <home-fcitx5-configuration>
(wayland-frontend?)
(if wayland-frontend?
`(("gtk-im-module" . "fcitx"))
'())))
(define %home-fcitx5-profile (define %home-fcitx5-profile
(match-record-lambda <home-fcitx5-configuration> (match-record-lambda <home-fcitx5-configuration>
(fcitx5 utilities themes input-method-editors gtk-im-module? qt-im-module?) (fcitx5 utilities themes input-method-editors wayland-frontend?)
(append (list fcitx5) (append (list fcitx5 fcitx5-gtk fcitx5-qt)
utilities utilities
themes themes
input-method-editors input-method-editors)))
(if gtk-im-module?
(list fcitx5-gtk)
'())
(if qt-im-module?
(list fcitx5-qt)
'()))))
(define %home-fcitx5-shepherd (define %home-fcitx5-shepherd
(match-record-lambda <home-fcitx5-configuration> (match-record-lambda <home-fcitx5-configuration>
@ -200,6 +235,12 @@
(extensions (extensions
(list (service-extension home-environment-variables-service-type (list (service-extension home-environment-variables-service-type
%home-fcitx5-environment-variables) %home-fcitx5-environment-variables)
(service-extension home-gtk2-service-type
home-fcitx5-gtk2)
(service-extension home-gtk3-service-type
home-fcitx5-gtk3)
(service-extension home-gtk4-service-type
home-fcitx5-gtk3)
(service-extension home-profile-service-type (service-extension home-profile-service-type
%home-fcitx5-profile) %home-fcitx5-profile)
(service-extension home-shepherd-service-type (service-extension home-shepherd-service-type