我用多種語言寫作和工作:德語、西班牙語、法語、希臘語、英語。在 Mac 中,當您按下某個鍵超過 2 秒時,您可以在從主角派生的特殊字元之間進行選擇。 Windows 中有一個名為 Holdkey 的軟體具有相同的功能。 Linux下有類似的東西嗎?我還沒找到。
答案1
我有兩個建議:
- 使用合適的鍵盤佈局,即帶有死鍵的佈局。如果您有英文鍵盤,請選擇英語(美國、國際、帶死鍵)。但還有其他幾種變體。
- 定義一個撰寫鍵。這樣您就可以輸入您正在使用的鍵盤佈局中未包含的許多字元。 (Compose 鍵是 XKB 功能,因此它在 Kubuntu 上可用,但您需要弄清楚如何在那裡定義它。)
答案2
如果您不怕設定(說明應該很清楚),以下可以為您提供快速插入常用特殊字元(-alternatives)的替代方案。
可編輯的特殊字元工具
下面的腳本是一個靈活的工具(單擊即可插入字元的視窗),可以立即使用常用的字元:
怎麼運作的
- 用快捷方式呼叫視窗
- 要插入字符,只需單擊它,它就會將該字符貼到您正在使用的視窗中。
若要新增一組字符,請按+ 將開啟文字編輯器窗口,在第一行新增您的「家庭」名稱,在下一行新增相關特殊字符,每行一個字符,例如:
a å ä ã â á à ª
(來自圖像)。關閉文件,從現在起,下次呼叫該視窗時,特殊字元將可用。
- 若要刪除一組可用字符,請按x
如何設定
您需要滿足一些依賴關係:
python3-xlib
sudo apt install python3-xlib
pyautogui:
pip3 install pyautogui
pyperclip:
sudo apt install python3-pyperclip xsel xclip
您可能需要安裝 Wnck:
python3-gi gir1.2-wnck-3.0
登出並重新登入。
將下面的腳本複製到一個空文件中,另存為
specialchars.py
並使其可執行#!/usr/bin/env python3 import os import gi gi.require_version("Gtk", "3.0") gi.require_version('Wnck', '3.0') from gi.repository import Gtk, Wnck, Gdk import subprocess import pyperclip import pyautogui css_data = """ .label { font-weight: bold; color: blue; } .delete { color: red; } """ fpath = os.environ["HOME"] + "/.specialchars" def create_dirs(): try: os.mkdir(fpath) except FileExistsError: pass def listfiles(): files = os.listdir(fpath) chardata = [] for f in files: f = os.path.join(fpath, f) chars = [s.strip() for s in open(f).readlines()] try: category = chars[0] members = chars[1:] except IndexError: os.remove(f) else: chardata.append([category, members, f]) chardata.sort(key=lambda x: x[0]) return chardata def create_newfamily(button): print("yay") n = 1 while True: name = "charfamily_" + str(n) file = os.path.join(fpath, name) if os.path.exists(file): n = n + 1 else: break open(file, "wt").write("") subprocess.Popen(["xdg-open", file]) class Window(Gtk.Window): def __init__(self): Gtk.Window.__init__(self) self.set_decorated(False) # self.set_active(True) self.set_keep_above(True); self.set_position(Gtk.WindowPosition.CENTER_ALWAYS) self.connect("key-press-event", self.get_key) self.set_default_size(0, 0) self.provider = Gtk.CssProvider.new() self.provider.load_from_data(css_data.encode()) self.maingrid = Gtk.Grid() self.add(self.maingrid) chardata = listfiles() # get the currently active window self.screendata = Wnck.Screen.get_default() self.screendata.force_update() self.curr_subject = self.screendata.get_active_window().get_xid() row = 0 for d in chardata: bbox = Gtk.HBox() fambutton = Gtk.Button(d[0]) fambutton_cont = fambutton.get_style_context() fambutton_cont.add_class("label") fambutton.connect("pressed", self.open_file, d[2]) Gtk.StyleContext.add_provider( fambutton_cont, self.provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION, ) fambutton.set_tooltip_text( "Edit special characters of '" + d[0] + "'" ) bbox.pack_start(fambutton, False, False, 0) for c in d[1]: button = Gtk.Button(c) button.connect("pressed", self.replace, c) button.set_size_request(1, 1) bbox.pack_start(button, False, False, 0) self.maingrid.attach(bbox, 0, row, 1, 1) deletebutton = Gtk.Button("X") deletebutton_cont = deletebutton.get_style_context() deletebutton_cont.add_class("delete") Gtk.StyleContext.add_provider( deletebutton_cont, self.provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION, ) deletebutton.connect("pressed", self.delete_file, d[2], bbox) deletebutton.set_tooltip_text("Delete family") self.maingrid.attach(deletebutton, 100, row, 1, 1) row = row + 1 addbutton = Gtk.Button("+") addbutton.connect("pressed", create_newfamily) addbutton.set_tooltip_text("Add family") self.maingrid.attach(addbutton, 100, 100, 1, 1) self.maingrid.attach(Gtk.Label("- Press Esc to exit -"), 0, 100, 1, 1) self.show_all() Gtk.main() def get_key(self, button, val): # keybinding to close the previews if Gdk.keyval_name(val.keyval) == "Escape": Gtk.main_quit() def replace(self, button, char, *args): pyperclip.copy(char) subprocess.call(["wmctrl", "-ia", str(self.curr_subject)]) pyautogui.hotkey('ctrl', 'v') Gtk.main_quit() def open_file(self, button, path): subprocess.Popen(["xdg-open", path]) def delete_file(self, button, path, widget): os.remove(path) widget.destroy() button.destroy() self.resize(10, 10) create_dirs() Window()
設定運行快捷鍵:
python3 /path/to/specialchars.py
第一次運行時,您只會看到一個+按鈕。開始添加您的角色“家庭”並重新啟動(-調用)窗口,以便單擊即可使用所有內容。
就是這樣...
答案3
您可以使用 unicode 在 Linux 上鍵入特殊字元。
若要輸入特殊字符,請先按下CTRL+ SHIFT+ U,然後放開按鍵。
接下來,鍵入要插入的字元的十六進位代碼,然後按ENTER
“ü”的十六進位代碼是00fc
。