Git Product home page Git Product logo

shin's Introduction

Shin: Shell input method

Shin lets you run shell commands anywhere you can type text. Watch this:

Screencast

This works in almost every Linux application, including Firefox, Chrome, LibreOffice, all GTK and Qt applications, and many more. The possibilities are endless as static editing and dynamic evaluation become one.

Shin stays completely out of your way until you press the magic key that brings it to life. When not in use, Shin consumes zero CPU time and memory. I despise software that wastes computing resources, and Shin is designed accordingly.

Ready to give it a try?

Installation

Installing Shin is a painless procedure on most Linux distributions.

Step 1: Set up IBus

Shin is implemented as an IBus input engine. Before Shin can be installed, IBus must be installed and configured.

If you use GNOME, you can skip this step, because the GNOME desktop comes with a fully configured IBus installation out of the box.

On KDE, it usually suffices to install any IBus input method (e.g. Typing Booster) from the KDE Software Center, after which you will be prompted to switch to IBus as the system input method. After logging out and back in, you should be ready to go.

For other desktop environments and window managers, the setup may involve manually installing the IBus daemon, and setting environment variables. See this ArchWiki article for more information.

Before filing an issue of the type "Shin is not working!", please verify that you have a functioning IBus setup. You can do this by trying out any other IBus input method, such as Typing Booster or Pinyin.

Step 2: Install Shin

Make sure you have Go, a C compiler, Make, and Git. Then run:

git clone https://github.com/p-e-w/shin.git
cd shin
make
sudo make install
ibus restart

Note 1: Occasionally, ibus restart fails to actually restart IBus. In that case, you have to restart the IBus daemon manually, or simply restart your system.

Note 2: The above commands assume that your IBus installation is located in /usr/share. In the vast majority of cases, this is correct. If you have installed IBus elsewhere, you must run both make and make install with the IBUS_INSTALL_DIR variable set to the actual location, e.g. make IBUS_INSTALL_DIR=/usr/share.

Step 3: Make Shin activatable

The Shin input engine is intended to be activated using a hotkey, and automatically deactivates itself after a shell command has been entered. This allows for normal text editing to continue without having to manually switch back to the default input method.

For this reason, it is not recommended to add Shin to the desktop's input method switcher.

Instead, simply bind the command ibus engine shin to a global keyboard shortcut such as Alt+Space. On GNOME, this can be done using Settings > Keyboard > View and Customize Shortcuts > Custom Shortcuts. On KDE, System Settings > Shortcuts > Custom Shortcuts does the same thing. For other desktop environments and window managers, see the appropriate documentation.

That's it! Shin is now just a keypress away whenever you need it.

The shin/bin directory

If you use Shin frequently, it's quite natural to want to define custom commands for inserting commonly needed text. For example, you might like to have a sig command that inserts a signature with your name and address for use in emails and online discussions.

Of course, you could just create a shell script which prints that text, and place it in any of the directories in the shell's search path. But then sig would also be available in regular interactive shells, and you probably don't want to pollute your global command namespace with Shin-specific commands. You may also wish to override some of the standard commands in Shin, but only in Shin.

To solve these problems, Shin prepends the directory $XDG_CONFIG_HOME/shin/bin (which usually expands to ~/.config/shin/bin) to the shell's search path when running commands. To define Shin-specific commands, simply create that directory, and drop executable scripts with the desired names there. They will be available in Shin, without affecting the behavior of the shell anywhere else.

Security considerations

By design, Shin turns every text input on your system into a basic terminal emulator with full shell access. This shouldn't be a problem under normal circumstances, since anyone with unsupervised access to your computer can just launch a terminal anyway, but in some situations, such as a system running in "kiosk mode", extra caution may be warranted.

Most screen locking applications explicitly disable input methods, but if you use a non-standard screen locker, you should verify that Shin cannot be accessed from the lock screen inputs, because that would create a trivial way to bypass the lock by running a shell command that kills the lock screen process.

To the best of my knowledge, web browsers do not allow JavaScript code to synthesize the low-level input events needed to control an IME. I therefore believe that Shin is safe to use in browser inputs, even on untrusted websites. A carefully designed website might however use concealed inputs and fake input overlays to trick you into thinking that you have typed something different from what you actually did. This represents a rather low security risk though, since the site still cannot control which commands are entered and executed.

Acknowledgments

Shin depends on the xdg, go-sqlite3, and dbus Go packages, as well as on BambooEngine's fork of the goibus package (the only fork with proper Wayland support).

This project was my first encounter with IBus, a system that in practice is used almost exclusively for typing East Asian scripts. I was pleasantly surprised to find that IBus is flexible enough to support a use case like Shin, which it was obviously not intended for and yet able to accommodate. My respect goes to the creators of IBus for their clean and versatile design.

License

Copyright © 2022 Philipp Emanuel Weidmann ([email protected])

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

By contributing to this project, you agree to release your contributions under the same license.

shin's People

Contributors

p-e-w avatar zachu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

shin's Issues

Prebuilt binaries

It would be really cool if release page would also contain prebuilt binaries, so users would not need install Go compiler and etc

Meta key (ctrl, alt) stays active after using shin

I have set ibus engine shin to the keyboard shortcut Ctrl+Space (and also tried with Alt+Space). After executing a command in shin by pressing Enter, it seems like the Ctrl stays stuck and I have to press Ctrl+c to exit this mode and return to normal input. At this point I'm not sure whether this is a shin or ibus problem, as this only started recently.

Some details:

  • Using the latest version of shin (a081ee0)
$ lsb_release -a
LSB Version:	n/a
Distributor ID:	Fedora
Description:	Fedora Linux 39 (Workstation Edition)
Release:	39
Codename:	n/a

$ gnome-shell --version 2>/dev/null
GNOME Shell 45.3

Update: Setting the keyboard shortcut to Super+Space works just fine.

Set global engine failed: Timeout was reached

Hello, I installed shin and ibus, bound ibus engine shin to a keybaord shortcut in KDE (ALT+SHIT+ENTER) but I still can't manage to run any commands, further more running it in a terminal errors me:

(process:2963): IBUS-WARNING **: 13:20:25.972: ibus_bus_call_sync: org.freedesktop.IBus.SetGlobalEngine: GDBus.Error:org.freedesktop.DBus.Error.Failed: Set global engine failed: Timeout was reached
Failed to configure global engine.

What am I doing wrong ?

What I run:

Distro       : Artix linux
init System  : runit
DE           : latest kde plasma 
IBUS         : IBus 1.5.27
Shin         : shin-git-1.0.0.r1.g7373a4f-1 (From the aur)

Thanks for the help.

Filter out the escape sequences

I think it's useful to leave out the escape sequences, because usually text editor will not properly render shell color code anyways.

For example, this is the output of command tldr ls

image

Dead keys not working after activating shin

Hey!

I'm having problem with Finnish keyboard layout containing multiple characters as Dead Keys. Keys such us ~ or ^ require me to press the ~ key and then space to enter only the given character. I can also combine them by pressing ~ and a for example to create ã.

I have all the keys working correctly, but after running ibus engine shin (and running a command through that) I no longer have working dead keys anywhere. Pressing for example ~ produces nothing.

Restarting ibus with ibus restart fixes this issue, but it comes back after every new launch of shiv.

Some details

Using finnish keyboard layout

$ setxkbmap -query
rules:      evdev
model:      pc105
layout:     fi,us
variant:    ,
options:    nbsp:none

Using the latest version of shin I guess

$ git rev-parse --short HEAD
2f76026

Running on POP!_OS 22.04 (so pretty much Ubuntu 22.04) with GNOME 42.3.1

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Pop
Description:	Pop!_OS 22.04 LTS
Release:	22.04
Codename:	jammy

$ gnome-shell --version 2>/dev/null
GNOME Shell 42.3.1

Works on Chrome & Pycharm, but not Gnome tooling

Love the tool, I installed it and would like to fix an issue I have. I'm currently unable to activate it in tools like gedit, but it works in chrome and pycharm. I've installed typing-booster and can confirm that that is working on the aforementioned platforms.

Any tips or tricks for debugging this would be appreciated!

Support for Immutable OSes like Fedora Silverblue?

I just switched to Fedora Silverblue. I tried to install Shin but I'm running into issues.
I installed Make and Go, but when I run the sudo make install command I get:

[lobau@fedora shin]$ sudo make install
[sudo] password for lobau: 
mkdir -p '/usr/share/ibus-shin'
mkdir: cannot create directory ‘/usr/share/ibus-shin’: Read-only file system
make: *** [Makefile:15: install] Error 1

Any other way to install Shin?

GTK applications on GNOME crash/freeze when length of command output exceeds 4083 bytes

This can be verified by running the commands

printf %4083s

which works, versus

printf %4084s

which crashes and sometimes freezes, when run from a Shin input inside a GTK application on GNOME. When a crash occurs, stdout contains the message

Error reading events from display: Broken pipe

This does not happen on KDE or Sway, even on the same base system and with the same GTK applications.

My guess is that the number 4083 is 4096 minus the size of the DBus header or something. There appears to be a GNOME-specific limit at work here. The other DEs can handle much larger outputs without any problems.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.