You are not logged in.

#101 2012-09-06 04:56:13

illusionist
Member
From: localhost
Registered: 2012-04-03
Posts: 498

Re: Dmenu Hacking Thread

Army wrote:

I don't use it, but as far as I understand this looks like you need the pango patch.

hmm... I was also thinking that , anyways thank you for your script and your time for replying.

Edit: quoted army's reply

Last edited by illusionist (2012-09-06 04:57:41)


  Never argue with stupid people,They will drag you down to their level and then beat you with experience.--Mark Twain
@github

Offline

#102 2012-09-07 04:53:06

avx
Member
Registered: 2011-07-05
Posts: 71

Re: Dmenu Hacking Thread

Maybe someone can tell me, if something like the following already exists...

I'd like to have a dmenu capable of being a) multiline per entry and b) supporting alternating colors. If it's not clear what I mean, here is a simple visualization of a)

> prompt
element 1
# some text belonging
# to element one
element n
# some text belonging
# to element n

As for colors, everything element-1 should f.e. have a blue background, while everything for element-n should have a red one. Bonus points for making single words/strings/lines bold/italic.

Offline

#103 2012-09-30 14:59:27

Rasi
Member
From: Germany
Registered: 2007-08-14
Posts: 1,914
Website

Re: Dmenu Hacking Thread

Zeltak and I created a little Screenshot dmenu script:

#!/bin/bash
#changelog
#v0.3
#added 1. Notifications 2.unique names for each type (for quick launch) 3.better photo editor (pinta) 4.dmenu title
#v0.4
#1.Added variable for notification timeouts. 2. Show link in notification


IMG_PATH=/home/carnager/Pictures/Screenshots/
UL=fb
EDIT=pinta
TIME=3 #Seconds notification should remain visible


prog="
---Local screenshots (saved at IMG_PATH)---
1.quick_fullscreen
2.delayed_fullscreen
3.section
4.edit_fullscreen
---Upload to remote service (images will be deleted)---
a.upload_fullscreen
u.upload_delayed_fullscreen
e.edit_upload_fullscreen
s.upload_section
p.edit_upload_section
"

cmd=$(dmenu  -l 20  -nf '#999' -nb '#000' -sf '#eee' -sb '#0077bb' -p 'Choose Screenshot Type'   <<< "$prog")

cd $IMG_PATH
case ${cmd%% *} in

	1.quick_fullscreen)	scrot -d 1 '%Y-%m-%d-@%H-%M-%S-scrot.png'  && notify-send -u low -t $TIME 'Scrot' 'Fullscreen taken and saved'  ;;
	2.delayed_fullscreen)	scrot -d 4 '%Y-%m-%d-@%H-%M-%S-scrot.png'  && notify-send -u low -t $TIME 'Scrot' 'Fullscreen Screenshot saved'    ;;
	3.section)	scrot -s '%Y-%m-%d-@%H-%M-%S-scrot.png' && notify-send -u low -t $TIME 'Scrot' 'Screenshot of section saved'    ;;
	4.edit_fullscreen)	scrot -d 1 '%Y-%m-%d-@%H-%M-%S-scrot.png' -e "$EDIT \$f"  && notify-send -u low -t $TIME 'Scrot' 'Screenshot edited and saved' ;;

a.upload_fullscreen)	scrot -d 1 '%Y-%m-%d-@%H-%M-%S-scrot.png' -e "$UL \$f" && (xclip -o;echo) | xclip -selection clipboard  && notify-send -u low -t $TIME "Scrot" "Screenshot Uploaded (powered by fb) - $(xclip -o;echo)"  ;;
    u.upload_delayed_fullscreen)	scrot -d 4 '%Y-%m-%d-@%H-%M-%S-scrot.png' -e "$UL \$f"  && (xclip -o;echo) | xclip -selection clipboard  && notify-send -u low -t $TIME "Scrot" "Screenshot Uploaded (powered by fb) - $(xclip -o)"  ;;
	e.edit_upload_fullscreen)	scrot -d 4 '%Y-%m-%d-@%H-%M-%S-scrot.png' -e "$EDIT \$f && $UL \$f && rm -f \$f"  && notify-send -u low -t $TIME "Scrot" "Screenshot Uploaded (powered by fb) - $(xclip -o)"  ;;
s.upload_section)	scrot -s '%Y-%m-%d-@%H-%M-%S-scrot.png' -e "$UL \$f"  && (xclip -o;echo) | xclip -selection clipboard   &&  notify-send -u low -t $TIME "Scrot" "Screenshot Uploaded (powered by fb - $(xclip -o)";;
    p.edit_upload_section)  scrot -s '%Y-%m-%d-@%H-%M-%S-scrot.png' -e "$EDIT \$f && $UL \$f && rm -f \$f"  && (xclip -o;echo) | xclip -selection clipboard && notify-send -u low -t $TIME "Scrot" "Screenshot Uploaded (powered by FB) - $(xclip -o)"  ;;


  	*)		exec "'${cmd}'"  ;;
esac

He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.

Douglas Adams

Offline

#104 2012-10-29 21:09:28

Rasi
Member
From: Germany
Registered: 2007-08-14
Posts: 1,914
Website

Re: Dmenu Hacking Thread

new version, now supports Screencasts and uploading of actual clipboard. Also added a timer for delayed screenshots

#!/bin/bash
# teiler - A script to share (german word: teilen) screenshots/casts for tiling WMs - Pun intended
# (c) Rasmus Steinke <rasi at xssn dot at> 
# Additional Ideas, testing and some code by Zeltak <zeltak at gmail dot com>
#
# Requirements:
# xclip, fb-client, pinta, dzen2, dmenu, ffmpeg, scrot, bc, some notification daemon


#changelog
#v0.8
#Put notify-send into its own function, Made delay being calculated from counter value.
#v0.7
#Massive Code Cleanup
#v0.6
#Countdown script stolen from Google and integrated.
#v0.5
#added clip uploading
#v0.4
#added screencast function
#v0.3
#added 1.notifications 2.unique names for each type (for quick launch) 3.better photo editor (pinta) 4.dmenu title


############### Configuration options ##############################

IMG_PATH=/home/carnager/Pictures/Screenshots/
FILEMASK=%Y-%m-%d-@%H-%M-%S-scrot.png
UL=fb
EDIT=pinta
RES=1920x1080   #set your screen resolution
TIME=3          #How long will notifications be visible?
COUNTER1=3      #Seconds to count for delay (Use $COUNTD variable)
COUNTER2=6      #Seconds to count for delay (Use $COUNTD2 variable)


#DMENU/DZEN2 CONFIGURATION
FONT="Envy Code R-9"
NF="#7c7c72"
NB="#1a1a1a"
SF="#FFFFFF"
SB="#33B5E5"
DZEN2_W=100     #Width of dzen2
DZEN2_X=850     #X Padding

################## Configuration End ##############################


# Needed for the countdown
# Based on some script by  Marco Fontani - MFONTANI at cpan dot org
set -bm
COLOR='#7c7c72'
function countdown () {
    seq 1 ${1:-10} | tac | \
        perl -ne'BEGIN{$|++;$msg=shift}$m=int($_/60);$s=int($_-$m*60);printf("$m:%02d -- $msg\n",$s);sleep 1;' \
        "${2:-ready...}"
}


# Outsource the notfiy-send to its own function to clean up the mess below a bit ;)
function notify() {
  notify-send -u low -t ${1} "Scrot" "${2}"
}

####Some Variables to clean up the code a bit
COUNTD="countdown $COUNTER1 GO | dzen2 -fn \"$FONT\" -fg \"$NF\" -ta c -w \"$DZEN2_W\" -bg \"$NB\" -x \"$DZEN2_X\""
COUNTD2="countdown $COUNTER2 GO | dzen2 -fn \"$FONT\" -fg \"$NF\" -ta c -w \"$DZEN2_W\" -bg \"$NB\" -x \"$DZEN2_X\""
XCLIP="(xclip -o;echo) | xclip -selection clipboard"



prog="
---Local screenshots (saved at IMG_PATH)---
1.quick_fullscreen
2.delayed_fullscreen
3.section
4.edit_fullscreen
5.edit_section
---Upload to remote service (images will be deleted)---
a.upload_fullscreen
u.upload_delayed_fullscreen
e.edit_upload_fullscreen
s.upload_section
p.edit_upload_section
---Screencasts
c.cast
k.kill_cast
---Clipboard
x.upload_clip
"


cmd=$(dmenu -l 20 -fn "$FONT" -nf $NF -nb $NB -sf $SF -sb $SB -p 'Choose Screenshot Type'   <<< "$prog")

cd $IMG_PATH
case ${cmd%% *} in

    #for local screenshots
    1.quick_fullscreen)             scrot -d 1 "$FILEMASK" && notify ${TIME} "Screenshot saved"  ;;
    2.delayed_fullscreen)           eval $COUNTD & scrot -d $(echo $COUNTER1+1 | bc) "$FILEMASK" && notify ${TIME} "Screenshot saved"     ;;
    3.section)                      scrot -s "$FILEMASK" && notify ${TIME} "Screenshot saved"    ;;
    4.edit_fullscreen)              scrot -d 1 "$FILEMASK" -e "$EDIT \$f" && notify ${TIME} "Screenshot edited and saved" ;;
    5.edit_section)                 scrot -s "$FILEMASK" -e "$EDIT \$f" && notify ${TIME} "Screenshot edited and saved"  ;;

    #for remote uploads
    a.upload_fullscreen)            scrot -d 1 "$FILEMASK" -e "$UL \$f" && eval $XCLIP && notify ${TIME} "Screenshot uploaded"  ;;
    u.upload_delayed_fullscreen)    eval $COUNTD & scrot -d $(echo $COUNTER1+1 | bc) "$FILEMASK" -e "$UL \$f && rm -f \$f" && eval $XCLIP && notify ${TIME} "Screenshot uploaded"  ;;
    e.edit_upload_fullscreen)       scrot -d 1 "$FILEMASK" -e "$EDIT \$f && $UL \$f && rm -f \$f" && eval $XCLIP && notify ${TIME} "Screenshot uploaded"  ;;
    s.upload_section)               scrot -s "$FILEMASK" -e "$UL \$f && rm -f \$f" && eval $XCLIP && notify ${TIME} "Screenshot uploaded"  ;;
    p.edit_upload_section)          scrot -s "$FILEMASK" -e "$EDIT \$f && $UL \$f && rm -f \$f" && eval $XCLIP && notify ${TIME} "Screenshot uploaded"  ;;

    #for screencasts
    c.cast)                         ffmpeg -r 25 -f x11grab -s $RES -i :0.0+0,0 -vcodec libx264 temp_cast.mkv && notify ${TIME} "Screencast started"  ;;
    k.kill_cast)                    kill $(pgrep -f x11grab) && sleep 3 && $UL temp_cast.mkv && rm -f temp_cast.mkv && eval $XCLIP && notify ${TIME} "Screencast uploaded"  ;;

    #for clipboard content
    x.upload_clip)                  eval $COUNTD2 & sleep $(echo $COUNTER2+1 | bc) && xclip -o | fb && eval $XCLIP && notify ${TIME} "Clipboard uploaded"
;;

	*)		exec "'${cmd}'"  ;;
esac

Edit 01/2014: The script basically ad a rewrite, with lots of config options now. you can get it here: http://git.53280.de/carnager/teiler/

Last edited by Rasi (2014-01-29 04:11:08)


He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.

Douglas Adams

Offline

#105 2012-10-29 21:47:58

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: Dmenu Hacking Thread

Here's dmenu with pango and image support: github
I use it myself with lolimpd:
tZzFsaw

Maybe you can find some use for it as well.. It's not that pretty, but works-

Offline

#106 2012-10-30 03:13:11

illusionist
Member
From: localhost
Registered: 2012-04-03
Posts: 498

Re: Dmenu Hacking Thread

Cloudef wrote:

Here's dmenu with pango and image support: github
I use it myself with lolimpd:
http://ompldr.org/tZzFsaw

Maybe you can find some use for it as well.. It's not that pretty, but works-

This is freakin awesome . Thank you so much for sharing this with us man . Now army's dmenu-translate works amazingly for me.
We really have a great community. smile


  Never argue with stupid people,They will drag you down to their level and then beat you with experience.--Mark Twain
@github

Offline

#107 2012-10-30 07:45:53

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: Dmenu Hacking Thread

This is freakin awesome . Thank you so much for sharing this with us man . Now army's dmenu-translate works amazingly for me.
We really have a great community.

There's also dmenu-pango in aur by me as well, if you only need the pango support.

Offline

#108 2012-10-30 17:14:27

illusionist
Member
From: localhost
Registered: 2012-04-03
Posts: 498

Re: Dmenu Hacking Thread

@Cloudef
yes i know that ( after checking your github , I saw that in aur) but i like the imlib support too. who does not like some extra functionality. tongue

EDIT: just one suggestion though , you may remove the default font line in pango patch. I did that and now passing the "-fn" flag  to dmenu actually changes the font before that it was not working for me. In fact some people were having this problem too ( I saw those threads here.)

Last edited by illusionist (2012-10-30 17:20:31)


  Never argue with stupid people,They will drag you down to their level and then beat you with experience.--Mark Twain
@github

Offline

#109 2012-10-30 17:39:28

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: Dmenu Hacking Thread

illusionist wrote:

@Cloudef
EDIT: just one suggestion though , you may remove the default font line in pango patch. I did that and now passing the "-fn" flag  to dmenu actually changes the font before that it was not working for me. In fact some people were having this problem too ( I saw those threads here.)

I don't see such problem here. The pango patch uses the syntax "<fontname> <size>",
eg. "IPAMonaGothic 12". Works fine here.

If it still doesn't, I'll remove the default font line from patch, I guess.

Last edited by Cloudef (2012-10-30 17:39:47)

Offline

#110 2012-10-31 19:04:49

Runiq
Member
From: Germany
Registered: 2008-10-29
Posts: 1,053

Re: Dmenu Hacking Thread

It seems I'm not able to start anything with dmenu-pango since about yesterday (or the day before yesterday). There's no output either (aside from the usual fontconfig warnings due to infinality).

My system is up to date, and an unpatched dmenu works fine. Anyone got an idea what could be causing this?

Edit: The menu starts up just fine, I should add; there are no issues with displaying anything. It's just that, when I press Return, nothing happens.

Last edited by Runiq (2012-10-31 19:06:12)

Offline

#111 2012-10-31 19:05:59

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: Dmenu Hacking Thread

@runiq, I fixed this on the imlib github.. Lemme fix the normal -pango on aur as well.
EDIT: Should be there now, can you test?

Last edited by Cloudef (2012-10-31 19:12:40)

Offline

#112 2012-10-31 19:07:23

Runiq
Member
From: Germany
Registered: 2008-10-29
Posts: 1,053

Re: Dmenu Hacking Thread

Cloudef wrote:

@runiq, I fixed this on the imlib github.. Lemme fix the normal -pango on aur as well.

Thanks a lot!

See, guys? That's what I call fast turnaround. Bug is literally fixed before I even finished reporting it. tongue

Offline

#113 2012-10-31 19:15:27

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: Dmenu Hacking Thread

See the edit above.
It frozes on the dc cleanup method.. Din't bother to debug it further, so just commented it out, linux will free the resources anyways after program exits.
But I bet it does something dirty that it should not and causes the lockup. Valgrind would propably tell the reason.

See, guys? That's what I call fast turnaround. Bug is literally fixed before I even finished reporting it.

I use dmenu myself daily. Can't go unnoticed smile

Offline

#114 2012-10-31 19:22:47

Runiq
Member
From: Germany
Registered: 2008-10-29
Posts: 1,053

Re: Dmenu Hacking Thread

Cloudef wrote:

EDIT: Should be there now, can you test?

Yup, works. Thanks again. smile

Offline

#115 2012-11-01 03:58:30

Archer777
Member
Registered: 2012-06-12
Posts: 13

Re: Dmenu Hacking Thread

Add currently playing song in mpd to any playlist.

#!/bin/bash

PL_DIR="$HOME/.mpd/playlists"		# Playlists directory

song=`mpc current -f %file%`		# Currently playing song
pl=`mpc lsplaylists | dmenu -i -l 20 -p "MPD Playlists: "` || exit	# Playlists
sl_pl="$PL_DIR/$pl.m3u"			# Selected playlist

# Check if song already exist in playlist, if not add it.
cat "$sl_pl" | grep -Fxq -m1 "$song" || echo "$song" >> $sl_pl

Offline

#116 2012-11-01 05:34:40

illusionist
Member
From: localhost
Registered: 2012-04-03
Posts: 498

Re: Dmenu Hacking Thread

@Cloudef
Thank you for fixing the patch against default font and the bug runiq stated. I also had the same problem. Though it was a consolekit problem . :headslap


  Never argue with stupid people,They will drag you down to their level and then beat you with experience.--Mark Twain
@github

Offline

#117 2012-11-01 19:12:10

Supplantr
Member
From: a state of sunshine
Registered: 2011-12-12
Posts: 149
Website

Re: Dmenu Hacking Thread

later: a simple "read-it-later"-style script with the option to add a "memo" to entries. I bind later -s to a key.

#!/usr/bin/env bash

DMENU='dmenu -l 50'
[ -f "$HOME/.dmenurc" ] && . "$HOME/.dmenurc" && DMENU+="$DMENU_ARGS"
SEL='xsel'
DATE='date'
FILE="$HOME/.later"

if [ -z "$1" ]; then
    pick="$($DMENU < $FILE)"
    if [ "$pick" ]; then
        IFS='>' read -ra entry <<< "$pick"
        len="${#entry[@]}"
        "$BROWSER" "${entry[$(( $len - 2 ))]}" && \
        sed -i "/${entry[$(( $len - 1 ))]}/d" "$FILE"
    fi
else
    line="$($DATE)"
    if [ "$1" == '-s' ]; then
        line="$($SEL) > $line"
        memo="$($DMENU -p memo: <&-)"
        [ "$memo" ] && line="$memo > $line"
    else
        line="$1 > $line"
        [ "$2" ] && line="$2 > $line"
    fi
    echo "$line" >> "$FILE"
fi

Last edited by Supplantr (2012-11-01 19:59:08)


I use linux and I dont understand nothing in this post.

Offline

#118 2012-11-01 20:57:55

avx
Member
Registered: 2011-07-05
Posts: 71

Re: Dmenu Hacking Thread

@Cloudef, nice work. Would be even nicer, if the thumbnail-size could be configurable, they are really tiny for me.

Offline

#119 2012-11-01 21:31:05

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: Dmenu Hacking Thread

@avx, it can. See the -is option, however tuning this up can make the rendering really slow. Use with care.
(Also, it will regenerate thumbnails, if last generated one was different size.., see the man page)

Offline

#120 2012-11-01 21:40:36

avx
Member
Registered: 2011-07-05
Posts: 71

Re: Dmenu Hacking Thread

Damn, missed that, thanks. About regeneration, why not store them as filename-$size?

Dunno if possible, but what about having the option of putting the output of some command in the space underneath the current thumbnails's position? Depending on the file(if the list only consists of those), things like filetype, dimensions, playtime, etc could be useful. So something like this

IMG:/foo\tCMD:ls\s-l\tfile

Offline

#121 2012-11-01 22:08:37

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: Dmenu Hacking Thread

Damn, missed that, thanks. About regeneration, why not store them as filename-$size?

Currently it uses basic 32 bit int hashing, that does not care about collisions that much, I could salt the size to the hash so the image doesn't need to be regenerated.
However, changing the hashing to SHA1 might be better then as well.

The current implementation is kind of hack job. You can feel free provide patches to it.
I might be able to do this sometime however, and make option to skip the cache all together.
It's not needed if the source image is small, or if you have only few menu items.

Dunno if possible, but what about having the option of putting the output of some command in the space underneath the current thumbnails's position? Depending on the file(if the list only consists of those), things like filetype, dimensions, playtime, etc could be useful. So something like this

Subtext for image? Yes this could be possible.

Last edited by Cloudef (2012-11-01 22:09:05)

Offline

#122 2012-11-02 10:14:18

avx
Member
Registered: 2011-07-05
Posts: 71

Re: Dmenu Hacking Thread

I could see a horizontal line of images, each with their respected text underneath them as being a nice way to browse f.e. a music-/videolibrary.

I like the approach so far, hacked a little UI with it around recoll's CLI search. Though I must say, some logic only/additionally picking up pre-built thumbs would be nice as there's AFAIK no direct way creating thumbs of f.e. text documents only using imlib.

Offline

#123 2012-11-02 15:00:48

xj9578cd
Member
Registered: 2011-03-21
Posts: 3

Re: Dmenu Hacking Thread

I have been using Dmenu for some time, and recently it changed color to black and no longer offers completion. I tried reinstalling it but its the same. However, I was able to change the color using a script. Still no completion.

Offline

#124 2012-11-02 16:46:44

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: Dmenu Hacking Thread

I like the approach so far, hacked a little UI with it around recoll's CLI search. Though I must say, some logic only/additionally picking up pre-built thumbs would be nice as there's AFAIK no direct way creating thumbs of f.e. text documents only using imlib.

Use -g option to generate thumbnails from stdin input.. Make sure you provide the correct size.
I have mpd dmenu client that uses the images like you've describen. You might be also interested in -si option that lets you specify start index (eg. playing track, or playing video).

Last edited by Cloudef (2012-11-02 16:47:00)

Offline

#125 2012-11-15 12:30:02

Pranavg1890
Member
From: Nagpur,India
Registered: 2012-09-07
Posts: 114

Re: Dmenu Hacking Thread

Hi , can anyone give me a script to select windows in dwm using dmenu just like in musca wm? Many thanks.f


Using Openbox + Tint2 + Idesk

Offline

Board footer

Powered by FluxBB