<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="https://dev1galaxy.org/extern.php?action=feed&amp;tid=1639&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Dev1 Galaxy Forum / alternative to ibus? ibus suffers from vanishing characters [SOLVED]]]></title>
		<link>https://dev1galaxy.org/viewtopic.php?id=1639</link>
		<description><![CDATA[The most recent posts in alternative to ibus? ibus suffers from vanishing characters [SOLVED].]]></description>
		<lastBuildDate>Wed, 11 Oct 2017 17:07:44 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Re: alternative to ibus? ibus suffers from vanishing characters [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=5493#p5493</link>
			<description><![CDATA[<p>I couldn&#039;t find anything suitable, so I rolled my own alternative to ibus. It&#039;s a simple bash script that allows typing diacritic either before or after the letter, user&#039;s choice. The script does not use &quot;preedit text&quot;, so no characters ever disappear.</p><p>Getting the dependencies:</p><div class="codebox"><pre><code>sudo apt-get install xvkbd python3 &amp;&amp; sudo pip3 install pynput</code></pre></div><p>You also need to install yad, which is not in the Devuan Jessie repositories but is easy to find (e.g., by clicking on your architecture at the bottom of <a href="https://packages.debian.org/stretch/yad" rel="nofollow">this page</a>). </p><p>pynput didn&#039;t work for me at first because one of its dependencies, the &quot;six&quot; module, was outdated. So, to be safe:</p><div class="codebox"><pre><code>sudo pip3 install --upgrade six</code></pre></div><p>Well, here&#039;s the script. It should &quot;just work&quot; once you have all the dependencies. You only need to alter it if you want to add or change the special characters section.</p><div class="codebox"><pre class="vscroll"><code>#!/bin/bash

# International keyboard (alternative to ibus for x11)
# Author: Bruno &quot;GNUser&quot; Dantas
# License: GPLv3
# Dependencies: 
#    sudo apt-get install xvkbd python3 yad
#    sudo pip3 install pynput
# Usage: 
#    - Change the triggers and unicode sequences in &quot;watch_for_triggers&quot; function to suit your needs
#    - Run this script as regular user to turn on the international keyboard
#    - Stop the script--via taskbar icon or, if running in terminal, Control+c--to clean up without a trace

main()
{
    create_pipe
    create_keylogger # writes to pipe
    create_taskbar_icon
    watch_for_triggers # reads from pipe, replaces user-defined character combinations with unicode characters
}

create_pipe()
{
    pipe=/tmp/international
    rm -f $pipe
    mkfifo $pipe
    exec 3&lt;&gt;$pipe
}

create_keylogger()
{
    # to troubleshoot the keylogger: 
    # 1. copy the python code below into a file foo
    # 2. comment out the three fifo lines, uncomment the print line in log_it function
    # 3. in a terminal: python3 /path/to/foo
    # 4. type stuff outside the terminal and watch terminal
    echo &quot;
from pynput import keyboard
from pynput import mouse
import os

fifo_write = open(&#039;$pipe&#039;, &#039;w&#039;)

def log_it(output):
    fifo_write.write(output + &#039;\n&#039;)
    fifo_write.flush()
    #print(output)

# get initial capslock state
exit_code = os.system(&#039;&#039;&#039;xset q 2&gt;/dev/null | grep -q -E &#039;Caps Lock: +on&#039; &#039;&#039;&#039;)
if exit_code == 0:
    capslock_in_effect = True
else:
    capslock_in_effect = False

# this function runs each time a key is pressed:
def on_press(key): 
    global capslock_in_effect
    output = str(key)
    if output == &#039;Key.caps_lock&#039;: # if capslock pressed, toggle capslock state
        capslock_in_effect = not capslock_in_effect
    if not output.startswith(&#039;Key&#039;): # special keys start with &#039;Key&#039; and can be logged as-is
        output = output[1:-1] # remove quotes around character
        if capslock_in_effect:
            output = output.swapcase()
    if not output.startswith(&#039;Key.shift&#039;): # don&#039;t log shift keys (e.g., while loop expects a~ not aKey.shift~)
        log_it(output)

# this function runs each time a mouse button is pressed:
def on_click(x, y, button, pressed):
    button = str(button)
    if pressed and button == &#039;Button.left&#039;:
        log_it(&#039;Key.mousebutton_left&#039;)

# start listening
with mouse.Listener(on_click=on_click) as listener:
    with keyboard.Listener(on_press=on_press) as listener:
        listener.join()
&quot; &gt;/tmp/tiny-keylogger
    python3 /tmp/tiny-keylogger &amp;
}

echo &quot;$(basename $0)&quot; &gt;/tmp/scriptname # so cleanup function can find this script&#039;s name when called from yad
cleanup()
{
    echo &quot;Cleaning up...&quot;
    pkill -f International # kill taskbar icon                     
    pkill -f tiny-keylogger # kill keylogger
    pkill -KILL &quot;$(cat /tmp/scriptname)&quot; # kill this script         
}
trap cleanup EXIT HUP TERM INT

create_taskbar_icon()
{
    export -f cleanup
    yad --notification --image=&#039;accessories-character-map&#039; --text=&#039;International Keyboard&#039; \
        --no-middle --menu=&quot;Stop!bash -c cleanup&quot; --command=&#039;&#039; &amp;
}

replace()
{
    xvkbd -xsendevent -text &quot;\b\b\[U$1]&quot; # send two backspaces then desired unicode character
}

watch_for_triggers()
{
    # endless loop (it reads from a fifo pipe, so never encounters EOF)
    while read current_char; do
        echo &quot;${previous_char}${current_char}&quot; # for debugging while running in terminal
        case &quot;${previous_char}${current_char}&quot; in
          # Portuguese
            &#039;A`&#039;) replace 00C0;;
            &#039;a`&#039;) replace 00E0;;
            &quot;A&#039;&quot;) replace 00C1;;
            &quot;a&#039;&quot;) replace 00E1;;
            &#039;A^&#039;) replace 00C2;;
            &#039;a^&#039;) replace 00E2;;
            &#039;A~&#039;) replace 00C3;;
            &#039;a~&#039;) replace 00E3;;
            &quot;E&#039;&quot;) replace 00C9;;
            &quot;e&#039;&quot;) replace 00E9;;
            &#039;E^&#039;) replace 00CA;;
            &#039;e^&#039;) replace 00EA;;
            &quot;I&#039;&quot;) replace 00CD;;
            &quot;i&#039;&quot;) replace 00ED;;
            &#039;O`&#039;) replace 00D2;;
            &#039;o`&#039;) replace 00F2;;
            &quot;O&#039;&quot;) replace 00D3;;
            &quot;o&#039;&quot;) replace 00F3;;
            &#039;O^&#039;) replace 00D4;;
            &#039;o^&#039;) replace 00F4;;
            &#039;O~&#039;) replace 00D5;;
            &#039;o~&#039;) replace 00F5;;
            &quot;U&#039;&quot;) replace 00DA;;
            &quot;u&#039;&quot;) replace 00FA;;
            &#039;U;&#039;) replace 00DC;;
            &#039;u;&#039;) replace 00FC;;
            &#039;C;&#039;) replace 00C7;;
            &#039;c;&#039;) replace 00E7;;
          # Esperanto
            &#039;Cx&#039;) replace 0108;;
            &#039;CX&#039;) replace 0108;;
            &#039;cx&#039;) replace 0109;;
            &#039;Gx&#039;) replace 011C;;
            &#039;GX&#039;) replace 011C;;
            &#039;gx&#039;) replace 011D;;
            &#039;Hx&#039;) replace 0124;;
            &#039;HX&#039;) replace 0124;;
            &#039;hx&#039;) replace 0125;;
            &#039;Jx&#039;) replace 0134;;
            &#039;JX&#039;) replace 0134;;
            &#039;jx&#039;) replace 0135;;
            &#039;Sx&#039;) replace 015C;;
            &#039;SX&#039;) replace 015C;;
            &#039;sx&#039;) replace 015D;;
            &#039;Ux&#039;) replace 016C;;
            &#039;UX&#039;) replace 016C;;
            &#039;ux&#039;) replace 016D;;
        esac
        previous_char=$current_char
    done &lt;&amp;3
}

main</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (GNUser)]]></author>
			<pubDate>Wed, 11 Oct 2017 17:07:44 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=5493#p5493</guid>
		</item>
		<item>
			<title><![CDATA[alternative to ibus? ibus suffers from vanishing characters [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=5361#p5361</link>
			<description><![CDATA[<p>I often use ibus to type in other languages. Especially when writing emails, I tend to edit a lot as I go along. The trouble is that in many applications when I click on the screen to move the cursor somewhere, if I&#039;m using ibus then the last character I typed simply disappears.</p><p>For example, in mate-terminal, thunderbird, and pluma, if I type this (for example):</p><div class="codebox"><pre><code>ho ho ho</code></pre></div><p>Then click somewhere on the screen, the text turns into this:</p><div class="codebox"><pre><code>ho ho h</code></pre></div><p>Have any of you found a way to type in other languages--with or without ibus--without being affected by this? </p><p>I have considered using a keyboard layout with dead keys as a workaround, but I don&#039;t like having to type the diacritic before the letter.</p><p>--------------<br />My setup:<br />- Devuan Jessie with MATE<br />- ibus 1.5.9-1<br />- ibus packages installed: ibus, ibus-gtk, ibus-gtk3, ibus-m17n, ibus-qt4</p>]]></description>
			<author><![CDATA[dummy@example.com (GNUser)]]></author>
			<pubDate>Fri, 06 Oct 2017 12:39:21 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=5361#p5361</guid>
		</item>
	</channel>
</rss>
