Skip to content

A script to create new yakuake sessions from command-line or '.desktop' files. It allows yakuake to be a better replacement of konsole.

License

GPL-3.0, GPL-3.0 licenses found

Licenses found

GPL-3.0
LICENSE
GPL-3.0
COPYING
Notifications You must be signed in to change notification settings

RogueScholar/yaknewtab

 
 

yaknewtab GitHub license

A shell script for opening new Yakuake tabs/sessions

made-with-bash GitHub issues GitHub stars GitHub last commit GitHub repo size

FOSSA Status


Forked from yakuake-session by Jesús Torres, © 2010-2018.


What is yaknewtab?

yaknewtab is a (mostly) POSIX shell script that greatly simplifies the creation of new tabs/sessions in Yakuake. It uses simple logic to determine the D-Bus CLI tool needed to communicate with the already-running Yakuake process, adding the specifics (supplied as standard POSIX flags and arguments) in the necessary syntax to generate the desired result.

I forked it from the original developer mainly to streamline the approach, more closely following consensus best practices, and ultimately achieving (I believe) greater consistency of operation on a wider range of shells. Like the upstream project the goal is a better integration of Yakuake with the desktop environment (typically KDE Plasma 5) and other resident applications. This is something which has often been constrained by its design as an "always-running" foreground process that remains hidden from view until triggered, insisting on D-Bus as the only method to receive user directives that are not issued through its GUI.

Where on most *nix systems a needed terminal instance can be invoked by simply calling its executable, with Yakuake that would add another running instance, conflicting with the one which was already running and hidden. To successfully accomplish new instance creation with Yakuake (i.e. telling the hidden instance to show itself and add a new tab in the requested working directory) requires use of the D-Bus interface, a task sufficiently esoteric that even many power users struggle to do without hiccups.

For example, thanks to it, Yakuake can replace Konsole in "Open terminal here" action in Dolphin or we can setup a menu similar to Konsole Profiles widget but using Yakuake instead of Konsole.

What is Yakuake?

A terminal emulator developed and distributed by KDE as part of the Plasma desktop environment. Visually, it seeks to hearken to the celebrated console panel from the 90s computer game, Quake: sliding into and out of view from the (top) edge of the screen upon the press of a hotkey.

The name is an exquisite example of over-the-top open source project naming irony. Technically a portmanteau crossed with a "backronym," it's derived from the motto "Yet Another Kuake." In keeping with KDE project tradition, phonemes that can be represented with the letter 'k' are styled as such, explaining the odd spelling.

Links to more information about Yakuake

Bugs & known issues

  • Requires wmctrl to change focus if yakuake is already open. Get it from the repo e.g. apt install wmctrl

  • Fish is not a POSIX compliant shell, so yaknewtab detects if it is used for the invocation and adjusts its operations accordingly. If the auto-detection doesn't work properly, two solutions exist:

    • Issuing the command export FISH_SHELL=0 temporarily disables the Fish shell adaptations, while export FISH_SHELL=1 temporarily enables them

    • For a permanent change, use the following command (provided that you placed it in a location in your $PATH) to open the script file in the default editor and change line 14 accordingly: FISH_SHELL=1 to enable the Fish shell changes or FISH_SHELL=0 to disable them.

      command -v yaknewtab | xargs sudoedit -e

Installation

Clone this repository and navigate into the new repository directory.

git clone https://github.com/RogueScholar/yaknewtab.git && cd yaknewtab

Copy the yaknewtab script to ~/bin, /usr/local/bin or some other directory in your $PATH variable so it can be executed by just its name.

If the file is in any other location you will be forced to type the relative or full path of the script every time you wish to use it.

# Examine your $PATH environment variable to aid in selecting an appropriate folder
# (Shown here with example output)

$ echo $PATH
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:$HOME/bin"

# Copy the script to the folder of your choice and ensure
# it has the right ownership and permissions

# Installation system-wide (for all users) in /usr/local/bin
$ sudo install -Dp --mode=755 --owner=root --group=root yaknewtab /usr/local/bin/yaknewtab

# Installation for the current user only in $HOME/bin
$ install -Dp --mode=755 yaknewtab $HOME/bin/yaknewtab

Usage

To invoke yaknewtab:

yaknewtab

Without arguments, yaknewtab creates a new session in the currently running Yakuake terminal emulator.

The option -e allows to indicate a command to execute in the new session.

yaknewtab -e ls

The argument -t sets the title for the new tab.

yaknewtab -t "Title"

The session working directory is changed to the directory where yaknewtab was called, before execute the command. If we want to launch the command from user's home directory then we would use the option -h.

yaknewtab -h -e ls

If the command requires some arguments, they are taken from non-option arguments passed to yaknewtab. That means that if some arguments for the command begin with -, they must passed to yaknewtab after --.

yaknewtab -h -e ssh -- -X user@example.com

Another useful option is --workdir. It allows to change the working directory before execute the command.

yaknewtab --workdir /tmp -e ls

yaknewtab has many other options that were shown in help.

$ yaknewtab --help

  Usage: yaknewtab [options] [args]

    Options:
      -q                      Keep the Yakuake window hidden
      -e <cmd>                Command(s) to execute; this flag will catch all subsequent arguments, so must be called last
      -t <title>              Set <title> as the title of the new tab
      -p <property=value>     Change the value of a profile property (only for KDE 4)
      -h, --homedir           Open a new tab with '$HOME' as the working directory
      -w, --workdir <dir>     Open a new tab with <dir> as the working directory
      --hold, --noclose       Do not close the session automatically when the command ends
      --fish | --nofish       Manually enable or disable the fish shell autocompletion support
      --debug                 Redirect script debugging output to the console
      --help                  Print this message

    Arguments:
      args                    Arguments passed to command from '-e' flag

Action in Dolphin

Dolphin provides the action "Open terminal here" that opens a Konsole terminal emulator in the specified folder. This behavior can be changed to use Yakuake instead of Konsole coping konsolehere.desktop into KDE Service Menus.

# KDE 4
cp ServiceMenus/konsolehere.desktop ~/.kde/share/kde4/services/ServiceMenus/
# KDE 5: for the current user only.
cp ServiceMenus/konsolehere.desktop ~/.local/share/kservices5/ServiceMenus/

or

# KDE 5: system-wide
cp ServiceMenus/konsolehere.desktop /usr/share/kservices5/ServiceMenus/

If we do not want to change the behavior of "Open terminal here", then copy yaknewtab-here.desktop instead to add the new action "Open yakuake here" to Dolphin.

# KDE 4
cp ServiceMenus/yaknewtab-here.desktop ~/.kde/share/kde4/services/ServiceMenus/
# KDE 5
cp ServiceMenus/yaknewtab-here.desktop ~/.local/share/kservices5/ServiceMenus/

or

# KDE 5: system-wide
cp ServiceMenus/yakuakehere.desktop /usr/share/kservices5/ServiceMenus/

Quick Access Menu

Konsole Profiles is a Plasma widget that allows to open a new terminal window, configured according to a select profile, and automatically execute a command in it. We can get something similar but for Yakuake using the QuickAccess widget.

We only have to make a directory and setup a QuickAccess widget instance to use it as origin (I also like to disable the browsing). Then we add some "Link to Application" to that directory, such that each one use yaknewtab to create a new Yakuake session and to execute the command that we want.

The file examples/yaknewtab-ssh.desktop contains an example that launch a ssh client in a new Yakuake session.

Contributing and licensing

Feature Requests

Most recent contributor2nd most recent contributorThird most recent contributorFourth most recent contributorFifth most recent contributorSixth most recent contributorSeventh most recent contributorSourcerer.io Contributors Widget About Page

Contributors need to sign the Contributor License Agreement before their pull requests will be reviewed.


SPDX Logo SPDX-License-Identifier: GPL-3.0-or-later

GNU GPL-3.0 License Logo GNU FDL-1.3 License Logo

Contact

Keybase PGP Twitter Follow Say Thanks

Creative Commons ShareAlike Symbol-20px Copyleft: All rights reversed. 2019 Peter J. Mello

About

A script to create new yakuake sessions from command-line or '.desktop' files. It allows yakuake to be a better replacement of konsole.

Topics

Resources

License

GPL-3.0, GPL-3.0 licenses found

Licenses found

GPL-3.0
LICENSE
GPL-3.0
COPYING

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 58.0%
  • Shell 37.9%
  • Makefile 4.1%