SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2011-09-04 05:42:49

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,466
Website

The Smileotron: quickly add a custom smilie to a post.

If you can't find the exact smilie you need on the list at the top of your input box, or (sacrilege vYTZ5aA) want a yellow one... You can quickly paste one into a forum post with this script.

setup: You need the utilities feh curl & xsel. They're all small and handy things to have, and in the repositories. Copy the code into a file eg smilies.sh, make it executable and tie it to a keybinding in rc.xml. Make a folder for your smilies, put some smiley images there (jpg, gif or png for the web, and make them fairly small), and edit the top of smileys.sh to the true path to your smileys folder.

usage: Hit the keyboard shortcut you set, click a smiley in the window that comes up, hit "Enter", then paste the BBC code into your forum post with the middle mouse button. That's it. (To cancel, just close the feh window.)

#!/bin/bash
## choose an image file from a folder and get its ompload url + bbcode to paste.
## Dependencies: feh curl xsel 

SMILEY_DIR="$HOME/images/smilies" # set your folder for smileys (and put some there)

[[ -d $SMILEY_DIR ]] || { echo "$0: $SMILEY_DIR no such directory" >&2; exit 1;}

[[ $1 = --load ]] || {
    exec feh -t "$SMILEY_DIR" --quiet --title 'Choose a smiley (click, then press enter)' --index-name no --image-bg black --action "$0 --load %n;"
    exit
}

####################################################

# if "--load" option passed, upload image to omploader (if necessary) and print out url

file="$SMILEY_DIR/$2"
[[ $(feh -U "$file") ]] || { echo "$0: $2 no such image file in $SMILEY_DIR" >&2; exit 1;}
[[ -f ${file}.url ]] || {
    curl --silent -F file1=@"$file" http://ompldr.org/upload|awk 'BEGIN{RS="<div class=\"left\">";FS="<\/div>"}/File:/{gsub(/<[^>]+>/,"",$2);printf "%s",$2}' > "${file}.url"
}

# uncomment end of next line to use clipboard instead of selection
printf '[img]%s[/img]' "$(<"${file}.url")" | xsel --input #--clipboard
pkill -f "feh -t $SMILEY_DIR"
exit

If you'd rather paste with Ctrl+V than the middle mouse button, edit the xsel options at the bottom of the script.

How it works: Feh has a "thumbnails" option - if you click one of the thumbnails in the window it opens a new one with that image (very small so you might not notice it). When you hit Enter feh runs a custom "action" which in this case reruns the script to check the image for a filename.url file. If it finds one, that url gets put into the primary selection (or, optionally, clipboard) to paste. If there's no url file the image gets uploaded to omploader and the returned url written into a file for next time, so we don't spam out omploader. Finally the original feh window has to be closed, with pkill not killall in case there's a different feh process also running (wallpaper?).

vYTZ5aw

Last edited by johnraff (2011-09-09 04:05:30)


John
--------------------
( a boring Japan blog , and idle twitterings )

Online

Help fund CrunchBang, donate to the project!

#2 2011-09-09 04:14:05

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,466
Website

Re: The Smileotron: quickly add a custom smilie to a post.

Added a few extra notes, and gave it a name.

Been using this a few days now and it seems to do the job OK. Only mild annoyance is having to press enter as well as clicking the image. I can't think of any way to cut out that extra step. Maybe now Openbox supports icons a pipe menu might be possible?


John
--------------------
( a boring Japan blog , and idle twitterings )

Online

#3 2011-11-23 03:27:02

anthony
Member
From: Brisbane, Australia
Registered: 2010-04-05
Posts: 13
Website

Re: The Smileotron: quickly add a custom smilie to a post.

It would be nice to be able to perform an 'action' in the thumbnail window

Perhaps  montage and index modes  could report the image selected with the mouse 'action',  where thumbnail mode 'opens' the image.

I have also been looking for some image viewer that can report locations of user 'mouse clicks' in the window.

Some type of 'remote control' such as "gqview" and "display" (from Imagemagick) would also be very useful!

Last edited by anthony (2011-11-28 01:41:24)


Anthony Thyssen   -- Webmaster for ImageMagick Example Pages
                  http://www.imagemagick.org/Usage/

Offline

#4 2011-11-25 16:27:25

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,466
Website

Re: The Smileotron: quickly add a custom smilie to a post.

@anthony yes it would be nice if you could call your custom action directly from the thumbnail window, saving a click, but that's all feh has to offer as far as I can tell.

What do you mean by "remote control"?


John
--------------------
( a boring Japan blog , and idle twitterings )

Online

#5 2011-11-28 01:39:10

anthony
Member
From: Brisbane, Australia
Registered: 2010-04-05
Posts: 13
Website

Re: The Smileotron: quickly add a custom smilie to a post.

Some client programs let you run them with a --remote option.  This mean instead of opening a new window, look for an already running window and pass the arguments to it. A technique netscape originally developed, for remote control of the currently viewed web page.

For example "display -remote" (from ImageMagick) will let you replace the currently viewed image with a new one without having to close and restart the application.

The USR1 signal for "feh" is one such 'remote control', making it useful for interactive scripts.   What is really lacking in image display programs is better feedback from such applications (image finished loading and is now displayed, or user clicks in image)


I wrote up a few notes on image remote control, on the page
    http://www.ict.griffith.edu.au/anthony/ … ontrol.txt

Last edited by anthony (2011-11-28 01:40:08)


Anthony Thyssen   -- Webmaster for ImageMagick Example Pages
                  http://www.imagemagick.org/Usage/

Offline

#6 2012-05-09 05:31:53

machinebacon
#! unstable
From: PRC
Registered: 2009-07-02
Posts: 6,212
Website

Re: The Smileotron: quickly add a custom smilie to a post.

vZG13dQ

Must bump this! John, you're a genius big_smile

vZG9jcQ


Start Distrohopping here! -> Break your own... cool  VSIDO  cool LinuxCNC  kiss Frugalware <- It's all just a kernel.

Offline

#7 2012-05-10 04:08:40

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,466
Website

Re: The Smileotron: quickly add a custom smilie to a post.

...ah praise!  More! More! vYWU1Zw

(PS Don't forget your smilie will be on a black backgound page here at #!.)

Last edited by johnraff (2012-05-10 04:09:47)


John
--------------------
( a boring Japan blog , and idle twitterings )

Online

#8 2012-05-10 04:12:28

machinebacon
#! unstable
From: PRC
Registered: 2009-07-02
Posts: 6,212
Website

Re: The Smileotron: quickly add a custom smilie to a post.

Yes, you forgot to add a transparency setting to your script!  vZG90ZA


Start Distrohopping here! -> Break your own... cool  VSIDO  cool LinuxCNC  kiss Frugalware <- It's all just a kernel.

Offline

#9 2012-05-10 05:37:30

pvsage
Internal Affairs
From: North Carolina
Registered: 2009-10-18
Posts: 9,021

Re: The Smileotron: quickly add a custom smilie to a post.


while ( ! ( succeed = try() ) );
We've earned a reputation as a nice, friendly community; please help us keep it that way.

Offline

#10 2012-05-10 05:55:47

machinebacon
#! unstable
From: PRC
Registered: 2009-07-02
Posts: 6,212
Website

Re: The Smileotron: quickly add a custom smilie to a post.


Start Distrohopping here! -> Break your own... cool  VSIDO  cool LinuxCNC  kiss Frugalware <- It's all just a kernel.

Offline

#11 2012-05-12 05:37:19

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,466
Website

Re: The Smileotron: quickly add a custom smilie to a post.

machinebacon wrote:

Yes, you forgot to add a transparency setting to your script!

True. OK a bit of processing with image/graphicsmagick before uploading the image? Could be done I guess.

(but I've got a cold)


John
--------------------
( a boring Japan blog , and idle twitterings )

Online

#12 2012-05-12 05:40:00

machinebacon
#! unstable
From: PRC
Registered: 2009-07-02
Posts: 6,212
Website

Re: The Smileotron: quickly add a custom smilie to a post.

^ I was kidding smile Hope you get well soon, you better relax and have a tea ~~


Start Distrohopping here! -> Break your own... cool  VSIDO  cool LinuxCNC  kiss Frugalware <- It's all just a kernel.

Offline

#13 2012-05-14 17:32:17

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,466
Website

Re: The Smileotron: quickly add a custom smilie to a post.

^Thought you might be, but Genius carries with it a certain sense of responsibility. wink

It's been a nasty cold, thanks for the good wishes, and seems finally to be improving a bit.


John
--------------------
( a boring Japan blog , and idle twitterings )

Online

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo