8000 [Feature] Add tag preview (WIP) · Issue #6 · siduck/chadwm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Feature] Add tag preview (WIP) #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
siduck opened this iss 8000 ue Jul 31, 2021 · 28 comments
Closed

[Feature] Add tag preview (WIP) #6

siduck opened this issue Jul 31, 2021 · 28 comments

Comments

@siduck
Copy link
Owner
siduck commented Jul 31, 2021

show a floating picture like thingy for tags when their icons on dwmbar is hovered, something like this

https://cdn.discordapp.com/attachments/635625917623828520/829478089469329438/gif_2021-04-07032620.gif
(awesomewm)

@siduck
Copy link
Owner Author
siduck commented Jul 31, 2021

so far I was able to preview an image with rofi and align it properly.

simplescreenrecorder-2021-07-31_19.27.59.mp4

@siduck
Copy link
Owner Author
siduck commented Jul 31, 2021
#!/bin/sh

preview_dir="$HOME/.dwm/tag_previews/"

current_tag=$(wmctrl -d | grep '*' | cut -d ' ' -f1)

save_Screenshot() {
  file="${preview_dir}${current_tag}.png"
  maim -u "${file}"
}

$(save_Screenshot)

@siduck
Copy link
Owner Author
siduck commented Jul 31, 2021

The above script should be excuted by dwm before the user switches to another workspace. (this is for saving the screenshots )

maim will overwrite the screenshots itself too.

@siduck
Copy link
Owner Author
siduck commented Jul 31, 2021

Basic Concept

  1. Run the above save_screenshot script before switching tags
  • suppose there are 5 workspaces ( 0 to 4 according to wmctrl )

image

  1. When you hover on the tag icon , it should execute 2 things :
  • (Note : tag_previews is the folder where we say our screenshots and the 1.png here is uncertain so when we hover a tag , its number will be saved in a variable and that variable will be used instead of 1.png)
screenshot=".dwm/tag_previews/1.png" 

sed -i "s:/home/sid/.*\.png:/home/sid/$screenshot:" ~/.config/rofi/tag.rasi 

And

I shouldnt worry about the alignment , I'll manage it in the tag_preview script.

@siduck
Copy link
Owner Author
siduck commented Aug 1, 2021
simplescreenrecorder-2021-08-01_20.38.28.mp4

works kinda ( but switching tags adds 100ms ~ delay ) :(

@siduck siduck changed the title [Feature] Add tag preview [Feature] Add tag preview (WIP) Aug 1, 2021
@siduck
Copy link
Owner Author
siduck commented Aug 2, 2021
simplescreenrecorder-2021-08-02_05.24.04.mp4

after using jpeg for image format , it feels faster than before!

@siduck
Copy link
Owner Author
siduck commented Aug 2, 2021

using feh instead of rofi is much faster!

simplescreenrecorder-2021-08-02_18.19.20.mp4

@siduck
Copy link
Owner Author
siduck commented Aug 3, 2021
  1. So we dont need some hooks stuff , since the tag preview is accurate (but not for current tag). the rest of the tags already have accurate previews ,since we're taking screenshot before switching the tag.

look

simplescreenrecorder-2021-08-03_06.58.49.mp4

@siduck
Copy link
Owner Author
siduck commented Aug 3, 2021

Issue 2 :

If there's an inactive tag , do not show its tag preview.

behaviour :

simplescreenrecorder-2021-08-03_07.05.15.mp4

Solution :

just delete its image from the ~/.dwm/tag_previews dir soo in our case 3 was the inactive tag , so remove 3.jpeg :)

if we hover an empty tag

@siduck
Copy link
Owner Author
siduck commented Aug 3, 2021

finally my friend made a patch for this! so no external scripts xD

0372264

@siduck
Copy link
Owner Author
siduck commented Aug 3, 2021

stuff needs to be fixed : tag preview doesnt update the current workspace screenshot

simplescreenrecorder-2021-08-03_18.14.00.mp4

solution : whenever we hover current tag icon , take screenshot + do tag preview

@siduck
Copy link
Owner Author
siduck commented Aug 3, 2021
simplescreenrecorder-2021-08-03_15.39.17.mp4

@siduck
Copy link
Owner Author
siduck commented Aug 3, 2021

75168cc

@siduck siduck closed this as completed Aug 3, 2021
@siduck
Copy link
Owner Author
siduck commented Aug 3, 2021

dwm ram usage keeps increasing if I switch to a different tag

simplescreenrecorder-2021-08-03_21.49.19.mp4

@siduck siduck reopened this Aug 4, 2021
@siduck
Copy link
Owner Author
siduck commented Aug 4, 2021

dwm ram usage keeps increasing if I switch to a different tag

simplescreenrecorder-2021-08-03_21.49.19.mp4

temp fix https://pastebin.com/raw/rThCDTZ6

@siduck
Copy link
Owner Author
siduck commented Aug 4, 2021

dwm ram usage keeps increasing if I switch to a different tag

simplescreenrecorder-2021-08-03_21.49.19.mp4

fixed here a10d00f

@siduck
Copy link
Owner Author
siduck commented Aug 4, 2021

dwm will know take around 11mb to 32~ mb , since its storing the images in ram rather than disk . I'll test it the other way around ( saving images on disk).

@siduck
Copy link
Owner Author
siduck commented Aug 4, 2021

FINALLY DONE f397a51

thanks a lot to /u/eProTaLT83 for helping with this feature!!

@siduck siduck closed this as completed Aug 4, 2021
@explosion-mental
Copy link

Hi, made a patch for this, which of course I can maintain.

Let me suggest to put it on the patches section since I know some are too comfy on their builds to switch.

@siduck
Copy link
Owner Author
siduck commented Aug 12, 2021

Hi, made a patch for this, which of course I can maintain.

Let me suggest to put it on the patches section since I know some are too comfy on their builds to switch.

Thanks for this! if you don't mind then you could add the tabbed with colored buttons patch too.

@explosion-mental
Copy link

Thanks for this! if you don't mind then you could add the tabbed with colored buttons patch too.

You mean this ?

@siduck
Copy link
Owner Author
siduck commented Aug 13, 2021

Thanks for this! if you don't mind then you could add the tabbed with colored buttons patch too.

You mean this ?

yes

@explosion-mental
Copy link
explosion-mental commented Aug 20, 2021

Sorry for the late response but the patch finally got pushed.
Also by

Let me suggest to put it on the patches section since I know some are too comfy on their builds to switch.

I meant to the readme of your repo lol. Anyway it's now pushed on the link above.

As for

if you don't mind then you could add the tabbed with colored buttons patch too.

I could but I wouln't be able to keep it up to date.

Maybe the author of the patch is interested on it? see

@siduck
Copy link
Owner Author
siduck commented Aug 20, 2021

@explosion-mental The author of the patch is /u/eProTaLT83 on reddit . I came up with this idea and he made a patch for it!

@renanwp2
Copy link
renanwp2 commented Oct 9, 2021

At least in my build of DWM, with the patch of explosion-mental, I have some problem with scaling variable. If I set it to 2 (static const int scalepreview= 2), the window size does not increase, but it still zooms the image. It would be better if the window size increases together. Probably an error in the calculation of XCopyArea.

@baizeyv
Copy link
Contributor
baizeyv commented Oct 9, 2021

At least in my build of DWM, with the patch of explosion-mental, I have some problem with scaling variable. If I set it to 2 (static const int scalepreview= 4), the window size does not increase, but it still zooms the image. It would be better if the window size still increases. Probably an error in the calculation of XCopyArea.

you can modify this function

+void
+updatepreview(void)
+{
+	Monitor *m;
+
+	XSetWindowAttributes wa = {
+		.override_redirect = True,
+		.background_pixmap = ParentRelative,
+		.event_mask = ButtonPressMask|ExposureMask
+	};
+	for (m = mons; m; m = m->next) {
+		m->tagwin = XCreateWindow(dpy, root, m->wx, m->by + bh, m->mw / 4, m->mh / 4, 0,
+				DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen),
+				CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
+		XDefineCursor(dpy, m->tagwin, curs
67E6
or[CurNormal]->cursor);
+		XMapRaised(dpy, m->tagwin);
+		XUnmapWindow(dpy, m->tagwin);
+	}
+}
+

modify this to

+void
+updatepreview(void)
+{
+	Monitor *m;
+
+	XSetWindowAttributes wa = {
+		.override_redirect = True,
+		.background_pixmap = ParentRelative,
+		.event_mask = ButtonPressMask|ExposureMask
+	};
+	for (m = mons; m; m = m->next) {
+		m->tagwin = XCreateWindow(dpy, root, m->wx, m->by + bh, m->mw / scalepreview, m->mh / scalepreview, 0,
+				DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen),
+				CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
+		XDefineCursor(dpy, m->tagwin, cursor[CurNormal]->cursor);
+		XMapRaised(dpy, m->tagwin);
+		XUnmapWindow(dpy, m->tagwin);
+	}
+}
+

This solution maybe will handle your problem.

@renanwp2
Copy link
renanwp2 commented Oct 9, 2021

At least in my build of DWM, with the patch of explosion-mental, I have some problem with scaling variable. If I set it to 2 (static const int scalepreview= 4), the window size does not increase, but it still zooms the image. It would be better if the window size still increases. Probably an error in the calculation of XCopyArea.

you can modify this function

+void
+updatepreview(void)
+{
+	Monitor *m;
+
+	XSetWindowAttributes wa = {
+		.override_redirect = True,
+		.background_pixmap = ParentRelative,
+		.event_mask = ButtonPressMask|ExposureMask
+	};
+	for (m = mons; m; m = m->next) {
+		m->tagwin = XCreateWindow(dpy, root, m->wx, m->by + bh, m->mw / 4, m->mh / 4, 0,
+				DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen),
+				CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
+		XDefineCursor(dpy, m->tagwin, cursor[CurNormal]->cursor);
+		XMapRaised(dpy, m->tagwin);
+		XUnmapWindow(dpy, m->tagwin);
+	}
+}
+

modify this to

+void
+updatepreview(void)
+{
+	Monitor *m;
+
+	XSetWindowAttributes wa = {
+		.override_redirect = True,
+		.background_pixmap = ParentRelative,
+		.event_mask = ButtonPressMask|ExposureMask
+	};
+	for (m = mons; m; m = m->next) {
+		m->tagwin = XCreateWindow(dpy, root, m->wx, m->by + bh, m->mw / scalepreview, m->mh / scalepreview, 0,
+				DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen),
+				CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
+		XDefineCursor(dpy, m->tagwin, cursor[CurNormal]->cursor);
+		XMapRaised(dpy, m->tagwin);
+		XUnmapWindow(dpy, m->tagwin);
+	}
+}
+

This solution maybe will handle your problem.

I don't believe that it was only it! Just exchange a four by the variable. I think this bug fix should be on dwm suckless site as well.

@baizeyv
Copy link
Contributor
baizeyv commented Oct 9, 2021

@renanwp2 This patch is not mine, I just found this little bug during debugging. The creator of this patch is explosion-mental.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
0