Skip to content
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

No way to pass font name with space in DMENU_CMD #7

Closed
oblitum opened this issue Oct 26, 2020 · 17 comments
Closed

No way to pass font name with space in DMENU_CMD #7

oblitum opened this issue Oct 26, 2020 · 17 comments

Comments

@oblitum
Copy link

oblitum commented Oct 26, 2020

I'm trying to set font for the menu but seems there's no way to set font with spaces?

DMENU_CMD="dmenu -f -p slip -fn 'BigBlue_TerminalPlus Nerd Font-16:regular' -i -y 520 -x 192 -w 1536 -h 40 -nb #444B6A -sb #444B6A -nf #F7768E -sf #E0AF68"
@Toqozz
Copy link
Owner

Toqozz commented Oct 27, 2020

Thanks for creating an issue!

I've fixed this now (4d8d591), available on master or tag 2.0.5.

Your above command should now work.

@Toqozz Toqozz closed this as completed Oct 27, 2020
@oblitum
Copy link
Author

oblitum commented Oct 27, 2020

I tried but still same result. I tried 3 versions, with single quotes, with escaped double quotes, and with escaped spaces, none worked.

FWIW, I have the same command working in i3 config.

@Toqozz
Copy link
Owner

Toqozz commented Oct 27, 2020

Hmm... It works for me with single quotes.

What happens? Is there any error or otherwise?

@Toqozz Toqozz reopened this Oct 27, 2020
@oblitum
Copy link
Author

oblitum commented Oct 27, 2020

I only get dmenu usage as output, which seems a side effect of passing broken params:

usage: dmenu [-b] [-q] [-f] [-r] [-i] [-z] [-t] [-mask] [-noinput]
             [-s screen] [-name name] [-class class] [ -o opacity]
             [-dim opcity] [-dc color] [-l lines] [-p prompt] [-fn font]
             [-x xoffset] [-y yoffset] [-h height] [-w width]
             [-nb color] [-nf color] [-sb color] [-sf color] [-v]

I also tried reversing quotes and using outer single quotes and inner double quotes, didn't work either.

@oblitum
Copy link
Author

oblitum commented Oct 27, 2020

Ah, it's working, the issue now lies in the colors with #.

@oblitum
Copy link
Author

oblitum commented Oct 27, 2020

Okay, found the fix. Putting the color constants in single quotes fixes the issue, but maybe this change broke previous way of passing colors?

@Toqozz
Copy link
Owner

Toqozz commented Oct 27, 2020

Possibly. I switched from $DMENU_CMD to eval "$DMENU_CMD", which should be better overall anyway.

Interpretation of the command is up to the shell, so if it doesn't work in a prompt (unquoted hashes don't for me), it probably won't work in the script.

@Toqozz Toqozz closed this as completed Oct 27, 2020
@oblitum
Copy link
Author

oblitum commented Oct 27, 2020

It seems like it broke when stopping recording. I'm now getting the same dmenu usage output.

@Toqozz
Copy link
Owner

Toqozz commented Oct 27, 2020

Oops! Looks like I missed a few $DMENU_CMD's. Patching now.

@Toqozz
Copy link
Owner

Toqozz commented Oct 27, 2020

Now fixed in aa40672 (2.0.6). Please let me know if there's anything else.

Thanks for your patience!

@oblitum
Copy link
Author

oblitum commented Oct 27, 2020

Working fine now, thx!

@oblitum
Copy link
Author

oblitum commented Oct 27, 2020

FYI, just a suggestion. I just tried gifski and it may be interesting tool to integrate. I know peek has it integrated.

@oblitum
Copy link
Author

oblitum commented Oct 27, 2020

FYI, just a suggestion. I just tried gifski and it may be interesting tool to integrate. I know peek has it integrated.

For example, I used slip to generate a video, then produced a gifski gif from it without rescaling, quality is much better.

@Toqozz
Copy link
Owner

Toqozz commented Oct 28, 2020

I'm hesitant about introducing dependencies that aren't available in most standard repos. Also, gifski is not a straight upgrade -- it sacrifices file size, which is concerning for uploading to imgur (gfycat uploads use the video file directly, so no change here).

@oblitum
Copy link
Author

oblitum commented Oct 28, 2020

yeah I agree, but I view it as optional. It is still able to produce short timed gifs of high quality. I've patched slip locally to use it instead of the ffmpeg approach.

@oblitum
Copy link
Author

oblitum commented Oct 28, 2020

❯ diff -u /usr/bin/slip ~/.local/bin/slip:

--- /usr/bin/slip       2020-10-26 23:08:08.000000000 -0300
+++ /home/francisco/.local/bin/slip     2020-10-30 12:58:51.618134779 -0300
@@ -175,22 +175,12 @@

 function convert_to_gif() {
     local tfn=$1
-    local pfn=$2
-    local fn=$3
-    local wh=$4 # 0 = width larger than height, 1 = height larger than width
-
-    local ratio
-    # If the width is larger than the height, we want to scale with the width, otherwise scale with the height.
-    if [ $wh -eq 0 ]; then
-        ratio="$GIF_SCALE:-1"
-    else
-        ratio="-1:$GIF_SCALE"
-    fi
+    local fn=$2
+    local wh=$3 # 0 = width larger than height, 1 = height larger than width

     notify "Converting to gif…"
     # Give enough time to save the file.
-    sleep 1 && ffmpeg -i "$tfn" -loglevel quiet -vf fps=$GIF_FPS,scale="$ratio":flags=lanczos,palettegen "$pfn" &&
-    ffmpeg -i "$tfn" -i "$pfn" -loglevel quiet -filter_complex "fps=$GIF_FPS,scale=$ratio:flags=lanczos[x];[x][1:v]paletteuse" "$fn" &&
+    sleep 1 && gifski --quiet --width "$GIF_SCALE" -o "$fn" "$tfn" &&

     echo "$fn"
 }
@@ -201,7 +191,6 @@
     local pid=$1                      # Process id (for killing ffmpeg).
     local tfn=$3                      # Temp file name (for gifs).
     local fn=$4                       # File name for the gif/vid we're saving.
-    local pfn="${tfn}-palette.png"    # Palette file name (for gif rendering).

     # Stop recording.
     kill_ffmpeg "$pid"
@@ -211,7 +200,7 @@
     #   the .gif file.
     # Is this actually a good idea?  We could just store the .mkv instead, but then we lose the ability to store .gif.
     if [ "$2" = "gif" ]; then
-        fn=$(convert_to_gif "$tfn" "$pfn" "$fn" "$5")
+        fn=$(convert_to_gif "$tfn" "$fn" "$5")
         size=$(du -k $fn | cut -f1)

         if [ $NOUPLOAD == 0 ]; then

I have built gifski with cargo install because the Arch Linux community package doesn't come with direct video to gif conversion. Made the command easier to replace, no png generation involved.

@Toqozz
Copy link
Owner

Toqozz commented Oct 28, 2020

Thanks for documenting this. I've added it to the readme.

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

2 participants