1

How would one make icons on the launcher jump to the top of the launcher when switching to a window using Alt+Tab or by clicking that window's icon on the launcher ?

1 Answer 1

1

Introduction

The script bellow makes the icon of currently active window float to the top of the launcher. It can be ran manually or as part of startup applications to start with the user session.

Setup

User can copy the script source from here, or obtain copy of the script through git:

  1. sudo apt-get install git
  2. cd /opt ; sudo git clone https://github.com/SergKolo/sergrep.git
  3. sudo chmod -R +x sergrep

The script file is /opt/sergrep/float_active_app.sh

To make the script start automatically on every login, refer to How do I start applications automatically on login? . Provide /opt/sergrep/float_active_app.sh (full path) as the command

Source

#!/usr/bin/env bash
#
###########################################################
# Author: Serg Kolo , contact: [email protected] 
# Date: April 9 , 2016
# Purpose: Make the icon of currently active app float to
#          the top of unity launcher
# Written for: 
# Tested on: Ubuntu 14.04 LTS
###########################################################
# Copyright: Serg Kolo , 2016
#    
#     Permission to use, copy, modify, and distribute this software is hereby granted
#     without fee, provided that  the copyright notice above and this permission statement
#     appear in all copies.
#
#     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#     IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
#     THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#     LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
#     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
#     DEALINGS IN THE SOFTWARE.

ARGV0="$0"
ARGC=$#
get_active_app()
{
  qdbus org.ayatana.bamf /org/ayatana/bamf/matcher \
      org.ayatana.bamf.matcher.ActiveApplication 
}

get_active_desktop_file()
{
  active_app=$(get_active_app)
  if [ -n "$active_app"  ];then
     qdbus org.ayatana.bamf "$active_app" \
        org.ayatana.bamf.application.DesktopFile | \
        awk -F '/' '{print "application://"$NF}'
  fi
}

get_launcher_items()
{
  gsettings get com.canonical.Unity.Launcher favorites | \
     awk '{ gsub(/,|\[|\]/,""); print}'
}

make_new_list()
{
 
 array=( $( get_launcher_items ) )
 printf "%s, " "$active"
 COUNT=0
 for item in ${array[@]} ; do
   COUNT=$(($COUNT+1))

   if [ "$item" = "$active"   ];then
     continue
   fi

   if [ $COUNT -eq ${#array[@]}  ];then
      printf "%s " "$item"
   else
      printf "%s, " "$item"
   fi
 done
}

set_launcher_items()
{
  gsettings set com.canonical.Unity.Launcher favorites "$1"
}

main()
{
  local active=""
  while true;
  do 
    active="'$(get_active_desktop_file)'"
    if [ "$active" = "'application://compiz.desktop'" ] || [ -z "$active"   ] ;then
       continue
    fi
    new_list="[$(make_new_list)]"
    set_launcher_items "$new_list"
  sleep 0.25
  done
}

main
2
  • What would I need to do to get the icons of all the currently active apps to move to the top of the side bar. For example if I have 4 applications running then I want all 4 of their icons to appear at the top rather than them stacked up around the bottom.
    – Ghos3t
    May 1, 2017 at 8:23
  • @user258365 You probably are asking same thing as this post askubuntu.com/q/858502/295286 May 1, 2017 at 8:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .