Giter Club home page Giter Club logo

xdg-xmenu's Introduction

xdg-xmenu

It's a small program to show a apps menu with xmenu. The current branch is a C rewrite of previous shell and python version of xdg-xmenu. This C version can launch xmenu directly, due to a faster execution time.

For the legacy shell and python versions, see corresponding branches of this git repository.

Requirements

  • libinih, or called 'inih', to parse the desktop entry files. Available in most major distros.

Usage

xdg-xmenu [-dGhIn] [-b ICON] [-i THEME] [-s SIZE] [-S SCALE] [-t TERMINAL]
          [-x CMD] [-- <xmenu_args>]

A simple app menu with xmenu.

Options:
  -h          Show this help message and exit
  -b ICON     Fallback icon name, default is application-x-executable
  -d          Dump generated menu, do not run xmenu
  -G          Do not show generic name of the app
  -i THEME    Icon theme for app icons. Default to gtk3 settings
  -I          Disable icon in xmenu
  -n          Do not run app, output to stdout
  -s SIZE     Icon size for app icons
  -S SCALE    Icon scale factor, useful in HiDPI screens
  -t TERMINAL Terminal emulator to use, default is xterm
  -x CMD      Xmenu command to use, default is xmenu
Note:
  Options after `--' are passed to xmenu (or CMD)

Notes

Important: Svg icons are supported since Imlib2 1.8.0. Thus, xdg-xmenu assumes that you have installed Imlib2 of at least that version. As a result, unlike the shell version, the svg icons are not converted to png anymore. If you don't have the required version of Imlib2, use the shell version instead.

xdg-xmenu's People

Contributors

xlucn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

xdg-xmenu's Issues

libinih error

Hey nice C version Thanks . Its not big issue I got the header ini.h not found error (ini parser) so I did install libinih

Its nice if you add in README.md for the dependency to install xdg-xmenu

dependency - libinih (for arch linux)

Thanks again

Empty prefix IMG: in the submenu titles

I found next error in the generation:

IMG: Science
IMG:/home/box/.cache/xdg-xmenu/icons/cantor.png Cantor (Frontend to Mathematical Software) cantor -qwindowicon cantor -qwindowtitle
R (environment for statistical computing) xterm -e R
IMG:/home/box/.cache/xdg-xmenu/icons/octave.png GNU Octave /usr/bin/octave --gui
IMG:/home/box/.cache/xdg-xmenu/icons/kalgebra.png KAlgebra (Graph Calculator) kalgebra
IMG:/home/box/.cache/xdg-xmenu/icons/kalgebra.png KAlgebra Mobile (Pocket Graph Calculator) kalgebramobile
IMG:/home/box/.cache/xdg-xmenu/icons/kalzium.png Kalzium (Periodic Table of Elements) kalzium -qwindowtitle
IMG:/home/box/.cache/xdg-xmenu/icons/marble.png KDE Marble (Virtual Globe) marble
IMG:/home/box/.cache/xdg-xmenu/icons/libreoffice-math.png LibreOffice Math (Formula Editor) libreoffice --math
IMG:/home/box/.cache/xdg-xmenu/icons/rocs.png Rocs (Rocs Graph Theory) rocs -qwindowtitle
Julia xterm -e julia
Singular xterm -e Singular

If the image doesn't exist in the app line, the prefix IMG is correctly removed, e.g. R and Singular lines.
But if the image missing for submenu names, there is still present IMG: prefix with empty icon which cause error message in the xmenu program: xmenu: cannot load icon
The prefix IMG: cannot be generated for submenu titles if there is no image for it, similar as app lines.

xdg-xmenu crashes if launched with -I

Okay, here's a weird one, honestly I have no clue what's going on.
Suddendly, if I run xdg-xmenu -I I have the usual menu, but instead of

Others > Jitsi Meet
	Rofi
	Rofi theme selector

Now I have

Others >
Jitsi Meet > Rofi
	Rofi theme selector

And if I put the cursor on Others, it crashes.

I tried to uninstall Jitsi Meet and the result became

Others >
Rofi > Rofi theme selector

So the problem is not Jitsi Meet.

If I run xdg-xmenu, the menu is back to normal and I have no problems.
Do you have any idea what the problem could be, and why if I remove the icons then my .desktops files without a specified Categories jump out from Others and create a new category, with the name of one of them as a title of the menu and the others as a submenu items?

I hope I have explained clearly the issue, if not I'll provide some screenshot as english is not my first language and this is very weird.
Thank you.

Edit: I tried to format it to look decent but I give up.

Show xdg-xmenu as a submenu integrated in xmenu

Hey, right now I have my xmenu.sh like this:


#!/bin/sh

xmenu <<EOF | sh &
Terminal	alacritty
Web Browser	firefox
File Manager	thunar
Text Editor	geany

Applications	xdg-xmenu -I

Exit			/home/andrea/bin/powermenu.sh
EOF

This way to open xdg-xmenu I have to click on Applications.

Is there a way to have xdg-xmenu embedded in xmenu, instead of having to click on Applications?

empty .local/share/applications dir and throws error

I have empty .local/share/applications dir and it throws error
a quick fix

after line no 178 please add this check (or a be better solution )
[[ ! "$(ls -A $appdir)" ]] && continue

Thanks for the xdg-menu :)

debian bookworm: segmentation fault

On execution, xdg-xmenu results with a segmentation fault. With the exception of the "-h" argument, they all result with segfaults.

OS details:

$ cat /etc/debian_version 
12.2

$ uname -a
Linux dusk 5.10.188-antix.1-amd64-smp #1 SMP PREEMPT Mon Jul 31 18:52:00 EEST 2023 x86_64 GNU/Linux

make, test, and execution:

$ make clean
rm -f xdg-xmenu

$ make
cc -o xdg-xmenu xdg-xmenu.c -linih

$ ./xdg-xmenu
Segmentation fault

$ make test
Testing tests/test_cannot_find_exec                                           OK
Testing tests/test_cannot_find_icon                                           OK
Testing tests/test_invalid_desktop_file                                       OK
Testing tests/test_invalid_icon_path                                          OK
Testing tests/test_option_fallback_icon                                       OK

Directory/files:

$ ll
-rw-r--r-- 1 techore techore 2.7K Nov  1 10:41 CHANGELOG
-rw-r--r-- 1 techore techore 1.1K Nov  1 10:41 LICENSE
-rw-r--r-- 1 techore techore 1.3K Nov  1 13:50 Makefile
-rw-r--r-- 1 techore techore 1.7K Nov  1 10:41 README.md
drwxr-xr-x 8 techore techore 4.0K Nov  1 10:41 tests
-rwxr-xr-x 1 techore techore  37K Nov  1 14:03 xdg-xmenu
-rw-r--r-- 1 techore techore 4.0K Nov  1 10:41 xdg-xmenu.1
-rw-r--r-- 1 techore techore  21K Nov  1 12:55 xdg-xmenu.c
-rw-r--r-- 1 techore techore  79K Nov  1 10:41 xdg-xmenu.png

Dependencies:

$ apt list --installed |grep -i libimlib2 
libimlib2-dev/stable,now 1.10.0-4+deb12u1 amd64 [installed]
libimlib2/stable,now 1.10.0-4+deb12u1 amd64 [installed]

$ apt list --installed |grep -i inih
libinih-dev/stable,now 55-1 amd64 [installed]
libinih1/stable,now 55-1 amd64 [installed]

Licensing

Hi,
As you haven't specified a license for this project, is it fine with you if I distribute a slightly modified version in my script collection under the BSD license?
Thanks for the great script btw!

Unable to copy some icons to cache, still used in menu file.

Running the command xdg-xmenu > menu results in some icons not stored in standard(?) paths not being copied to their intended location.

Error saving to file: /home/myrkvi/.cache/xdg-xmenu/icons/opt/intellij-idea-ultimate-edition/bin/idea.png
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/usr/share/pixmaps/jetbrains-toolbox.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/home/myrkvi/.pia_manager/pia_tray_files/img/icon_512x512.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/usr/share/bzflag/bzflag-48x48.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/usr/share/hplip/data/images/128x128/hp_logo.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/usr/share/icons/Humanity/devices/48/printer.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/usr/local/bin/immersed-res/icon.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/opt/goland/bin/goland.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/usr/share/lightworks/Icons/App.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/usr/share/pixmaps/nvidia-settings.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/usr/share/pixmaps/r.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/opt/runescape/share/img/runescape.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/opt/runescape/share/img/runescape.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/opt/runescape/share/img/update-runescape.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/home/myrkvi/.cache/yay/skype-desktop-bin/pkg/skype-desktop-bin/opt/skype_unofficial_client/skype.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/usr/share/racket/slideshow-exe-icon.png': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/opt/st/stm32cubeide_1.3.0/icon.xpm': No such file or directory
cp: cannot create regular file '/home/myrkvi/.cache/xdg-xmenu/icons/var/lib/snapd/snap/teams-for-linux/105/meta/gui/icon.png': No such file or directory

I'm assuming this is because the parent directories for the icon files within ~/.cache/xdg-menu/icons do not exist.
These paths are still included for the programs, and xmenu then fails to run because it cannot find the images.

Possible conflict of icons provided as full path with the same icon name

A example for this issue is in one desktop file there is:

Icon=/path/to/icon.svg

and in another:

Icon=/foo/bar/icon.svg

The xdg-xmenu script only copy/generate the cache icon with the same basename, which means currently in the example above one app will use the icon of another.

Possible solution might be flatten the path to path_to_icon.svg/foo_bar_icon.svg, but I have not decided yet.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.