Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

So, we have the Tabs Outliner extension

https://chrome.google.com/webstore/detail/tabs-outliner/eggkanocgddhmamlbiijnphhppkpkmkl

That is a very good vertical tabs manager for chromium. The problem is it occupies too much screen, and I dont have a widescreen monitor. So it is a new chrome window that would be visible all the time, occupying the left side of the screen.

The problem is: how make it hide automatically after you move your mouse away from it, and after you double click on one of its listed tabs?

share|improve this question
add comment

1 Answer

ok, I managed to code a script for that, you may find it usefull to provide similar functionality to other situations. If yo do so I would like to know too :)

Also if there is a better way to do that I would like to know too :)

the beggining variables are your options

#!/bin/bash -i

waitStart=5
delayRaiseTabOutliner=0.1
screenLeftMarginOpen=10
screenLeftMarginClose=200
bUseScreenLeftMarginClose=false
bGoToChromiumWhenTablinkIsDoubleClicked=true

function FUNCparent() {
    xwininfo -tree -id $1 |grep "Parent window id"
}
function FUNCparentest() {
    local check=`printf %d $1`
    local parent=-1
    local parentest=-1

    #echo "Child is: $check" >&2

    while ! FUNCparent $check |grep -q "(the root window)"; do
      #echo "a $check" >&2 #DEBUG info
        xwininfo -id $check |grep "Window id" >&2 #report
        parent=`FUNCparent $check |egrep -o "0x[^ ]* "`
        parent=`printf %d $parent`
        check=$parent
        sleep 1
    done
    if((parent!=-1));then
        parentest=$parent
    fi

    if((parentest!=-1));then
        echo $parentest
        #echo "Parentest is: $check" >&2
    else
        echo $1
        #echo "Child has no parent." >&2
    fi
}

while true; do
    list=(`xdotool search Chromium 2>/dev/null`)
    chromiumWindowId=""
    for windowId in `echo ${list[*]}`; do 
        if xwininfo -id $windowId |grep "Window id" |egrep -oq " - Chromium\"$"; then
            chromiumWindowId=$windowId
            xwininfo -id $chromiumWindowId |grep "Window id" #report
            break;
        fi
    done
    if [[ -z "$chromiumWindowId" ]]; then
        sleep $waitStart
        continue;
    fi

    list=(`xdotool search "Tabs Outliner" 2>/dev/null`)
    tabsOutlinerWindowId=""
    for windowId in `echo ${list[*]}`; do 
        if xwininfo -id $windowId |grep "Window id" |egrep -oq "\"Tabs Outliner\"$"; then
            tabsOutlinerWindowId=`FUNCparentest $windowId`
            xwininfo -id $tabsOutlinerWindowId |grep "Window id" #report
            break;
        fi
    done
    if [[ -z "$tabsOutlinerWindowId" ]]; then
        sleep $waitStart
        continue;
    fi

    previousWindowId=-1
    previousChromeTabName=""
    while true; do
        # check if chromium is still running
        if ! xdotool getwindowname $chromiumWindowId 2>&1 >/dev/null; then
            break;
        fi
        if ! xdotool getwindowname $tabsOutlinerWindowId 2>&1 >/dev/null; then
            break;
        fi

        # info about window below mouse (even if have not focus)
        eval `xdotool getmouselocation --shell 2>/dev/null`
        windowId=$WINDOW
        mouseX=$X
        mouseY=$Y

# not working yet...        
        # must work only if over chromium application windows
        #activeWindow=`xdotool getactivewindow`
        #activeWindow=`FUNCparentest $activeWindow`

        #echo "windowId=$windowId, chromiumWindowId=$chromiumWindowId, tabsOutlinerWindowId=$tabsOutlinerWindowId, previousWindowId=$previousWindowId, activeWindow=$activeWindow" #DEBUG info

# not working yet...        
        # only allowed to work if chromium windows has focus
#       if((activeWindow!=chromiumWindowId && activeWindow!=tabsOutlinerWindowId));then
#           sleep $delayRaiseTabOutliner
#           continue
#       fi
        #echo "Chromium app is active."

        # from chromium to tabs outliner!
        if((windowId==chromiumWindowId));then
            if((mouseX<screenLeftMarginOpen));then
                xdotool windowactivate $tabsOutlinerWindowId
                echo "activate TabOutliner (`date`)"
            fi
        fi

        # from tabs outliner to chromium
        bActivatedChromium=false
        # when a tabs outliner tab is double clicked, it changes chromium window current tab!
        if $bGoToChromiumWhenTablinkIsDoubleClicked; then
            if((windowId==tabsOutlinerWindowId));then
                currentChromeTabName=`xprop -id $chromiumWindowId |grep "^WM_NAME(STRING) = \""`
                if [[ -z "$previousChromeTabName" ]]; then
                    previousChromeTabName="$currentChromeTabName"
                fi
                if [[ "$currentChromeTabName" != "$previousChromeTabName" ]]; then
                    xdotool windowactivate $chromiumWindowId
                    bActivatedChromium=true
                fi
                previousChromeTabName="$currentChromeTabName"
            fi
        fi

        if $bUseScreenLeftMarginClose;then
            if((windowId==tabsOutlinerWindowId));then
                if((mouseX>screenLeftMarginClose));then
                    xdotool windowactivate $chromiumWindowId
                    bActivatedChromium=true
                fi
            fi
        else
            if((previousWindowId==tabsOutlinerWindowId));then
                if((windowId==chromiumWindowId));then
                    xdotool windowactivate $chromiumWindowId
                    bActivatedChromium=true
                fi
            fi
        fi

        if $bActivatedChromium; then
            echo "activate Chromium (`date`)"
        fi

        previousWindowId=$windowId

        sleep $delayRaiseTabOutliner
    done
done
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.