BunsenLabs / bunsen-pipemenus

A collection of Openbox pipemenus for use with BunsenLabs
https://pkg.bunsenlabs.org/debian/pool/main/b/bunsen-pipemenus/
GNU General Public License v3.0
29 stars 11 forks source link

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

Closed johnraff closed 9 years ago

johnraff commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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

capn-damo commented 9 years ago

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

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

johnraff commented 9 years ago

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 commented 9 years ago

Edited bl-tint2-pipemenu and pushed changes.