howtos


HOWTO: Make Terminator Terminal Act Like Guake Terminal in Ubuntu 16.04 LTS (The easy ways) 3

First way to make terminator toggle its visibility using the F12 key (like guake)

  • Start terminator
  • Right click anywhere in the terminal area and click on the Preferences option

terminator-01

  • In the new window, click on the Keybindings tab and scroll down until you find the line that has the following information:
    Name : hide_window
    Action : Toggle window visibility

terminator-02

  • Click on the Keybinding column (3rd column), the value will change to New accelerator..., hit the key combination you want to be used to toggle the visibility of terminator. If you want the same behavior as guake, hit F12. You will see that the value in the Keybinding column will change to F12.
  • Hit the close button to close the settings window.
  • In the terminal try the key you just set (e.g F12) to see if it works. If it doesn’t work and in the case of F12 writes on the terminal a ~, close terminator and re-open it for the changes to get applied.

Second way to make terminator toggle its visibility using the F12 key (like guake)

  • Create the folder tree ~/.config/terminator (maybe it exists already). Please note that the . in front of config is purposely there, it is the way to hide a folder.
  • In the folder create a file named config (the full path would be ~/.config/terminator/config) and put the following as content:
[global_config]
[keybindings]
  hide_window = F12
[layouts]
  [[default]]
    [[[child1]]]
      parent = window0
      type = Terminal
    [[[window0]]]
      parent = ""
      type = Window
[plugins]
[profiles]
  [[default]]
  • Save the file and start terminator, pressing the F12 key should hide the terminal, pressing it once more should make it reappear.

HOWTO: Make Terminator Terminal Act Like Guake Terminal in Ubuntu 16.04 LTS (XenialXerus) Desktop edition x64 bit architecture 3

We propose an alternative solution to making terminator act like guake that requires two additional packages: xdotool and wmctrl.

Our proposal will launch terminator if there is not instance running.

In Ubuntu you can install the needed packages from the official repositories using sudo apt-get install xdotool wmctrl.

Using a text editor, create in you home folder a file named nano ~/toggle_visibility.sh and copy there the contents of the following chunk of code. You can also use nano, from a terminal issue nano ~/toggle_visibility.sh, then paste the code and hit CTRL+X to exit. When prompted if you want to save press ‘Y’ and hit enter.

#!/bin/bash

#The purpose of this script is to allow the user to toggle the visibility of (almost) any window.
#Please note it will work on the first match, so if there are multiple instances of an application it would be a random window of them the one to be affected.
#Usually it will control the window with the smallest PID.

#Checking that all dependencies are met, since we cannot proceed without them.
declare -a DEPENDENCIES=("xdotool" "wmctrl");
declare -a MANAGERS=("dnf" "apt-get");

for DEPENDENCY in ${DEPENDENCIES[@]}; do
    echo -n "Checking if $DEPENDENCY is available";
    if hash $DEPENDENCY 2>/dev/null; then
        echo "- OK, Found";
    else
        echo "- ERROR, Not Found in $PATH";
        for MANAGER in ${MANAGERS[@]}; do
            if hash $MANAGER 2>/dev/null; then
                echo -n "$DEPENDENCY is missing, would you like to try and install it via $MANAGER now? [Y/N] (default is Y): ";
                read ANSWER;
                if [[ "$ANSWER" == "Y" || "$ANSWER" == "y" || "$ANSWER" == "" ]]; then
                    sudo "$MANAGER" install "$DEPENDENCY";
                else
                    echo "Terminating";
                    exit -1;
                fi
            fi
        done
    fi
done

APPLICATION="$1";
FULL_COMMAND="$2";

#Checking if the application name provided by the user exists
if ! hash $APPLICATION 2>/dev/null; then
    echo -e "$APPLICATION does not seem to be a valid executable\nTerminating";
    exit -2;
fi

#Checking if the application is running.
PID=$(pgrep -u `whoami` -f "$FULL_COMMAND" | head -n 1);

#If the application is not running, we will try to launch it.
if [ -z $PID ]; then
  echo "$FULL_COMMAND not running, launching it..";
    $FULL_COMMAND;
else
    #Since the application has a live instance, we can proceed with the rest of the code.
    #We will get the PID of the application that is currently focused, if it is not the application we passed as parameter we will change the focus to that. In the other case, we will minimize the application.
  echo -n "$FULL_COMMAND instance found - ";
    FOCUSED=$(xdotool getactivewindow getwindowpid);
    if [[ $PID == $FOCUSED ]]; then
    echo "It was focused so we are minimizing it";
        #We minimize the active window which we know in this case that it is the application we passed as parameter.
        xdotool getactivewindow windowminimize;
    else
    echo "We are setting the focus on it";
        #We set the focus to the application we passed as parameter. If it is minimized it will be raised as well.
        wmctrl -x -R $APPLICATION;
    fi
fi

exit 0

Afterwards, you need to make the script an executable so you should issue chmod +x ~/toggle_visibility.sh to do that.

Then, execute ~/toggle_visibility.sh in your terminal once. We need to do that in order to install any missing dependencies for the tool.

Finally, you need to create a custom shortcut that will call the script using the key combination you like at any point.

To complete the procedure:

  1. Go to ‘System Settings’ either by clicking on the menu on the top right corner that looks like a light bulb or by issuing the following in a terminal unity-control-center to start the unity control center.
  2. In the newly appeared window, click on the ‘keyboard’ icon that is in the category ‘Hardware’.
  3. After that, click on the tab ‘Shortcuts’
  4. and on the left list, click on custom shortcuts.
  5. You will see a button with the + sign right next to the list, click that.
  6. In the dialog box that will appear enter the following:
    – In the name field enter anything you like. e.g ‘Toggle Terminator Visibility’
    – In the command field enter /home/<USER>/toggle_visibility.sh terminator "^/usr/bin/python /usr/bin/terminator$" where <USER> enter your own username.
    – Click apply.
  7. You will see a new row with two columns with the name you just set in the first column. Click on the second column, where it should say ‘Disabled’ and the press the key combination you want for toggling terminator e.g F12

You are ready to go 🙂

Just try the key combination you just provided and terminator will appear in front of you. Pressing it once more it will hide it.

NOTE: Please keep in mind that the above script can be used for other applications as well. In step 7, we gave as parameter the name of the application to be used, if you change that you could use it with other applications like Firefox.


Bash: Show GIT Remote Origin for each immediate subfolder

To print on screen all the immediate subfolders and their GIT Remote Origin URL configuration we used the following command

find . -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && echo '{}' && git config --get remote.origin.url" \;

We used the find general command to get all folders that are in depth 1, in other words all folders that are in the specific folder where we started the search.
In our case we used the dot as the starting folder which means that it will run the find in the same folder as we were navigating in.
We passed as a parameter the -type d to instruct find to show only folders and ignore the files.
The \( ! -name . \) prevents executing the command in current directory by removing it from the result set.
With the results we executed some commands on each.

Specifically, we created a new bash session for each result that navigated in the folder, printed out the name of the matched folder and then print the Remote Origin URL using the command git config --get remote.origin.url


Gnome3: How to scale background image 3

Issue in your terminal the following to change the mode of how the background is displayed

gsettings set org.gnome.desktop.background picture-options "scaled"

We used “scaled” which will center the image to and will resize it to fit the screen if needed.
You could use another option if you like. To get the full list of available options issue the following in your terminal.

gsettings range org.gnome.desktop.background picture-options

It will produce a list similar to this

enum

  • ‘none’
  • ‘wallpaper’
  • ‘centered’
  • ‘scaled’
  • ‘stretched’
  • ‘zoom’
  • ‘spanned’

To reset to the default option use the following

gsettings reset org.gnome.desktop.background picture-options