Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bl-tint2-pipemenu when running default tint2 does not find config file to edit #33

Closed
johnraff opened this issue Jul 4, 2015 · 5 comments

Comments

@johnraff
Copy link
Member

johnraff commented Jul 4, 2015

When running a new install, the command in ~/.config/openbox/autostart to launch tint2 is (sleep 2s && bl-tint2-session) &
If there is no session file, then bl-tint2-session runs the command tint2 with no config file defined. tint2 will then load the default ~/.config/tint2/tint2rc.

Now, on the menu Settings > Tint2>Edit Tint2s > Running Tint2s offers to edit the file tint2/tint2
Clicking this opens the non-existent file ~/tint2

The problem comes from loadTEditmenu() in bl-tint2-pipemenu:

loadTEditmenu(){
    menuSeparator 
    menuItem "Default tint2rc" "bl-text-editor $TINT2RC"
    if [ "$(pidof tint2)" ];then
        menuSubmenu "RunningTint2" "Running Tint2s"
        pgrep -a tint2 | while read pid cmd; do 
            if [[ ${cmd%% *} = tint2 ]]; then
                TINT2=$(echo $cmd | awk -F"/" '{print $(NF-1)"/"$NF}')
                TINT=$(echo $cmd | awk '{print $NF}')
                menuItem "$TINT2" "bl-text-editor $TINT"
            fi
        done
        menuSubmenuEnd
    fi
}

pgrep -a tint2 returns:

7135 /bin/bash /usr/bin/bl-tint2-session
7228 tint2

The awk lines above are returning tint2/tint2 and tint2 respectively, while what is desired in this case is something like default tint2rc' and~/.config/tint2/tint2rc`.

SUGGEST: either amend loadTEditmenu() to set the default tint2rc when no config file is in the command line, or perhaps ship a default tint2 session file (although the problem with loadTEditmenu() would remain in that case).

@capn-damo
Copy link
Contributor

Immediate fix is

loadTEditmenu(){
    menuSeparator 
    menuItem "Default tint2rc" "bl-text-editor $TINT2RC"
    if [ "$(pidof tint2)" ];then
        menuSubmenu "RunningTint2" "Running Tint2s"
        pgrep -a tint2 | while read pid cmd; do 
            if [[ ${cmd%% *} = tint2 ]]; then
                TINT2=$(echo $cmd | awk -F"/" '{print $(NF-1)"/"$NF}')
                TINT=$(echo $cmd | awk '{print $NF}')
                if [[ $TINT2 = "tint2/tint2" ]];then
                    TINT="$TINT2RC"
                    TINT2="Default tint2rc"
                fi
                menuItem "$TINT2" "bl-text-editor $TINT"
            fi
        done
        menuSubmenuEnd
    fi
}

A sessionfile only has the paths to the chosen tint2's, so a default tint2-sessionfile would just contain the line
/home/user/.config/tint2/tint2rc

@johnraff
Copy link
Member Author

johnraff commented Jul 5, 2015

btw it's possible to get rid of the awk calls:
TINT=${cmd##* }
TINT2=${TINT#$HOME/.config/}
if [[ $TINT = tint2 ]]; then...

@capn-damo
Copy link
Contributor

btw it's possible to get rid of the awk calls:

...but I find it difficult getting my head around those bash substitutions!

@johnraff
Copy link
Member Author

johnraff commented Jul 5, 2015

Much nicer looking though - and faster too, if that matters.
Easy enough once you get the hang of it:
http://wiki.bash-hackers.org/syntax/pe#substring_removal

@capn-damo
Copy link
Contributor

Edited bl-tint2-pipemenu and pushed changes.

@johnraff johnraff closed this as completed Jul 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants