You are not logged in.

#301 2020-09-11 22:25:07

peterk
Member
Registered: 2017-10-27
Posts: 8

Re: jgmenu

Hello,
I have two different themes in the .config/jgmenu/theme1 & theme2 is there a way - command to choose one of those two of my theme configs?

Offline

#302 2020-09-11 23:32:36

damo
....moderator....
Registered: 2015-08-20
Posts: 6,701

Re: jgmenu

Do you mean the gtk theme, or different jgmenurc's?

jgmenu --config-file=<file>

Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#303 2020-09-12 06:05:06

malm
jgmenu developer
Registered: 2016-10-13
Posts: 703
Website

Re: jgmenu

Other than what @Damo suggested there is no builtin way to support this.

If running jgmenu as a long-running application (default), any change in jgmenurc will be detected, so you could write a script which copies either theme{1,2} to jgmenurc. E.g. toggle-theme.sh

Offline

#304 2020-09-13 18:30:55

peterk
Member
Registered: 2017-10-27
Posts: 8

Re: jgmenu

Hi,
I have my own tint2rc themes and the match jgmenurc themes so basically when I change the tint2rc it detects is theme and like @malm suggested copies xxx.jgmenurc and renames it to jgmenurc.
Works thanks.

Offline

#305 2021-03-24 20:49:53

misko_2083
Member
Registered: 2016-05-24
Posts: 500

Re: jgmenu

@Malm remember when we mentioned about having a blurred image of the desktop behind the jgmenu?
It's a shame cairo doesn't have it's own algorithm to blur.
But I've been experimenting with ImageMagick and it's very fast.
Of course it depends from image size and ammount of blur 0x1 to 0x8.
0x4 is very good. https://legacy.imagemagick.org/Usage/blur/
The screenshot app changes mouse cursor and when I select a rectanggle image is saved in the same dir.
Then I measure time to blur the image.

./screenshot && time convert image.png -blur 0x4 image_blur.png

With this screenshot app:

#include <cairo.h>
#include <gdk/gdk.h>
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/cursorfont.h>
#include <unistd.h>

/* Select an area to save to "image.png" in the current folder
   gcc  screenshot.c -Wall -o  screenshot
  `pkg-config --cflags --libs x11 cairo gtk+-3.0`
*/

static void _select_area (int * cordx, int * cordy, int * cordw, int * cordh)
{
  /* Select area borrowed from
     https://bbs.archlinux.org/viewtopic.php?pid=660547#p660547
  */
  int rx = 0, ry = 0, rw = 0, rh = 0;
  int rect_x = 0, rect_y = 0, rect_w = 0, rect_h = 0;
  int btn_pressed = 0, done = 0;

  XEvent ev;
  Display *disp = XOpenDisplay(NULL);

  if(!disp)
    exit(1);

  Screen *scr = NULL;
  scr = ScreenOfDisplay(disp, DefaultScreen(disp));

  Window root = 0;
  root = RootWindow(disp, XScreenNumberOfScreen(scr));

  Cursor cursor, cursor2;
  cursor = XCreateFontCursor(disp, XC_cross);
  cursor2 = XCreateFontCursor(disp, XC_crosshair);
  XColor color;
  Colormap colormap;
  char blueLight[] = "#0580FF"; // Misko decided to change the color
  colormap = DefaultColormap(disp, 0);
  XParseColor(disp, colormap, blueLight, &color);
  XAllocColor(disp, colormap, &color);

  XGCValues gcval;
  gcval.foreground = XWhitePixel(disp, 0);
  gcval.function = GXxor;
  gcval.background = XBlackPixel(disp, 0);
  gcval.plane_mask = gcval.background ^ gcval.foreground;
  gcval.subwindow_mode = IncludeInferiors;
  gcval.line_width = 2;

  GC gc;
  gc = XCreateGC(disp, root,
                 GCFunction | GCForeground | GCBackground | GCSubwindowMode | GCLineWidth ,
                 &gcval);

  /* this XGrab* stuff makes XPending true ? */
  if ((XGrabPointer
       (disp, root, False,
        ButtonMotionMask | ButtonPressMask | ButtonReleaseMask, GrabModeAsync,
        GrabModeAsync, root, cursor, CurrentTime) != GrabSuccess))
    printf("couldn't grab pointer:");

  if ((XGrabKeyboard
       (disp, root, False, GrabModeAsync, GrabModeAsync,
        CurrentTime) != GrabSuccess))
    printf("couldn't grab keyboard:");

  while (!done) {
//  while (!done && XPending(disp)) {
//    XNextEvent(disp, &ev);
// fixes the 100% CPU hog issue in original code
    if (!XPending(disp)) { usleep(1000); continue; }
    if ( (XNextEvent(disp, &ev) >= 0) ) {
      switch (ev.type) {
        case MotionNotify:
        /* this case is purely for drawing rect on screen */
          if (btn_pressed) {
            if (rect_w) {
              /* re-draw the last rect to clear it */
              XDrawRectangle(disp, root, gc, rect_x, rect_y, rect_w, rect_h);
            } else {
              /* Change the cursor to show we're selecting a region */
              XSetForeground(disp, gc, color.pixel);
              XChangeActivePointerGrab(disp,
                                       ButtonMotionMask | ButtonReleaseMask,
                                       cursor2, CurrentTime);
            }
            rect_x = rx;
            rect_y = ry;
            rect_w = ev.xmotion.x - rect_x;
            rect_h = ev.xmotion.y - rect_y;

            if (rect_w < 0) {
              rect_x += rect_w;
              rect_w = 0 - rect_w;
            }
            if (rect_h < 0) {
              rect_y += rect_h;
              rect_h = 0 - rect_h;
            }
            /* draw rectangle */
            XDrawRectangle(disp, root, gc, rect_x, rect_y, rect_w, rect_h);
            XFlush(disp);
          }
          break;
        case ButtonPress:
          btn_pressed = 1;
          rx = ev.xbutton.x;
          ry = ev.xbutton.y;
          break;
        case ButtonRelease:
          done = 1;
          break;
      }
    }
  }
  /* clear the drawn rectangle */
  if (rect_w) {
    XDrawRectangle(disp, root, gc, rect_x, rect_y, rect_w, rect_h);
    XFlush(disp);
  }
  rw = ev.xbutton.x - rx;
  rh = ev.xbutton.y - ry;
  /* cursor moves backwards */
  if (rw < 0) {
    rx += rw;
    rw = 0 - rw;
  }
  if (rh < 0) {
    ry += rh;
    rh = 0 - rh;
  }

  *cordx = rx;
  *cordy = ry;
  *cordw = rw;
  *cordh = rh;

  XCloseDisplay(disp);
}


int main (int argc, char *argv[])
{
  gdk_init(&argc, &argv);
  
  int cordx, cordy, cordw, cordh;
  _select_area (&cordx, &cordy, &cordw, &cordh);
  
  printf("X=%d\nY=%d\nWIDTH=%d\nHEIGHT=%d\n", cordx, cordy, cordw, cordh);

  GdkWindow *root_win = gdk_get_default_root_window();
 
  cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
                                                                                                      cordw, cordh);
  GdkPixbuf *pb = gdk_pixbuf_get_from_window(root_win, cordx, cordy,
                                                                                                      cordw, cordh);
  cairo_t *cr = cairo_create(surface); 
  gdk_cairo_set_source_pixbuf(cr, pb, 0, 0);
  cairo_paint(cr);  

  cairo_surface_write_to_png(surface, "image.png");
  
  cairo_destroy(cr);
  cairo_surface_destroy(surface);

  return 0;
}

It would be faster withour writing to hard drive.
But I'm not touching ImageMagick's low-level api.
Luckely there is MagickWand:
https://www.imagemagick.org/api/MagickWand/
(That doesn't mean I understand it. smile )
In Buster it's libmagickwand-6.q16-dev and when compiling gcc `pkg-config --cflags --libs MagickWand`.
The only example I can find with Gtk3 is this:
https://legacy.imagemagick.org/discours … hp?t=22105
It segfaults. smile
But it's interesting to know one can export from Magick to pixbuf.
Don't know if it can convert to cairo surface.
and there is  import and
blur.
There are other kinds of blur, adaptive and bilateral that seem slow on command line.


This content is censored by the German government.

Offline

#306 2021-03-24 21:14:01

DeepDayze
Like sands through an hourglass...
From: In Linux Land
Registered: 2017-05-28
Posts: 1,324

Re: jgmenu

Would be nice to have a config option to add blur to the background transparency of the menu a la Windows 10, something like menu_background_blur = <0-100> where 0-100 is the percentage of blur desired. 0 for no blur, 100 for totally blurred.

Is this possible to add?

PS: Would love to see something like this in Tint2 as well so will ask about that idea to the Tint2 dev.

Last edited by DeepDayze (2021-03-24 21:15:41)


Real Men Use Linux

Offline

#307 2021-03-24 21:25:05

malm
jgmenu developer
Registered: 2016-10-13
Posts: 703
Website

Re: jgmenu

I do indeed remember big_smile

Suggest we start by producing a proof of concept application which grabs a region of the desktop and blurs it - preferably as a cairo surface.

We ought to write it in C and not save to harddisk.

From memory, tint2 has some code which grabs sections of the desktop (for the hover preview).

Not sure how blurring works. Couldn’t we just average the colours of neighbouring pixels or similar?

I’m tied up for a couple of days, but will do some research.

Offline

#308 2021-03-24 21:47:05

malm
jgmenu developer
Registered: 2016-10-13
Posts: 703
Website

Re: jgmenu

Offline

#309 2021-03-25 12:08:43

misko_2083
Member
Registered: 2016-05-24
Posts: 500

Re: jgmenu

malm wrote:

I do indeed remember big_smile

Suggest we start by producing a proof of concept application which grabs a region of the desktop and blurs it - preferably as a cairo surface.

We ought to write it in C and not save to harddisk.

From memory, tint2 has some code which grabs sections of the desktop (for the hover preview).

Oh tint2 is grabbing image straight from X with XGetImage function.
It also has an option to use this XShm extension I never heard about.

From what I see in tint2 code something aproximately like this:

/*this is far from working code*/
#include <cairo.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/Xrandr.h>

// This is measured to be slightly faster.
#define GetPixel(ximg, x, y) ((u_int32_t *)&(ximg->data[y * ximg->bytes_per_line]))[x]

/*function to scrape from X*/
cairo_surface_t *get_root_ximage(int cordx, int cordy, int cordw, int cordh)
{
    //connect to x
    Display* dpy = XOpenDisplay(NULL);
    // Get root window 
    Window root = DefaultRootWindow(dpy);

    cairo_surface_t *surface = NULL;
    surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, cordw, cordh);

    XImage *ximg;
    ximg = XGetImage(dpy, root, cordx, cordy, cordw, cordh, AllPlanes, ZPixmap);
    u_int32_t *data = (u_int32_t *)cairo_image_surface_get_data(surface);
    memset(data, 0, cordw * cordh);

/* Some magick from tint2 here, sinsirely have no idea how it works
    ...
     Fixed-point precision - whatever it means
    ...
     Convert to argb32
*/

    cairo_surface_mark_dirty(surface);

    if (ximg) {
        XDestroyImage(ximg);
        ximg = NULL;
    }

  XCloseDisplay(dpy);

return surface;
}

/*function to work with cairo*/
void some_function ()
{
  int cordx, cordy, cordw, cordh;
  //get_coord (&cordx, &cordy, &cordw, &cordh);
  cairo_surface_t *image_surface = NULL;

  /*pass coordinates and size of the root window*/
  image_surface = get_root_ximage(cordx, cordy, cordw, cordh);

   /*do something with the surface, blur, write to hard drive or window*/
  //cairo_surface_write_to_png(image_surface, "image.png");

  cairo_surface_destroy(image_surface);
}

But there are lot of other things to keep an eye on:  root window size change, display change, visual.

Well average blur would work.
It seems to be called "mean filter".
https://medium.com/swlh/how-image-blurr … 2051aee2d1


This content is censored by the German government.

Offline

#310 2021-03-26 13:13:28

sleekmason
zoom
Registered: 2018-05-22
Posts: 604
Website

Re: jgmenu

I fell like I am behind the times by a year or two. roll

Just an incredible piece of work.

Anyhow,  The menu on the left is my current OB menu (in jgmenu), and the right is just my appends and prepends attached.

So, my understanding was that I could simply make and point to my own menu by using:

csv_cmd = cat ~/.config/jgmenu/mymenu.csv

And add entries to the file?  but nope. I do not have this correct.

Terminal,           lxterminal,       utilities-terminal
File Manager,       thunar,           system-file-manager
Firefox,            firefox,          /usr/share/icons/ld-icons/firefox.png

        ---ENTRY FOR THE APPS MENU GOES HERE----

Restart Openbox,    openbox --restart,        /usr/share/icons/ld-icons/pixmaps/logout_reboot.png
Reconfigure,        openbox --reconfigure,    /usr/share/icons/gnome/48x48/actions/redo.png 
Exit,               ld-logout,                 /usr/share/icons/ld-icons/exit4.png

^^^ Me keeping it simple. If I can get this working, and the Root apps menu in the center, I can figure everything else out!

jgmenu-test.png

So I need to know how to:

1. How to call my personal menu correctly.  (cat ~/.config/jgmenu/mymenu.csv)?  Guessing this isn't it.)  And then, anything necessary in the menufile itself to be read correctly.

2. What do I use to display the "apps" menu inside of an entry (Debian). Basically I want to recreate my Openbox menu above using the jgmenu system, without using the OB feature.  Point being easier editing of the menus etc . .  (^root)? something?

3. Every Icon works but accessories here . . .(gnome). Just thought I should mention it.

4. Any other advise you may have for me.

Getting set up was a breeze, and the initial implementation gives a solid menu right out of the box.  All of the customization possibilities are just neat.  Looking forward to hours of working on this.  Really nice.

Offline

#311 2021-03-26 15:01:07

malm
jgmenu developer
Registered: 2016-10-13
Posts: 703
Website

Re: jgmenu

1. It is exactly how you’ve described it. Try running jgmenu from the terminal so you can see any error messages if it’s not working.

killall jgmenu
jgmenu_run

2.

Debian,^pipe(jgmenu_run apps)

3. Run

jgmenu_run apps | grep -i accessories

Third field is icon name. Does that give us a clue why it’s not working?

Offline

#312 2021-03-26 19:19:35

sleekmason
zoom
Registered: 2018-05-22
Posts: 604
Website

Re: jgmenu

Huh, getting an error in the terminal:

fatal: item 6 was not correctly terminated with a '\n'

Looks like the problem is item six in /mymenu?  I deleted all but the terminal line, and it gave the same error but for "item 0" Tried adding the above \n . . . Didn't see this in any examples I found in your tutorial.

Better give you everything:
Mymenu:

Terminal,           lxterminal,       utilities-terminal
File Manager,       thunar,           system-file-manager
Firefox,            firefox,          /usr/share/icons/ld-icons/firefox.png
Debian,^pipe(jgmenu_run apps)
Restart Openbox,    openbox --restart,        /usr/share/icons/ld-icons/pixmaps/logout_reboot.png
Reconfigure,        openbox --reconfigure,    /usr/share/icons/gnome/48x48/actions/redo.png  
Exit,               ld-logout,                 /usr/share/icons/ld-icons/exit4.png
# verbosity = 0
# stay_alive = 1
# persistent = 0
# hide_on_startup = 0
csv_cmd = cat ~/.config/jgmenu/mymenu.csv
# tint2_look = 0
position_mode = pointer
# edge_snap_x = 30
# terminal_exec = x-terminal-emulator
# terminal_args = -e
# monitor = 0
# hover_delay = 100
# hide_back_items = 1
# columns = 1
# tabs = 120
# menu_margin_x = 0
# menu_margin_y = 0
menu_width = 170
# menu_height_min = 0
# menu_height_max = 0
# menu_height_mode = static
# menu_padding_top = 2
# menu_padding_right = 2
# menu_padding_bottom = 2
# menu_padding_left = 2
# menu_radius = 1
menu_border = 1
# menu_halign = left
# menu_valign = bottom
 menu_gradient_pos = left
sub_spacing = 5
# sub_padding_top = auto
# sub_padding_right = auto
# sub_padding_bottom = auto
# sub_padding_left = auto
# sub_hover_action = 1
# item_margin_x = 1
# item_margin_y = 1
# item_height = 25
# item_padding_x = 2
# item_radius = 1
# item_border = 0
# item_halign = left
# sep_height = 5
sep_halign = center
sep_markup = 
# font = Liberation Sans 11
# font_fallback = xtg
# icon_size = 22
# icon_text_spacing = 15
# icon_norm_alpha = 100
# icon_sel_alpha = 100
# icon_theme = gnome
# icon_theme_fallback = xtg
# arrow_string = ▸
# arrow_width = 15
color_menu_bg = #707874 100
color_menu_bg_to = #89918D 100
color_menu_border = #444D48 100
# color_norm_bg = #000000 00
color_norm_fg = #0D0B0B 100
color_sel_bg = #57615E 100
color_sel_fg = #C9DBD9 100
color_sel_border = #57615E 100
color_sep_fg = #293231 100
# color_scroll_ind = #eeeeee 40
color_title_fg = #0D0B0B 100
color_title_bg = #767D79 100
color_title_border = #767D79 100
# csv_name_format = %n (%g)
# csv_single_window = 0
# csv_no_dirs = 0
# csv_i18n = 
# csv_no_duplicates = 0

And for the accessories icon:

sleekmason@ai2:~$ jgmenu_run apps | grep -i accessories
Accessories,^checkout(apps-dir-Accessories),applications-accessories
^tag(apps-dir-Accessories)

I do have lx-menu installed as well. Everything else is groovy.

Last edited by sleekmason (2021-03-26 19:21:20)

Offline

#313 2021-03-26 21:33:15

malm
jgmenu developer
Registered: 2016-10-13
Posts: 703
Website

Re: jgmenu

What editor do you use?

What happens if you just add a new empty line at the end of the file.

Does it work if you delete jgmenu.c lines 1239+1240?
https://github.com/johanmalm/jgmenu/blo … nu.c#L1239

Offline

#314 2021-03-26 22:31:33

sleekmason
zoom
Registered: 2018-05-22
Posts: 604
Website

Re: jgmenu

malm wrote:

What editor do you use?

What happens if you just add a new empty line at the end of the file.

Does it work if you delete jgmenu.c lines 1239+1240?
https://github.com/johanmalm/jgmenu/blo … nu.c#L1239

-----

Ha! That was ridiculous on my part:) A new line at the end did indeed do the trick. Wonderful! This is going to be a blast:) Thank you for your hard work!

Offline

#315 2021-03-26 22:38:05

sleekmason
zoom
Registered: 2018-05-22
Posts: 604
Website

Re: jgmenu

So any entries inside the Debian "apps" menu do not have icons . . Is there a generic addition to add icons to the menu?  (for that matter, to the "Debian" entry as well. Cant just add the path like I would for a regular entry?) *edit - Yes!.

No worries either way here, as it never did with the Openbox menu either. (well some, but not many.)

Edit* Ha! Got the icon issue sorted for the "Debian" entry itself. Didn't kill and restart.  roll

So only thing left is inside the pipe menu to apps.

Last edited by sleekmason (2021-03-27 00:12:48)

Offline

#316 2021-03-29 14:08:01

misko_2083
Member
Registered: 2016-05-24
Posts: 500

Re: jgmenu

I did a short video to demonstrate stackblur of the rectangle on the root screen.
Now imagine this image behind the transparent jgmenu. smile
https://www.youtube.com/watch?v=ZOBBZv9B3Q8
Stackblur algoritm by Mario Klingemann.
Stackblur is a compromise between Gaussian blur and Box blur,
but it creates much better looking blurs than Box blur and it is ~7x faster than Gaussian blur.


This content is censored by the German government.

Offline

#317 2021-03-29 19:59:32

misko_2083
Member
Registered: 2016-05-24
Posts: 500

Re: jgmenu

DeepDayze wrote:

Would be nice to have a config option to add blur to the background transparency of the menu a la Windows 10, something like menu_background_blur = <0-100> where 0-100 is the percentage of blur desired. 0 for no blur, 100 for totally blurred.

Is this possible to add?

I think Kawase blur is too much, it looks like that blur relies on OpenGL.
https://www.youtube.com/watch?v=AN-cVA_tCR0&t=104s
But it looks very preety. smile
Stack blur is very fast, supports multithreading and can blur the entire desktop in 30ms or less.
We can control the blur radius:
https://www.youtube.com/watch?v=ZOBBZv9B3Q8
100 would be a bit too much. Maybe between 0-30 ?


This content is censored by the German government.

Offline

Board footer

Powered by FluxBB