Author Topic: A categorized desktop menu for i3 using dmenu (or rofi or something else)  (Read 10492 times)

0 Members and 1 Guest are viewing this topic.

Offline oberon

  • Core Team
  • *****
  • Posts: 3858
  • I'm nice. Be new!
  • Branch: unstable
  • Desktop: i3, Deepin, Cinnamon
  • GPU Card: Intel ValleyView Gen7
  • GPU driver: Intel
  • Kernel: 4.1 / 4.4
  • Skill: Intermediate
I'm not sure if the first command is correct. I assume buld was a typo, so I used
Code: [Select]
[bernhard@manjaro-i3 ~]$ morc_menu build all
[bernhard@manjaro-i3 ~]$
This takes about one second.

Then
Code: [Select]
morc_menu txtreturns this immediately:
manjaro is addictive ::)
* manjaro-i3  * manjaro-cinnamon  * manjaro-deepin

Offline oberon

  • Core Team
  • *****
  • Posts: 3858
  • I'm nice. Be new!
  • Branch: unstable
  • Desktop: i3, Deepin, Cinnamon
  • GPU Card: Intel ValleyView Gen7
  • GPU driver: Intel
  • Kernel: 4.1 / 4.4
  • Skill: Intermediate
I'm not sure if the first command is correct.
Apparently it was correct - I only see now that this wrote a file 'all' containing the menu information ;) ;D
manjaro is addictive ::)
* manjaro-i3  * manjaro-cinnamon  * manjaro-deepin

Offline boruch

  • Jr. Mitglied
  • **
  • Posts: 85
  • Skill: Intermediate
@Oberon - Great. I wrote the program, and I forget how to use it!

 'build_all' is the internal function name, not the command option (see 'morc_menu --help'), so what I should have told you to do was run 'morc_menu build' and then 'morc_menu txt'.

Thanks for posting the screenshot of the error message. I need to update it to read "morc_menu" instead of "categorized menu", and set it to be certain to display the entire file name that it failed to read.

Offline boruch

  • Jr. Mitglied
  • **
  • Posts: 85
  • Skill: Intermediate
Update on the project and its defaults
« Reply #18 on: 14. March 2016, 23:52:42 »
It's been a constructive day: I've fixed all reported bugs in morc_menu, and made some significant changes to morc_menu defaults and documentation. Here's why, what they are, and how to easily undo them:

I received a report that morc_menu was only working in patched versions of dmenu, but not the plain basic version, and sure enough the report was accurate. Manjaro i3 distributes a patched version (called package dmenu-manjaro), while my Manjaro OpenRC XFCE box has the unpatched one (called package dmenu). This left me faced with a choice of OTOH having the default config showing off only limited features, but working for everyone, or OTOH having it show off all the cool features only for those with the particular patched version of dmenu.

I chose the first option, and left a clearly labeled line in the config file for everyone using Manjaro i3, or dmenu-manjaro, or other patched versions of dmenu. I also tried to clearly write, in a place most people would notice, about the differences in morc_menu features depending upon the version of dmenu, and to recommend dmenu-manjaro over plain dmenu. OTOH, I was concerned that people often lose interest if something doesn't work at first run, but OTOH morc_menu is so much nicer with the added patches of dmenu-manjaro.

So there you have it. The latest and greatest is available at: https://github.com/Boruch-Baum/morc_menu

Offline oberon

  • Core Team
  • *****
  • Posts: 3858
  • I'm nice. Be new!
  • Branch: unstable
  • Desktop: i3, Deepin, Cinnamon
  • GPU Card: Intel ValleyView Gen7
  • GPU driver: Intel
  • Kernel: 4.1 / 4.4
  • Skill: Intermediate
Thank you very much, @boruch! I will clone and test the update! :)
manjaro is addictive ::)
* manjaro-i3  * manjaro-cinnamon  * manjaro-deepin

Offline Chrysostomus

  • Maintainer
  • ***
  • Posts: 1634
  • Neckbeards are cool
    • Git
  • Branch: unstable
  • Desktop: Gnome, bspwm
  • GPU Card: Intel HD4000
  • GPU driver: free
  • Kernel: linux44-x64
  • Skill: Intermediate
Do you mind if I package this and add it to manjaro repos? I'm about to release next bspwm edition, and I would really like to include this on it. From my point of view it already quite usable.

Offline boruch

  • Jr. Mitglied
  • **
  • Posts: 85
  • Skill: Intermediate
Do you mind if I package this and add it to manjaro repos? I'm about to release next bspwm edition, and I would really like to include this on it. From my point of view it already quite usable.
Please do. I had originally wanted to try doing it myself, as an exercise to learn how to package for Manjaro/Arch, but I haven't started yet, and I understand that you're working on a timeline for manjaro-bspwm, so please, go right ahead. I'll learn from your work.

What seems to me to be the major packaging issue is possibly patching the configuration file default for the added capabilities of package dmenu-manjaro instead of manjaro. Let me explain the issue:

The Manjaro/Arch/AUR repositories have two versions of dmenu: 'dmenu' and 'dmenu-manjaro', where 'dmneu-manjaro' has additional features for positioning and sizing dmenu. dmenu-manjaro is backward-compatible with dmenu, but if you try to use the additional dmenu-manjaro options in the plain package 'dmenu', then dmenu will fail. [At least at this point, ] Both packages use the same executable name, so one can not have both packages installed and working at the same time. I originally did not know any of this, and wrote morc_menu to default to using package dmenu-manjaro. Once I learned of the difference, I changed the DEFAULT to be compatible with plain dmenu, but for the user, the difference is a single line in the configuration file to un-comment. (see this thread, three messages previous)

My opinion is that the manjaro packaging should DEPEND primarily on package dmenu-manjaro, but that would best be done along with a build-time patch to the morc_menu configuration file (uncommenting a line so that the benefits of dmenu-manjaro are used by default). In debian, that kind of patching is standard practice, so I know how to do that for debian, but it's one of the things I don't know about manjaro/arch yet.

The bigger picture is what to do for people who don't have access to package dmenu-manjaro, or don't want it. Should package dmenu (plain) be offered as a secondary dependency option? Should package rofi be offered as an dependency option? [I also need to make the confguration example for rofi prettier]

Those were some of the things I was planning to deal with, but like I said, I haven't even started, and I've never done it before, and I understand your time-crunch, so anything you do would be great.

Offline Chrysostomus

  • Maintainer
  • ***
  • Posts: 1634
  • Neckbeards are cool
    • Git
  • Branch: unstable
  • Desktop: Gnome, bspwm
  • GPU Card: Intel HD4000
  • GPU driver: free
  • Kernel: linux44-x64
  • Skill: Intermediate
I know about the difference, I was patching dmenu-manjaro myself  :).

I think patching is unnecessary, because any manjaro editions using it can provide modified confoguration file at iso build time. We could add patched dmenus as optdepends (there are three sufficiently patched dmemus in aur that can be used if dmenu-manjaro is missing) and keep dmenu as hard dependency in the aur version. For manjaro version we can make it just depend on dmenu-manjaro. Dmenu-manjaro provides dmenu, so it will not break any dependencies.

I'm not yet very good at scripting, so this is how I usually do packaging:
1) find a pkgbuild that does similar thing to what is needed (install a bash script to /usr/bin/ and few other files somewhere else). You can find good examples from aur and from manjaro packages-community repo in github. For this particular package, I would use pacli as model.

2) Modify pkgbuild to match your needs. Point it to right github repo, rename package, rename files to be installed, choose dependencies, optdepends and version.

3) try if it works by running
Code: [Select]
makepkg -sriOn the directory where pkgbuild is located.

4) If it works, clone manjaro/packages-community repo and add folder "morc_menu" with your pkgbuild in it.

5) send pull request to main repo and ask one of the packagers to build it.

Thats what I often do. It is the easy way to start. With aur it is a bit different.

I'll write the pkgbuild and add it this evening if I have time.


Offline Chrysostomus

  • Maintainer
  • ***
  • Posts: 1634
  • Neckbeards are cool
    • Git
  • Branch: unstable
  • Desktop: Gnome, bspwm
  • GPU Card: Intel HD4000
  • GPU driver: free
  • Kernel: linux44-x64
  • Skill: Intermediate
Here is an example what the pkgbuild might look like:

Code: [Select]
# Maintainer: Chrysostomus @forum.manjaro.org
# Maintainer: boruch @forum.manjaro.org

pkgname=morc_menu
pkgver=0.1
pkgrel=1
pkgdesc="A categorized applications menu using dmenu and bash"
arch=(any)
url="https://github.com/Boruch-Baum/morc_menu"
license=(GPL3)
depends=('dmenu'
'bash')
makedepends=('git')
optdepends=(
'wmutils: Spawn menu on cursor'
'xdotool: Spawn menu on cursor'
'dmenu-manjaro: Support for mouse, xft fonts and menu placing'
'rofi: Alternative frontend'
'zenity: Alternative frontend'
'rootmenu: Spawn menu by clicking desktop')
source=("git://github.com/Boruch-Baum/morc_menu")
md5sums=('SKIP')

package () {
    install -Dm755 "$srcdir/$pkgname/morc_menu" "$pkgdir/usr/bin/morc_menu"
    install -Dm544 "$srcdir/$pkgname/morc_menu_v1.conf" "$pkgdir/etc/skel/.config/morc_menu/help/morc_menu_v1.conf"
}

Work in progress still. THis version has dmenu as dependency and dmenu-manjaro as optdepend.

Offline boruch

  • Jr. Mitglied
  • **
  • Posts: 85
  • Skill: Intermediate
@Chrysostomus. The example seems straightforward. I think I understand it, but if so, then should:
Code: [Select]
install -Dm544 "$srcdir/$pkgname/morc_menu_v1.conf" "$pkgdir/etc/skel/.config/morc_menu/help/morc_menu_v1.conf"
be instead:
Code: [Select]
install -Dm544 "$srcdir/$pkgname/morc_menu_v1.conf" "$pkgdir/etc/skel/.config/morc_menu/morc_menu_v1.conf"
 install -Dm644 "$srcdir/$pkgname/morc_menu_v1.conf" "$pkgdir/usr/share/morc_menu/morc_menu_v1.conf"

Also, I see you listed me as a maintainer at boruch@forum.manjaro.org, but you should know I have NEVER gotten a notification from the forum boards even though I request notifications and have entered my e-mail. Nothing shows up in my mail client spam folder from forum.manjaro either.

Offline boruch

  • Jr. Mitglied
  • **
  • Posts: 85
  • Skill: Intermediate
@Chrysostomus: Also, there needs to be an entry for the man page:
Code: [Select]
install -Dm644 "$srcdir/$pkgname/morc_menu.1" "$pkgdir/usr/share/man/man1/morc_menu.1"
I'm not sure this is correct, though, because really the file should be compressed in gz format when installed, to conform with all the contents of the target folder.

Offline oberon

  • Core Team
  • *****
  • Posts: 3858
  • I'm nice. Be new!
  • Branch: unstable
  • Desktop: i3, Deepin, Cinnamon
  • GPU Card: Intel ValleyView Gen7
  • GPU driver: Intel
  • Kernel: 4.1 / 4.4
  • Skill: Intermediate
Looks good already.
I'd suggest to install the template config to /etc/morc_menu. That's how similar things like the default i3/config are placed.
I thought the same about the man file that we should compress it to .gz
I'm just not sure if you'll be able to push an archive to github. If the system doesn't allow that we can still compress it in the PKGBUILD
How about a little install script with an info message about the config?
For that you can simply add a morc_menu.install file with something like that, or even simpler without the fancy colors like that 8)
In the PKGBUILD you add
Code: [Select]
install=$pkgname.install. It's not necessary to add it to the source array.
« Last Edit: 16. March 2016, 10:12:46 by oberon »
manjaro is addictive ::)
* manjaro-i3  * manjaro-cinnamon  * manjaro-deepin

Offline Chrysostomus

  • Maintainer
  • ***
  • Posts: 1634
  • Neckbeards are cool
    • Git
  • Branch: unstable
  • Desktop: Gnome, bspwm
  • GPU Card: Intel HD4000
  • GPU driver: free
  • Kernel: linux44-x64
  • Skill: Intermediate
Some packages seem to compress their man page in the pkgbuild.

This is how bar installs man page:
Code: [Select]
install -Dm644 bar.1 "${pkgdir}/usr/share/man/man1/bar.1"
And this is how open-fuse-iso-term does it:

Code: [Select]
mkdir -p "$pkgdir/usr/share/man/man1"
  cp man1/open-fuse-iso.1 "$pkgdir/usr/share/man/man1/open-fuse-iso.1"
  gzip "$pkgdir/usr/share/man/man1/open-fuse-iso.1"

Offline boruch

  • Jr. Mitglied
  • **
  • Posts: 85
  • Skill: Intermediate
@Chrysostomus: OK! So for us, we would do?
Code: [Select]
install -Dm544 "$srcdir/$pkgname/morc_menu_v1.conf" "$pkgdir/etc/skel/.config/morc_menu/morc_menu_v1.conf"
 install -Dm644 "$srcdir/$pkgname/morc_menu_v1.conf" "$pkgdir/usr/share/morc_menu/morc_menu_v1.conf"
 install -Dm644 "$srcdir/$pkgname/morc_menu.1" "$pkgdir/usr/share/man/man1/morc_menu.1"
 gzip "$pkgdir/usr/share/man/man1/morc_menu.1"

@Oberon: Let me see if I'm getting the hang of this PKGBUILD thing. Based upon the firefox PKGBUILD that I'm looking at, to add an install script, I would have to add to PKGBUILD a line like this:
Code: [Select]
install=fmorc_menu.install
Where the name of the install script would be exactly that, morc_menu.install, . . .

And to add a patch, I would add a script function like this directly in PKGBUILD:
Code: [Select]
prepare() {
patch -Np1 -i ../morc_menu_blah_blah.patch
  }
But I'm not certain about the need to cd into a partcular folder. In our case, the most likely patch would be to change the config file to default to extra features supported by package dmenu-manjaro if that is the version being used.

I'd suggest to install the template config to /etc/morc_menu. That's how similar things like the default i3/config are placed.
@Oberon: I may have ranted about this in the past. My understanding of the LSB standard is that one is not supposed to use /etc for these kind of files. If I'm wrong, I would have to modify the script to look there, which isn't a problem, but I don't think I'm wrong on this one. The way the LSB wants systems to work is that the package's default would be in /usr/share/pkg-name/, the system administrator's modified version would be in /usr/local/share/pkg-name, and the user's personal modified version in the appropriate ${HOME} sub folder. Programs either read all of them (and last one wins), which is what morc_menu does, or just looks in reverse order for the first one it finds.

@Chrysostomus & @Oberon: I pushed an addition to github to automatically copy the config file to the user's ${HOME}/.config/morc_menu folder if it doesn't exist and to create that folder if it doesn't exist.

@Oberon: What message would you want in an install script "about the config"?

@Chrysostomus & @Oberon: PKGBUILD seems to use shell scripting. Does it use bash or sh or can each PKGBUILD file specify which shell? At most naughty, would it be impolite to 'exec /bin/bash -c '?

Offline Chrysostomus

  • Maintainer
  • ***
  • Posts: 1634
  • Neckbeards are cool
    • Git
  • Branch: unstable
  • Desktop: Gnome, bspwm
  • GPU Card: Intel HD4000
  • GPU driver: free
  • Kernel: linux44-x64
  • Skill: Intermediate
Pkgbuild uses bash syntax, so no need for full posix compliance and bash functions can be used.

If you wish to add install script, arch wiki has excellent documentaion on it. I'm pretty bad with them myself.

Installing default config to /usr/share makes sense. I just quickly typed this example on my cellphone.