0

I'm using fcitx5 with emacs, to enable entry of Chinese characters. There is a known issue with emacs, where in order to input Chinese characters, one needs to launch emacs using LC_CTYPE=zh_CN.UTF-8 emacs. This works fine, but I would like to make this more permanent (for lack of better word).

One thing I would like to do is change the Desktop Entry file to set LC_CTYPE. The reason I want to change this file is because I have different symlinks pointing to it (like autostart), and would like to launch this entry with the edited LC_CTYPE. Is this possible?

My Desktop Entry file in /usr/share/applications/ looks like this:

[Desktop Entry] Version=1.0 Name=Emacs (GUI) GenericName=Text Editor Comment=GNU Emacs is an extensible, customizable text editor - and more MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++; TryExec=/usr/bin/emacs Exec=/usr/bin/emacs %F Icon=emacs Type=Application Terminal=false Categories=Utility;Development;TextEditor; StartupWMClass=Emacs Keywords=Text;Editor; 
7
  • 1
    One workaround mentioned here seems to be to use Exec=/usr/bin/env LC_CTYPE=zh_CN.UTF-8 emacs %F. Commented May 2, 2024 at 17:44
  • Thank you @Arfrever Just to clarify, is that a one-line update to the Exec key's value? i.e., I should update Exec to LC_CTYPE=zh_CN.UTF-8 emacs %F? Commented May 2, 2024 at 20:43
  • 2
    Try Exec=/usr/bin/env LC_CTYPE=zh_CN.UTF-8 /usr/bin/emacs %F line. env tool (usually /usr/bin/env) allows to run any program with added/changed/deleted environment variables. See man 1 env. Commented May 2, 2024 at 21:33
  • 1
    I also remind that shell variables and environment variables are different things. env tool allows to set environment variables, whose names contain characters not allowed in names of shell variables: env -i my-variable:with@shell%disallowed^charactersあいうえお=1 python -c 'import os; print(os.environ)'. Commented May 2, 2024 at 21:42
  • 2
    Note that your change will be lost when Emacs gets upgraded by your package management system. You should make a copy in ~/.local/share/applications, edit that instead and update your symlinks to point there. Commented May 3, 2024 at 5:30

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.