You are not logged in.

#1 2017-04-01 03:54:09

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 5,731
Website

~/.config/openbox/pipemenus.rc

During the app-install pipemenu development (graphics, multimedia...) we hit the problem that users would have apps they had no interest in installing stuck in the menu every time they opened it, as an item "install thisapp". This was fixed by providing a user config file ~/.config/openbox/pipemenus.rc where users could add or remove apps to taste.

Now all the uninstalled apps are hidden away in the "install" submenu, so IMO it doesn't matter so much if there are extra apps there.

Meanwhile, I've recently run into the problem of adding apps to the list with a BL upgrade. We can't edit users' existing pipemenus.rc even if bunsen-pipemenus is upgraded.

I'm thinking of including a default apps list inside each pipemenu script, leaving open to users the possibility of adding their own custom entries, but not of removing the default ones. (As I said above, uninstalled apps aren't visible unless you look for them.)

Another complication that arises if users can add any package they want, is that sometimes the command to run that app is not the same as the packagename. This makes the automatic pipe menu generation more complicated. It can be done if we have a lookup array of special app commands, but that can only be done if we know the apps on the list in advance. If users add some random package then we need a way they can also let the pipemenu know if it has some special command.

To take the current situation, eg with media players, there is an array in pipemenus.rc:

MM_APPS=( 'vlc' 'audacious' 'smplayer' 'gnome-mplayer' )

Say, they wanted to add 'oddplayer' whose command was 'oplay'. I was thinking MM_APPS could be made an associative array, like:

MM_APPS=( [vlc]= [audacious]= [smplayer]= [gnome-mplayer]= [oddplayer]='oplay' )

The appnames are the indexes, the entries the commands, but they only have to be defined if different from the packagenames. This would work, but the different syntax would break existing pipemenu.rc entries. neutral

Alternatively, an extra associative array giving commands only for packages where it was different:

CMDS=([oddplayer]='oplay')

Simpler, but an extra entry. (CMDS could be merged into the default list back in the pipemenu itself.)

Alternatively, just do away with pipemenus.rc altogether and let users manage with the default appslist which BL defines.

Any thoughts?


John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Offline

#2 2017-04-01 14:28:40

Sector11
The Tpyo Knig Mod
From: 77345 ¡#
Registered: 2015-08-20
Posts: 5,528

Re: ~/.config/openbox/pipemenus.rc

Just my personal opinion but ...

I think we are going a bit overboard with the 101 different pipemenus thing. (exaggeration  smile )
Install a default media player and let users delete it and add their own via apt, apt-get or synaptic if they want.

Ubuntu spoon feeds new users, let's leave a little brain game for the new users to at least learn some basics.

Again, I personally prefer to see "MPV" in my menus rather than "BL-MediaPlayer" or "Media Player", or Thunar over "BL-FileManager" or "File Manager".

Just MHO


BunsenLabs Forum Rules ---== I'm a Conky 1.9'er ==---
System:    Host: d67 Kernel: 4.9.0-9-amd64 x86_64 (64 bit gcc: 6.3.0)
Desktop: Openbox 3.6.1 Distro: Debian GNU/Linux 9 (stretch)

Offline

#3 2017-04-01 15:21:29

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 8,759
Website

Re: ~/.config/openbox/pipemenus.rc

I don't use the right-click menu, as a rule, and I certainly don't touch the pipemenus so I'm not sure I can have any useful input here, sorry.


“Et ignotas animum dimittit in artes.” — Ovid, Metamorphoses, VIII., 18.

Forum Rules   •   How to report a problem   •   Software that rocks

Offline

#4 2017-04-01 18:09:54

hhh
Meep!
Registered: 2015-09-17
Posts: 8,324
Website

Re: ~/.config/openbox/pipemenus.rc

@Hoas, me too, I find nested menus very clumsy (sorry!) and use xfce4-appfinder for apps I haven't assigned shortcut keys for. I guess that leaves me in favor of Option C, do away with pipemenus.rc.

We need input from people who love the right-click menu, though... how they organize it and whether the way BL has it configured helps or hinders that process. Chime in here, folks!

Another complication that arises... is that sometimes the command to run that app is not the same as the packagename.

GNOME. They're really putting a wall between the user and the OS, aren't they? What good is "Files" if you can't launch it from a terminal (nautilus --no-desktop) to see error messages? /rant

Offline

#5 2017-04-01 18:26:46

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 8,759
Website

Re: ~/.config/openbox/pipemenus.rc

I wrote:

The trick is to check the .desktop file and see what the Exec line uses wink

hhh wrote:

Of course EYE know that, you silly monkey

@n00bs, take note!

EDIT: big_smile

Last edited by Head_on_a_Stick (2017-04-01 19:24:34)


“Et ignotas animum dimittit in artes.” — Ovid, Metamorphoses, VIII., 18.

Forum Rules   •   How to report a problem   •   Software that rocks

Offline

#6 2017-04-02 06:36:46

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 5,731
Website

Re: ~/.config/openbox/pipemenus.rc

hhh wrote:

@Hoas, me too, I find nested menus very clumsy (sorry!) and use xfce4-appfinder for apps I haven't assigned shortcut keys for.

@hhh this reappraisal of the way pipemenus display apps was started because of your kind review of the recent experimental isos:

hhh wrote:

Mirage under Graphics, can we rename the menu entry to "Mirage Image Viewer" for clarity? If you install GIMP, Inkscape, etc... I'd expect you to know a bit about it, but Mirage comes OOTB, making the entry a bit cryptic IMO.

Mirage under Graphics = the output of the graphics pipemenu. What you're suggesting is easily done, but ties the tail "Image Viewer" permanently to Mirage, even if the user chooses eg GPicView as bl-image-viewer.

Right now I'm playing with a pipemenu (starting with multimedia in fact, because it's more complicated) that adds "Media Player" to whatever app the user has chosen as bl-media-player (ie "mpv Media Player" or "Vlc Media Player"...). It's doable, but does add some complication to the code. For example, bl-media-player is a Debian Alternative that points to a command under /usr/bin which then has to be translated into a packagename for the menu. (As mentioned above, commands and packagenames aren't always the same. Our new wrapper script for mpv, bl-mpv, is an example.)

When that trial media-pipemenu is done, I'll post it here for people to play with and comment on.

I guess that leaves me in favor of Option C, do away with pipemenus.rc.

That would certainly make life easier for pipemenu writers. I guess it comes down to how many users might want to use pipemenus.rc to tweak their apps menus, rather than installing directly with apt-get and editing their menus by hand. The former does preserve a neater appearance I suppose, with all media apps in the same submenu. The even more extreme option is to get rid of the apps pipemenus altogether and go back to hard-coded menus. yikes

We need input from people who love the right-click menu, though... how they organize it and whether the way BL has it configured helps or hinders that process. Chime in here, folks!

Please!

Another complication that arises... is that sometimes the command to run that app is not the same as the packagename.

GNOME. They're really putting a wall between the user and the OS, aren't they? What good is "Files" if you can't launch it from a terminal (nautilus --no-desktop) to see error messages? /rant

That wasn't quite what I meant. You're referring to the "Name" that is defined by the app's *.desktop file. I meant that the packagename itself is quite often different from the command(s) it provides. For example the package libreoffice-writer provides the command lowriter.


John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Offline

#7 2017-04-02 07:50:41

dolly
Miss Mixunderstand
From: /lab1
Registered: 2015-10-03
Posts: 368

Re: ~/.config/openbox/pipemenus.rc

Chiming in about how I do and feel about it. I use the right click menu quite a lot. And I like to edit it with "obmenu" and I prefer it static. Here I am mostly with Sector11, it is a bit over the top. No, it is not a problem for me with these extended pipemenus, just that they are getting a bit too much. Specially those with all the different install options. How needed or wanted are they really?

I do like the "recent files" and "places" and use them, also I think that the "help" can be good to have for obvious reasons.

Anyway, do what you want, or think are the best for BL, this is in no way a dealbreaker.  I am pretty sure it will be really cool and appreciated in the end. smile


Keep BunsenLabs #!yish please.

Offline

#8 2017-04-02 08:10:39

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 5,731
Website

Re: ~/.config/openbox/pipemenus.rc

^Thanks for the input dolly smile

Just as an example, here is a graphics pipemenu that adds "... Image Viewer" to the name of whatever app is chosen as bl-image-viewer, and puts it at the top of the graphics menu. Either overwrite /usr/bin/bl-graphics-pipemenu with it, or put it wherever you like and edit the graphics pipemenu entry in menu.xml with the right path. Or just add it as a new menu entry.

I guess this is exactly what dolly is saying is getting a bit too much, but anyway...

#!/bin/bash
#    bl-graphics-pipemenu - an Openbox pipemenu for Graphics applications
#    Copyright (C) 2012 Philip Newborough   <corenominal@corenominal.org>
#    Copyright (C) 2015-2016 damo    <damo@bunsenlabs.org>
#    Copyright (C) 2015-2017 John Crawley    <john@bunsenlabs.org>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.

#   To change the entries shown in the Graphics pipemenu:
#   edit ".config/openbox/pipemenus.rc"

HELP='    bl-graphics-pipemenu an Openbox Pipe Menu for graphics applications
    It should normally be called from an openbox menu.

Options (usually passed from the menu):
    -h --help   show this message
    --install   install a graphics-related package
    (the package must be in the list defined in the pipemenu config file)

    If bl-graphics-pipemenu is called with no options (the usual method),
    it will output an xml openbox pipemenu
    for launching and installing graphics applications.

See ~/.config/openbox/pipemenus.rc for configuration options.
'
# default apps lists
# user lists in ~/.config/openbox/pipemenus.rc will be merged
DEF_GRAPHICS_APPS=( 'mirage' 'gimp' 'blender' 'inkscape' 'mandelbulber' 'viewnior' 'gpicview')
DEF_GRAPHICS_SCROTS=('xfce4-screenshooter' 'scrot' )

# array: commands in menu which are different from package names
declare -A pkg_cmd=()

# look for a help option somewhere
for i in "$@"
do
    case "$i" in
    -h|--help)
        echo "$HELP"
        exit 0
        ;;
    esac
done

BL_COMMON_LIBDIR='/usr/lib/bunsen/common'
USR_CFG_DIR="$HOME/.config/openbox"

# Get $USER images directory
if type xdg-user-dir &>/dev/null; then
    IMGDIR=$(xdg-user-dir PICTURES)
else
    IMGDIR="~/Pictures"
fi
# test for screenshots dir, create if it doesn't exist
SCROTSDIR="$IMGDIR/screenshots"
mkdir -p "$SCROTSDIR"

# this array might be in $USR_CFG_DIR/pipemenus.rc
declare -A user_package_commands

if ! . "$BL_COMMON_LIBDIR/bl-include.cfg" 2> /dev/null; then
    echo $"Error: Failed to source bl-include.cfg in $BL_COMMON_LIBDIR" >&2
    exit 1
elif ! . "$USR_CFG_DIR/pipemenus.rc" 2> /dev/null; then
    echo $"Error: Failed to source pipemenus.rc in $USR_CFG_DIR" >&2
    exit 1
fi

# add any user-specified commands, overwriting defaults if set
for i in "${!user_package_commands[@]}"
do
    pkg_cmd[$i]="${user_package_commands[$i]}"
done

declare -A cmd_pkg=() # reverse lookup
for i in "${!pkg_cmd[@]}"
do
    cmd_pkg[${pkg_cmd[$i]}]="$i"
done

default_viewer_cmd=$(readlink -f /usr/bin/bl-image-viewer)
default_viewer_cmd="${default_viewer_cmd##*/}"
BL_VIEWER="${cmd_pkg[$default_viewer_cmd]:-$default_viewer_cmd}"

# fast check of package installed status (will move to bl-include.cfg)
allInstalled() {
    local pkg=
    for pkg in "$@"
    do
        [[ -f /var/lib/dpkg/info/${pkg}.list ]] || return 1
    done
    return 0
}

# remove duplicate members of array passed as $1, keep order
nodups(){
    local -A check
    local -n target_array="$1"
    for i in "${!target_array[@]}"
    do
        local content="${target_array[$i]}"
        if [[ ${check[$content]+x} = x ]]
        then
            unset target_array[$i]
        else
            check[$content]=1
        fi
    done
}

GRAPHICS_APPS=( "$BL_VIEWER" "${DEF_GRAPHICS_APPS[@]}" "${GRAPHICS_APPS[@]}" )
GRAPHICS_SCROTS=( "${DEF_GRAPHICS_SCROTS[@]}" "${GRAPHICS_SCROTS[@]}" )

for i in GRAPHICS_APPS GRAPHICS_SCROTS
do
    nodups "$i"
done

declare -A AppName AppStatus AppCmd # AppName: split on hyphens, first letter uppercase
for curApp in "${GRAPHICS_APPS[@]}" "${GRAPHICS_SCROTS[@]}"; do
    words=(${curApp//-/ })
    AppName[$curApp]="${words[*]^}"
    AppCmd[$curApp]="${pkg_cmd[$curApp]:-$curApp}" # use packagename as command if not defined in pkg_cmd
    allInstalled "$curApp" && AppStatus[$curApp]='installed'
    [[ $curApp = $BL_VIEWER ]] && AppName[$curApp]="${AppName[$curApp]} Image Viewer"
done

appExists() {
    for curApp in "${GRAPHICS_APPS[@]}"; do # if $packageName exists in GRAPHICS_APPS array
        [[ $curApp = "$1" ]] &&
            return 0
    done
    say "Unable to install $1. There is no such application that I know of." 1 >&2
    say "You can try one of these: ${GRAPHICS_APPS[*]}" 2 >&2
    return 1
}

screenshooterExists() {
    for curScrot in "${GRAPHICS_SCROTS[@]}"; do # if $packageName exists in GRAPHICS_SCROTS array
        [[ $curScrot = "$1" ]] &&
            return 0
    done
    say "Unable to install $1. There is no such application that I know of." 1 >&2
    say "You can try one of these: ${GRAPHICS_SCROTS[*]}" 2 >&2
    return 1
}

writeScrot() {                  # Write scrot submenu items
    IMG="$SCROTSDIR/%F-%H-%M-%S_scrot.png"
    VIEW="'bl-image-viewer $IMG'"
    menuSubmenu 'scrot' 'scrot Screenshooter'
        menuItem "scrot Now" "scrot $IMG -e $VIEW"
        menuItem "scrot In 5 secs..." "scrot -d 5 $IMG -e $VIEW"
        menuItem "scrot In 10 secs..." "scrot -d 10 $IMG -e $VIEW"
        menuItem "scrot Select Area" "scrot -s $IMG -e $VIEW"
        menuItem "scrot Current Focus" "scrot -u $IMG -e $VIEW"
        menuItem "scrot Multi-Monitor" "scrot -m $IMG -e $VIEW"
    menuSubmenuEnd
}

# If the package needs additional configuration before installation
# create a function called setupappName, it will be called automatically.

if [[ $1 = --install ]]; then
    packageName=$2
    appName=${AppName[$packageName]}
    if [[ $packageName = scrot || $packageName = xfce4-screenshooter ]];then
        screenshooterExists "$packageName" || exit 1
    else
        appExists "$packageName" || exit 1
    fi

    terminalCheck -T "Install $appName" "$@"

    desc="This script will install $appName."
    setupFunctionName="setup${appName//[^a-zA-Z]/}" # setupFunctionName should now be in format like 'setupBlender'
    if [[ $(type -t "$setupFunctionName") = 'function' ]]; then
        promptInstall --setup "$setupFunctionName" "$appName" "$desc" "$packageName"
    else
        if [[ $packageName = gimp ]] && prompt 'This will install GIMP. Do you also want to install Gimp Extras?' N; then
            appName="Gimp and Gimp Extras"
            packageNameSet=(gimp gimp-plugin-registry gimp-gmic)
            desc="This script will install gimp, gimp-plugin-registry and gimp-gmic"
            promptInstall "$appName" "$desc" "${packageNameSet[@]}"
        else
            promptInstall "$appName" "$desc" "$packageName"
        fi
    fi

elif [[ $1 ]]; then
    echo "$0: no such option $*" >&2
    exit 1

else # pipemenu
    menuStart
    for curApp in "${GRAPHICS_APPS[@]}"; do
        if [[ ${AppStatus[$curApp]} = installed ]]; then
            menuItem "${AppName[$curApp]}" "$curApp"
        fi
    done
    menu_started=false
    for curApp in "${GRAPHICS_APPS[@]}"; do
        if ! [[ ${AppStatus[$curApp]} = installed ]]; then
            $menu_started || menuSubmenu "graph-apps-install-submenu" "Install"
            menu_started=true
            menuItem "Install ${AppName[$curApp]}" "$0 --install $curApp"
        fi
    done
    $menu_started && menuSubmenuEnd

    menuSeparator 'Screenshots'

    for curScrot in "${GRAPHICS_SCROTS[@]}"; do
        if [[ ${AppStatus[$curScrot]} = installed ]]; then
            if [[ "$curScrot" = scrot ]];then
                writeScrot
            else
                menuItem "${AppName[$curScrot]}" "$curScrot"
            fi
        fi
    done
    menu_started=false
    for curScrot in "${GRAPHICS_SCROTS[@]}"; do
        if ! [[ ${AppStatus[$curScrot]} = installed ]]; then
            $menu_started || menuSubmenu "graph-scrots-install-submenu" "Install"
            menu_started=true
            menuItem "Install ${AppName[$curScrot]}" "$0 --install $curScrot"
        fi
    done
    $menu_started && menuSubmenuEnd
    menuEnd
fi
exit 0

John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Offline

#9 2017-04-02 11:13:39

thoro
Member
Registered: 2015-09-30
Posts: 37

Re: ~/.config/openbox/pipemenus.rc

Full ack! with Sector 11 and dolly. I'm not using all the app-install pipemenus and removed them from the configuration files. Software that I need, I install with apt or even synaptic.


"It's just your opinion, man!"

Offline

#10 2017-04-02 13:25:17

username
Member
Registered: 2016-02-13
Posts: 8

Re: ~/.config/openbox/pipemenus.rc

Usage wise I'm probably 50/50 between keyboard shortcut and
right click pipemenu. Similarly with editing them. Sometimes
it's obmenu other times I'll edit the config files by hand, just
depends on the mood.

Very much like having them there and don't think they're in any
way bloated (yet).

While it's not hard to see how they can soon use up plenty of
screenspace, as has been pointed out earlier, it's not hard
to trim them if you want rid of items. Thats all part of the charm
of user choice.

My twopenn'orth.

Offline

#11 2017-04-03 01:51:04

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 5,731
Website

Re: ~/.config/openbox/pipemenus.rc

Thanks everyone for your input!

Just to focus, my original question is: how much do people use pipemenus.rc to tweak the contents of their pipemenus?

EDIT: although, the pipemenu code I posted above copes with all situations anyway - when a user adds apps, it adds them to the list but if they do nothing they get the default list. The only functionality that gets removed is that users can't remove apps from the list. However, if they don't install them they stay hidden in the "install" submenu anyway.

Last edited by johnraff (2017-04-03 01:54:53)


John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Offline

#12 2017-04-03 02:09:57

Sector11
The Tpyo Knig Mod
From: 77345 ¡#
Registered: 2015-08-20
Posts: 5,528

Re: ~/.config/openbox/pipemenus.rc

johnraff wrote:

Just to focus, my original question is: how much do people use pipemenus.rc to tweak the contents of their pipemenus?

0%


BunsenLabs Forum Rules ---== I'm a Conky 1.9'er ==---
System:    Host: d67 Kernel: 4.9.0-9-amd64 x86_64 (64 bit gcc: 6.3.0)
Desktop: Openbox 3.6.1 Distro: Debian GNU/Linux 9 (stretch)

Offline

#13 2017-04-03 21:40:10

thoro
Member
Registered: 2015-09-30
Posts: 37

Re: ~/.config/openbox/pipemenus.rc

johnraff wrote:

Just to focus, my original question is: how much do people use pipemenus.rc to tweak the contents of their pipemenus?

0 %


"It's just your opinion, man!"

Offline

#14 2017-04-04 02:04:41

ututo
Member
Registered: 2015-09-29
Posts: 277

Re: ~/.config/openbox/pipemenus.rc

I use pipemenus.rc when I have to. I prefer to use obmenu instead, or edit menu.xml.
Every time I install BL I add a menu entry under Preferences > Openbox > "Edit pipemenus"
to execute ' bl-text-editor ~/.config/openbox/pipemenus.rc '


BunsenLabs on deviantArt
Don't touch my git!

Offline

#15 2017-04-04 05:13:36

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 5,731
Website

Re: ~/.config/openbox/pipemenus.rc

^ututo, I'm interested, what do you normally change in pipemenus.rc? Add some app that's not in the list, or remove one?

Would the ability to locally add apps to a default list be enough for you?

Last edited by johnraff (2017-04-04 05:14:23)


John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Offline

#16 2017-04-04 18:01:06

Sector11
The Tpyo Knig Mod
From: 77345 ¡#
Registered: 2015-08-20
Posts: 5,528

Re: ~/.config/openbox/pipemenus.rc

I have a really dumb question.  Where does this "pipemenus.rc" show itself?


BunsenLabs Forum Rules ---== I'm a Conky 1.9'er ==---
System:    Host: d67 Kernel: 4.9.0-9-amd64 x86_64 (64 bit gcc: 6.3.0)
Desktop: Openbox 3.6.1 Distro: Debian GNU/Linux 9 (stretch)

Offline

#17 2017-04-04 18:29:30

kozimodo
Member
Registered: 2015-10-04
Posts: 40

Re: ~/.config/openbox/pipemenus.rc

I don't use the stock menu.xml at all and on any fresh install of Bunsenlabs, one of my first tasks is to install obmenu-generator.  Works, seems reasonably quick and obviates the need to edit files every time a package is installed or uninstalled.

Offline

#18 2017-04-04 19:15:00

ututo
Member
Registered: 2015-09-29
Posts: 277

Re: ~/.config/openbox/pipemenus.rc

johnraff wrote:

^ututo, I'm interested, what do you normally change in pipemenus.rc? Add some app that's not in the list, or remove one?

Nope, I don't remove any app. I just add the ones that are not listed, like spotify in the MM_APPS  for example.

johnraff wrote:

Would the ability to locally add apps to a default list be enough for you?

Sounds good to me. Like I said before, I don't mind to edit pipemenus or menu.xml. But I do prefer to use obmenu.

Sometimes I'm too lazy and when I install an app I don't add it to the menu and just launch it via gmrun or dmenu. I think that at some point there should be an option to automatically generate a menu like obamenu or obmenu-generator as @kozimodo said.

Sector11 wrote:

I have a really dumb question.  Where does this "pipemenus.rc" show itself?

I read about it in Help > Bunsen Help Files > How to Edit Menu. I don't think it has its own entry so i created one for it.


BunsenLabs on deviantArt
Don't touch my git!

Offline

#19 2017-04-05 19:18:59

damo
....moderator....
Registered: 2015-08-20
Posts: 5,059

Re: ~/.config/openbox/pipemenus.rc

'pipemenus.rc' is in '~/.config/openbox/', and as mentioned its use is explained in the Help menu item.

IIRC it was originally envisaged as a help for a) new users, to see what the defaults are, or might be available, and b) the devs, so a default app change only needs an edit to the rc file.

FWIW I use Openbox exclusively, and r-click/super+Space all the time. I manually tweak the menu.xml or the pipemenus for my particular needs, but don't need to edit pipemenus.rc.


Be Excellent to Each Other...

FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Online

#20 2017-04-06 02:38:27

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 5,731
Website

Re: ~/.config/openbox/pipemenus.rc

What I remember about the birth of pipemenus.rc was that with the early pipemenus, every app would have an entry at the top level (of the pipemenu), either "Thisapp" if it was installed, or "Install Thisapp" if it wasn't. That meant, for some users, the menu was always clogged up with apps that they had no interest in ever installing. pipemenus.rc let them remove those apps altogether.

Later, though, the "install" entries were all moved to an "install" submenu, where they aren't so much in your face. I think that makes the remove apps function of pipemenus.rc less urgent.

What I'm currently thinking of, and suggesting here, is that the default list of apps returns to the pipemeu script itself, but that users can optionally add their own apps to it with pipemenus.rc. If the file is missing from ~/.config/openbox/ it will be silently ignored, likewise if all the user list entries are empty. If any app in a users list duplicates one in the default list, two menu items will not be generated. The advantage of having the apps list in the system file bl-something-pipemenu is that if an app breaks we can leave it off and if a super cool new one appears we can add it on, and the new menus will appear on users desktops after a package upgrade.

Want to check out an example of what bl-multimedia-pipemenu might be? Copy the code below. Try changing your chosen bl-media-player in Galternatives and see how the menu reacts. Try adding a new app in pipemenus.rc - it should still be added to the menu as before. (Then try installing it.)

I might also try putting something like this in the next experimental iso, for feedback. There's still time to change it.

#!/bin/bash
#    bl-multimedia-pipemenu - an Openbox pipemenu for Multimedia applications
#    Copyright (C) 2012 Philip Newborough   <corenominal@corenominal.org>
#    Copyright (C) 2015 damo    <damo@bunsenlabs.org>
#    Copyright (C) 2015-2017 John Crawley    <john@bunsenlabs.org>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.

#   To add to the entries shown in the Multimedia pipemenu:
#   edit ".config/openbox/pipemenus.rc"

HELP='    bl-multimedia-pipemenu an Openbox Pipe Menu for multimedia applications
    It should normally be called from an openbox menu.

Options (usually passed from the menu):
    -h --help   show this message
    --install   install a multimedia package
    (the package must be in the list defined in the pipemenu config file
     or in the default list in this file)

    If bl-multimedia-pipemenu is called with no options (the usual method),
    it will output an xml openbox pipemenu
    for launching and installing multimedia applications.

See ~/.config/openbox/pipemenus.rc for configuration options.
'

# default apps lists
# user lists in ~/.config/openbox/pipemenus.rc will be merged
DEF_MM_APPS=('mpv' 'vlc' 'audacious' 'smplayer' 'gnome-mplayer')
DEF_MM_EDITORS=('mhwaveedit' 'audacity' 'openshot')
DEF_MM_UTILS=('xfburn' 'gtk-recordmydesktop')

# array: commands in menu which are different from package names
declare -A pkg_cmd=([mpv]='bl-mpv')

# look for a help option somewhere
for i in "$@"
do
    case "$i" in
    -h|--help)
        echo "$HELP"
        exit 0
        ;;
    esac
done

BL_COMMON_LIBDIR='/usr/lib/bunsen/common'
USR_CFG_DIR="$HOME/.config/openbox"

# this array might be in $USR_CFG_DIR/pipemenus.rc
declare -A user_package_commands

if ! . "$BL_COMMON_LIBDIR/bl-include.cfg" 2> /dev/null; then
    echo "Error: Failed to source bl-include.cfg in $BL_COMMON_LIBDIR" >&2
    exit 1
elif ! . "$USR_CFG_DIR/pipemenus.rc" 2> /dev/null; then
    echo "Failed to source pipemenus.rc in $USR_CFG_DIR" >&2
fi

# add any user-specified commands, overwriting defaults if set
for i in "${!user_package_commands[@]}"
do
    [[ -n ${user_package_commands[$i]} ]] || continue
    pkg_cmd[$i]="${user_package_commands[$i]}"
done

# get BL alternatives player
bl_mp_cmd=$(readlink -f /usr/bin/bl-media-player)
bl_mp_cmd="${bl_mp_cmd##*/}"

BL_MM_APP=
for i in "${DEF_MM_APPS[@]}" "${MM_APPS[@]}"
do
    [[ ${pkg_cmd[$i]:-$i} = "$bl_mp_cmd" ]] && {
        BL_MM_APP=$i
        break
    }
done

# remove duplicate, and null, values of array passed as $1, keep order
nodups(){
    local -A check
    local -n target_array="$1"
    for i in "${!target_array[@]}"
    do
        local value="${target_array[$i]}"
        if [[ -z $value || ${check[$value]+x} = x ]]
        then
            unset target_array[$i]
        else
            check[$value]=1
        fi
    done
}

installed(){
    local list="/var/lib/dpkg/info/${1}.list"
    [[ -f "${list}" ]] || return 1
    grep -Evq '/etc($|/)' "${list}" || return 1
    return 0
}

MM_APPS=( "$BL_MM_APP" "${DEF_MM_APPS[@]}" "${MM_APPS[@]}" )
MM_EDITORS=( "${DEF_MM_EDITORS[@]}" "${MM_EDITORS[@]}" )
MM_UTILS=( "${DEF_MM_UTILS[@]}" "${MM_UTILS[@]}" )

for i in MM_APPS MM_EDITORS MM_UTILS
do
    nodups "$i"
done

declare -A AppName AppStatus AppCmd # AppName: split on hyphens, first letter uppercase
for curApp in "${MM_APPS[@]}" "${MM_EDITORS[@]}" "${MM_UTILS[@]}"; do
    words=(${curApp//-/ })
    AppName[$curApp]="${words[*]^}"
    AppCmd[$curApp]="${pkg_cmd[$curApp]:-$curApp}" # use packagename as command if not defined in pkg_cmd
    installed "$curApp" && AppStatus[$curApp]='installed' || AppStatus[$curApp]=''
    [[ $curApp = "$BL_MM_APP" ]] && AppName[$curApp]="${AppName[$curApp]} Media Player"
done

appExists() {
    for curApp in "${!AppName[@]}"; do # if $packageName exists in MM_APPS MM_EDITORS MM_UTILS arrays
        [[ $curApp = "$1" ]] &&
            return 0
    done
    say "Unable to install $1. There is no such application that I know of." 1 >&2
    say "You can try one of these: ${MM_APPS[*]} ${MM_EDITORS[*]} ${MM_UTILS[*]}" 2 >&2
    return 1
}

# If the package needs additional configuration before installation
# create a function called setupappName, it will be called automatically.

if [[ ${1-} = --install ]]; then
    packageName=$2
    appName=${AppName[$packageName]}
    appExists "$packageName" || exit 1

    terminalCheck -T "Install $appName" "$@"

    desc="This script will install $appName."
    setupFunctionName="setup${appName//[^a-zA-Z]/}" # setupFunctionName should now be in format like 'setupChromium'
    if [[ $(type -t "$setupFunctionName") = 'function' ]]; then
        promptInstall --setup "$setupFunctionName" "$appName" "$desc" "$packageName"
    else
        promptInstall "$appName" "$desc" "$packageName"
    fi

elif [[ ${1-} ]]; then
    echo "$0: no such option $*" >&2
    exit 1

else # pipemenu
    menuStart

    for curApp in "${MM_APPS[@]}"; do
        if [[ ${AppStatus[$curApp]} = installed ]]; then
            menuItem "${AppName[$curApp]}" "${AppCmd[$curApp]}"
        fi
    done

    menuSeparator
    menuSeparator 'Editors'
    for curApp in "${MM_EDITORS[@]}"; do
        if [[ ${AppStatus[$curApp]} = installed ]]; then
            menuItem "${AppName[$curApp]}" "${AppCmd[$curApp]}"
        fi
    done

    menuSeparator
    menuSeparator 'Utilities'
    for curApp in "${MM_UTILS[@]}"; do
        if [[ ${AppStatus[$curApp]} = installed ]]; then
            menuItem "${AppName[$curApp]}" "${AppCmd[$curApp]}"
        fi
    done

    install_menu_started=false

    for curApp in "${MM_APPS[@]}"; do
        if ! [[ ${AppStatus[$curApp]} = installed ]]; then
            $install_menu_started || { menuSeparator; menuSubmenu "mm-install-submenu" "Install";}
            install_menu_started=true
            menuItem "Install ${AppName[$curApp]}" "$0 --install $curApp"
        fi
    done

    editors_menu_started=false
    for curApp in "${MM_EDITORS[@]}"; do
        if ! [[ ${AppStatus[$curApp]} = installed ]]; then
            $install_menu_started || { menuSeparator; menuSubmenu "mm-install-submenu" "Install";}
            $editors_menu_started || menuSeparator 'Editors'
            install_menu_started=true
            editors_menu_started=true
            menuItem "Install ${AppName[$curApp]}" "$0 --install $curApp"
        fi
    done

    utils_menu_started=false
    for curApp in "${MM_UTILS[@]}"; do
        if ! [[ ${AppStatus[$curApp]} = installed ]]; then
            $install_menu_started || { menuSeparator; menuSubmenu "mm-install-submenu" "Install";}
            $utils_menu_started || menuSeparator 'Utilities'
            install_menu_started=true
            utils_menu_started=true
            menuItem "Install ${AppName[$curApp]}" "$0 --install $curApp"
        fi
    done

    $install_menu_started && menuSubmenuEnd

    menuEnd
fi
exit 0

John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Offline

#21 2017-04-06 10:23:45

damo
....moderator....
Registered: 2015-08-20
Posts: 5,059

Re: ~/.config/openbox/pipemenus.rc

^ That seems to work really well - good job! smile


Be Excellent to Each Other...

FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Online

#22 2017-04-06 22:15:00

dbvolvox
Member
Registered: 2015-09-29
Posts: 52

Re: ~/.config/openbox/pipemenus.rc

For me BL is what I use for my daily work, always with the menu, and although I read these forums regularly I am not installing new software very often (actually hardly at all) so when I do editing menu.xml is OK.

Offline

Board footer

Powered by FluxBB