How to add shortcut key by bash script - linux

We are working on a kiosk mode in Linux Ubuntu. We would like to define a shortcut by command line (bash script). Is this possible? We would like to setup our kiosk mode automatically by a bash script. So creating a new shortcut via Compiz isn't possible.
Any ideas?

The shortcuts usually depend on the window manager you're using. If you're using Ubuntu you should have Gnome as default windomanager so you could use the Gnome Control Center to set the shortcuts you want.
Another way, is use a tool like Xbindkeys which is indipendent from the window manager and reads the key configuration from a simple text file usually ~/.xbindkeysrc.
So you could install Xbindkeys in your system with:
sudo apt-get install xbindkeys
Then in the bash script you could add a new entry in the ~/xbindkeysrc config file to add your shortcut.

Related

How can I launch gitahed from terminal?

I enjoy using gitahed, and I would like to add a shortcut to lauch it, with github desktop I use github-desktop, but I can do the same with GA?
How can I launch gitahed from terminal?
GitAhead has a Terminal panel at Tools->Options. It has a button to install command line tools. It really just creates a symlink to the GitAhead binary in /usr/local/bin. If that doesn't work for some reason, you can create the symlink yourself or an alias. See command line options by running with the --help flag. There are only a few at the moment.

How do I create a shortcut for a command line command in Raspbian Stretch?

I am attempting to install RetroPie as an app on Raspbian Stretch and I am done except for creating a desktop shortcut for it. The problem is that the only way to open RetroPie seems to be running a command in the command line. I can’t do it in terminal because it gives me an error saying that it can’t initialize the window. Is there a way to run a command line command as a shortcut or am I going to have to find another way of doing this?
P.S. Here is the tutorial that I followed to install RetroPie:
https://www.makeuseof.com/tag/install-retropie-app-raspberry-pi/
Probably your shell (on the raspberry) is GNU bash. So read the manual of GNU bash.
You probably want (once) to edit some Bash startup file (such as ~/.bashrc) to define functions and aliases there, and you could add executable shell scripts somewhere in your $PATH. I recommend having a $HOME/bin/ directory containing your scripts and executables, and have $HOME/bin/ early in your $PATH.
I can’t do it in terminal because it gives me an error saying that it can’t initialize the window.
Perhaps you need some display server (such as Xorg or Wayland) running (with a desktop environment or a window manager). You could run Xorg on your PC (on which you could install Linux) and connect to the raspberry using ssh -X then remote applications running on your Raspberry are displayed on your PC. IF your Raspberry is directly connected to a screen (via HDMI) you might run some Xorg server on it.
Is there a way to run a command line command as a shortcut
Yes, by making a shell alias or shell function or shell script. You need to understand how they work and change or create some appropriate file using some source code editor (I recommend GNU emacs, but the choice is yours and you might use any other editor such as vim, gedit, etc...): functions and aliases could be defined in your ~/.bashrc; shell scripts would usually have their own file with a shebang under your $HOME/bin/...

How to create files and folder in Atom using the command line?

I was watching a speedy workflow tutorial about Atom text editor, and saw how the guy uses Linu commands like ls (to check the files in the directory), touch (to create files eg. style.css) and mkdir (to create folders). Now in my Atom editor I am able to open the command line using the following command.
CTRL + SHIFT + T
Now in my command line the default windows command line opens up, I am able to create folder using mkdir, but the commands touch and ls don't work, which makes me wonder weather Atom has its own command line?
See the SCREENSHOT to see how this guy is creating folders, files and using the ls command.
So my question is, how do I create files in Atom? How do I get the touch command to work?
It looks like the tutorial is using the Term2 package for opening a shell within the editor (http://code.tutsplus.com/courses/speedy-workflows-with-atom/lessons/term2). Since you seem to be able to open a terminal using the described screenshot, you seem to have the Term2 package installed - so far so good.
This package opens a standard command window within the editor. The tutorial seems to be using Linux or Mac OS X as the operating system. If you're running Windows, you will only have the Windows CMD interpreter available.
Windows does not natively support the touch command (but it has a mkdir command). There is a unxtools project that provides some of the common Gnu tools. If you install that, you should be able to run touch from the Windows command shell as well. More details can be found here.

How to run a program in Atom Editor?

I found Atom editor as good free alternative to Sublime text editor. Not able to find a straightforward way to run a program in Atom editor. In my case, I am trying to run a java program. Please let me know if it's possible? If yes, please describe the steps to follow.
I find the Script package useful for this. You can download it here.
Once installed you can run scripts in many languages directly from Atom using cmd-i on Mac or shift-ctrl-b on Windows or Linux.
Click on Packages --> Commmand Palette --> Select Toggle.
Type Install Packages and Themes.
Search for Script and then install it.
Press Command + I to run the code (on Mac)
You can go settings, select packages and type atom-runner there if your browser can't open this link.
To run your code do Alt+R if you're using Windows in Atom.
For C/C++ programs there's very good package gpp-compiler.
Shortcuts:
To compile and run: F5
To debug: F6
If you know how to launch your program from the command line then you can run it from the platformio-ide-terminal package's terminal. See platformio-ide-terminal provides an embedded terminal within the Atom text editor. So you can issue commands, including commands to run your Java program, from within it. To install this package you can use APM with the command:
$ apm install platformio-ide-terminal --no-confirm
Alternatively, you can install it from the command palette with:
Pressing Ctrl+Shift+P. I am assuming this is the appropriate keyboard shortcut for your platform, as you have dealt ith questions about Ubuntu in the past.
Type Install Packages and Themes.
Search for the platformio-ide-terminal.
Install it.
This package in Atom can run scripts.
Atom script package
press Alt+X for the running script.
For running javascript you need to install 'node js'
Also pressing ctrl+shift+i in atom gives developer option like chrome
you can test javascript code side by side in atom editor.
In order to get this working properly on Windows, you need to manually set the path to the JDK (...\jdk1.x.x_xx\bin) in the system environment variables.
You can try to use the runner in atom
Hit Ctrl+R (Alt+R on Win/Linux) to launch the runner for the active window.
Hit Ctrl+Shift+R (Alt+Shift+R on Win/Linux) to run the currently selected text in the active window.
Hit Ctrl+Shift+C to kill a currently running process.
Hit Escape to close the runner window
You can run specific lines of script by highlighting them and clicking shift + ctrl + b
You can also use command line by going to the root folder and writing:
$ node nameOfFile.js

How do I open a WinSCP GUI session from command line?

If I have a session named "hpc" and I run:
winscp hpc
I get into command line mode. How do I run the GUI and open a session from the command line (Windows)?
WinSCP has two executables, winscp.exe and winscp.com. The winscp.exe is GUI, while the winscp.com is command-line.
If you use just the winscp, due to an extension precedence in Windows, the .com wins. Make sure you use a full GUI executable name:
winscp.exe hpc
References:
https://winscp.net/eng/docs/executables
https://winscp.net/eng/docs/commandline

Resources