SEARCH

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

You are not logged in.

#2 Re: Tips, Tricks & Scripts » working, portable openbox menu gen. available » Today 09:51:54

rmoe wrote:

I for one find icons useful. Not so much for mere attractivity but because they are an additional - and ergonomically powerful - element to quickly guide me through menus.

Me too, to be honest. But it depends on what the price will be... smile

#3 Re: Help & Support (Stable) » Pentium III 800MHz 128MB RAM 20GB HDD » Today 09:47:01

If you really can't get any more RAM, run htop in a terminal and click "MEM%" at the top to see what apps and processes are using the most memory. It might give you some ideas for things to get rid of...

#4 Re: Help & Support (Stable) » How to randomly select and copy mp3 files to an SD card? » Today 09:37:07

ohnonot wrote:
hooliganshark wrote:

Being lazy I am usually too ready to just copy paste....

if you do that only half understanding what it actually does you might easily create more work for yourself instead of less.

@ohnonot you're quite right of course, but we all have our learnig methods and mine, especially with something I've only just started dabbling with, is to take a piece of someone else's code that works and does something vaguely similar to what I'm trying to achieve - then change it here and there and see what happens. If it breaks I try to find out why, go back a step, try again...

Yes it's probably a longer process than doing all the reading first, but I find it more fun. smile

#5 Re: Off Topic / General Chat » the cool random internet stuff thread 1.0 » 2014-10-20 03:07:01

ohnonot wrote:

mysogyny/sexism is a sad & strangely retro (or should i say de-generate) internet phenomenon.

Really. I thought we had moved on from that years ago. neutral

#6 Re: Off Topic / General Chat » the cool random internet stuff thread 1.0 » 2014-10-20 03:01:11

This Bill Gates email has been available since 2008 and posted on many blogs, but I only found it today. Hilarious! Next time you get caught up in a Windows vs Linux discussion you can throw this in: http://blog.seattlepi.com/microsoft/200 … mail-rant/
big_smile

...not that anyone here would want to get involved in any flame wars of course - just good-natured banter, right?  tongue

#7 Re: Help & Support (Stable) » How to randomly select and copy mp3 files to an SD card? » 2014-10-20 02:35:29

It just so happens, pidsley on the LinuxBBQ forum published a script to do this very thing: http://linuxbbq.org/bbs/viewtopic.php?f=4&t=1174

Unfortunately, as he pointed out, pidsley's script, and most of the code on that stackoverflow page, breaks if file names have spaces or line breaks in them. Not a problem if you choose filenames yourself, but if they come from outside, who knows what kind of names they have?

I played with it a bit - I'm still working on the final script - but here are some snippets that might possibly help:

shopt -s globstar nullglob nocaseglob
list=( $SRC/**/*.mp3 )
shopt -u globstar nullglob nocaseglob

This puts all the mp3 filenames in the directory SRC into the array list.
Now ${!list[@]} contains all the array indices - no spaces, just integers. You can do

shuf -e ${!list[@]}

to get a randomized list of all the indices, which you can then use to access the filenames in random order. If DEST is the path to the destination folder on the card and MAX_SIZE is the maximum total size in kb then my script does something like this:

n=0
for i in $(shuf -e ${!list[@]}); do # shuffle indices
    song=${list[$i]}
    tsize=$(($(du -c "$DEST" | awk '/total/{print $1}') + $(du "$song" | awk '{print $1}')))
    [[ $tsize -gt  $MAX_SIZE ]] && {
        [[ $(( tsize - MAX_SIZE )) -gt 10000 ]] && {
            echo "$song is too big to fit - try another";continue # try another file
        }
        break # stop if would go over max size
    }
    ((n++))
    cp "$song" "$DEST/$(printf 'mix%03d-' $n)${song##*/}" # add prefix to stop system from undoing randomness
    echo "added $n $song"
done

A numbered prefix is added to the names on the card so that the system at some point doesn't try to reorder them based on their names, undoing the randomness.

A bit bloated, but might give you some ideas. smile

#8 Re: Tips, Tricks & Scripts » working, portable openbox menu gen. available » 2014-10-19 03:06:13

Thank you rmoe, that new version works nicely, and without icons the output comes in 38ms as opposed to 63ms before (even though I wasn't using the icons anyway).

The speed is really a main attraction here because it means there's no need to update a cached menu when apps are added or removed from the system. Just call the script when you need it.  cool

About icons - I can see why the intricacies and inconsistencies of the way they are provided will annoy you, or anyone... but - and I mean this in a totally positive way - if the user has to manually set up the links for icons of the apps they install, then some of the point of an auto-updating menu is lost.

There are already a number of much bulkier menus (gnome, xfce, lxde...) which go through all those icon folders and come up with an iconified menu, at the cost of speed and system load. If you can hone your script to cover all the corner cases and fill out the menu with all its icons, then that's fantastic! If not, it has a valuable role as a nice text-only menu which takes up no RAM when it's not used.

#9 Re: Off Topic / General Chat » What is the ideal partition? » 2014-10-16 02:24:23

May be wrong, but is 500MB enough for /tmp? What if you were doing some big media conversion process for example?

#10 Re: CrunchBang Talk » strange nvidia adventures using backports on wheezy » 2014-10-13 00:55:46

Sector11 wrote:

Also ... couldn't one just put the nvidia driver on hold?

I think the problem there would be that the new backports kernel doesn't support the old driver.

#11 Re: Tips, Tricks & Scripts » working, portable openbox menu gen. available » 2014-10-12 06:49:58

Thanks - the current version now works OK, though only about 1/2 the items get icons. No problem (for me) I don't use them anyway. It's a nice little text-based menu and is fast enough not to need caching, at least on this machine, so the menu generated is always up to date.  cool

#12 Re: Tips, Tricks & Scripts » working, portable openbox menu gen. available » 2014-10-12 05:15:22

Thank you for that, rmoe! It's working nicely for me in text-only mode, which is what I normally use, but not with icons. In the interests of science I enabled icons in openbox but they aren't being displayed. Here's a snippet of the code which obamenu is giving me:

<menu id="openbox-Office" label="Office"  >
<item icon="/usr/share/pixmaps//usr/share/pixmaps/evince.xpm" label="Document Viewer"><action name="Execute"><command><![CDATA[evince]]></command></action></item>
<item label="LibreOffice Draw"><action name="Execute"><command><![CDATA[libreoffice --draw]]></command></action></item>

As you can see, the string /usr/share/pixmaps/ is being doubled, and icons from /usr/share/icons/Faenza-CrunchBang/categories/24 aren't being output at all.
Here's my config section in the script:

applications_dirs = ("/usr/share/applications","/home/john/.local/share/applications" )
image_dir_base = "/usr/share" # without "pixmaps" -/usr/local/share in FreeBSD, /usr/share on linux
icon_Theme = "Faenza-Crunchbang"
image_cat_prefix = "applications-"
application_groups = ("Office",  "Development",  "Graphics", "Internet",  "Games", "System",  "Multimedia",  "Utilities",  "Settings")
group_aliases = {"Audio":"Multimedia","AudioVideo":"Multimedia","Game":"Games", "Utility":"Utilities", "GTK":"",  "GNOME":""}
ignoreList = ("evince-previewer", "Ted",  "wingide3.2", "python3.4", "feh","xfce4-power-manager-settings" )
terminal_string = "urxvt -e"         # your favourites terminal exec string

Anyway, it's fine for me as it is, but you might want to have a look at those icons. smile

#13 Re: Off Topic / General Chat » What do you do when using technology to secure your Privacy? » 2014-10-09 02:56:12

It's not just officialdom - a deranged stalker might be after you too.  shifty.gif

#14 Re: Off Topic / General Chat » website icon issues » 2014-10-08 08:57:39

good idea!
I was just kidding though. The thought of beer was plenty!

#15 Re: Off Topic / General Chat » website icon issues » 2014-10-08 08:37:41

Yes it's only recently it's been bothering me too. I prefer to keep my own font rather than the webmaster's choice of Times New Roman or whatever, and it always used to work fine but I guess more and more sites are using custom fonts for icons.

There's an addon called Document Font Toggle that handles this nicely, but they've updated it for the latest Firefox and it no longer works with Iceweasel 24.8 sad
(I don't like Fx 30 so much so am not going to upgrade for a while.)

Maybe you can send that six-pack via Dropbox?

#16 Re: Feedback & Suggestions » Invest Vs Donate » 2014-10-08 08:20:47

^^Brilliant!!

(I don't usually bother to check out Youtube links, but this one was well worth it.)

#17 Re: Off Topic / General Chat » website icon issues » 2014-10-08 02:22:04

There's another issue on the user side, connected with fonts. A lot of sites, eg Wordpress, seems like yours too chameleon, use custom fonts to make icons. If the user (Sector11?) unchecks the "Allow websites to choose their own fonts" box in Firefox prefs then some icons get garbled. I think those three strange icons on the top right in S11's screenshots of both sites are due to this. (I get it too if I uncheck that box, which I usually do.) There might not be much the website can do about that one.

Allowing website fonts, both sites look fine here on Iceweasel/Waldorf.

#18 Re: Feedback & Suggestions » How to get involved? » 2014-10-06 02:47:00

@tactonic, another long-term suggestion. If you don't feel like, or feel ready for, writing software, the Linux world in general has a chronic shortage of documentation. Even if you can't write a detailed manual for some esoteric library, in the near future there might be a useful "how-to" you can write on some problem you found out how to solve. smile

#19 Re: Feedback & Suggestions » How to get involved? » 2014-10-06 02:38:59

...and users from here helping out on other forums.  cool

#20 Re: Feedback & Suggestions » Invest Vs Donate » 2014-10-06 02:35:50

"Amateur" has got nothing to do with being inept. The words roots are in "love" and it means one who does what they do for the love of it, not for the money.

#21 Re: Help & Support (Stable) » startup - where is polkit run from » 2014-10-05 08:49:44

@layr (as ohnonot posted while I was thinking about this) I think you were right about the
OnlyShowIn (GNOME, XFCE, Unity)
in the .desktop files in /etc/xdg/autostart
Run

/usr/lib/openbox/openbox-xdg-autostart --list

to see which desktop files are being run by openbox. The OnlyShowIn entries are excluding some, including polkit-gnome-authentication-agent-1.desktop, which is, however running!

I searched around a bit to try and pin down what was actually launching polkit-gnome-authentication-agent-1 and the closest I could get was this hint that ohnonot was on the right track with dbus:
https://bugs.debian.org/cgi-bin/bugrepo … =703016#30
I couldn't find any direct reference to policykit in the files in /etc/X11/Xsession.d, or even in /etc/dbus-1, but dbus (which is started by /etc/X11/Xsession.d/75dbus_dbus-launch) seems likely.

#22 Re: Tips, Tricks & Scripts » Shoutcast and Radionomy tuner for mplayer, mpg123 or radiotray » 2014-10-03 04:46:40

Since that last post Radionomy have also changed their web interface a bit. Luckily, this time it only requires curl to follow a redirect to the new search results page, which means adding a -L option. Script now edited.

#23 Re: Off Topic / General Chat » What's your favorite Dropbox alternative? » 2014-09-29 09:05:20

Just to refresh - what is the problem with Dropbox? The fact that it's not open source? Small space allowance? (It's been working very well for me the last 2~3 years.)

#24 Re: Tips, Tricks & Scripts » Shoutcast and Radionomy tuner for mplayer, mpg123 or radiotray » 2014-09-23 13:32:54

Shoutcast changed their web interface a while ago, breaking that part of the script. This is now fixed, and a bonus is that you now get more results. There's also a --help option. Otherwise usage is the same as post #12 : (edit 141003 Version 3.1 to handle new Radionomy interface.)

#!/bin/bash
# shoutcast_radionomy_search.sh
# search shoutcast and radionomy,
# send url to radiotray, mpg123, mplayer or another player
# send url to streamripper to record
#
# version 3.1
#
# needs curl, [radiotray, dbus | mpg123 | mplayer], streamripper, [xsel], [perl]
# xsel enables pasting from the X selection (to a config file etc.)
# Comment out line 288 "printf '%s'..." if you don't use it.
# perl is used to urlencode the query.
# Comment out line 246 and uncomment line 245 to escape spaces only
# if your system doesn't have perl.
#
# KEYBOARD SHORTCUTS:
# Ctrl+C to exit normally
# Ctrl+\ to terminate and close player
# Ctrl+Z to start recording current station (handles SIGTSTP)

##### choose from radiotray, mpg123 or mplayer #####
player=radiotray
#player=mpg123
#player=mplayer

# Set this to something other than 'true'
# to have audio player exit with script.
# Otherwise player will continue till closed separately.
# Even with 'keep_player=true', if script is stopped with Ctrl+\
# then player will exit too.
keep_player=true

##### code to record a radio stream (url is $1) in a new terminal #####
# Add your own options to streamripper's command line,
# edit ~/.config/streamripper/streamripper.ini,
# change urxvt to another terminal
# or use a different command altogether.
recorder() {
    ( setsid urxvt -e streamripper "$1" >/dev/null 2>&1 & )
}

# where to put player control fifo
# (radiotray doesn't use this)
rpipe=/tmp/radio_pipe

HELP="This is an interactive script to query the Shoutcast and Radionomy listings,
put the results in a menu,
and load the chosen radio station in radiotray, mpg123 or mplayer.
There is also an option to record with streamripper.

If you exit the script and leave mpg123 or mplayer running,
you can close either of them with the command:
echo quit >$rpipe

KEYBOARD SHORTCUTS:
Ctrl+C to exit normally
Ctrl+\ to terminate and close player
Ctrl+Z to start recording current station (handles SIGTSTP)"

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

case $1 in
--help|-h)
    echo "$HELP"
    exit
    ;;
esac

case $player in

##### RADIOTRAY SETTINGS #####
radiotray)
required_commands='curl streamripper radiotray'
start_player() {
    if pgrep radiotray >/dev/null
    then
        echo "$player is already running"
    else
        ( setsid radiotray >/dev/null 2>&1 & )
    fi
}
radioplay() {
    radiotray "$1"
}
cleanup() { # run just before exit
    [[ $player_ok = true ]] && [[ $keep_player = true ]] && {
        echo "$player will continue to play.
You can control it from the system tray icon
or run the script again to choose another station."
        sleep 4
        return
    }
    pkill radiotray && echo "Closed radiotray."
    sleep 4
}
;;
##### END RADIOTRAY #####

##### MPLAYER SETTINGS #####
mplayer)
required_commands='curl streamripper mplayer'
player_regex="^mplayer .*-input file=$rpipe"
launch_player() {
    [[ -p $rpipe ]] || { mkfifo "$rpipe" || error_exit "cannot make fifo $rpipe"; }
    ( setsid sh -c "mplayer -really-quiet -idle -slave -input file=$rpipe; rm -f $rpipe;" >/dev/null 2>&1 & )
    sleep 4 & launching_player=$!
}
load_url() {
    echo "loadlist $1" >"$rpipe"
}
;;&
##### END MPLAYER #####

##### MPG123 SETTINGS #####
mpg123)
required_commands='curl streamripper mpg123'
player_regex="^mpg123 .*--fifo $rpipe"
launch_player() { # mpg123 will make fifo if necessary
    ( setsid sh -c "mpg123 --remote --fifo $rpipe; rm -f $rpipe;" >/dev/null 2>&1 & )
    (sleep 2; echo 'silence' >"$rpipe") & launching_player=$!
}
load_url() {
    echo "loadlist 1 $1" >"$rpipe"
}
;;&
##### END MPG123 #####

##### COMMON TO MPLAYER AND MPG123 #####
mplayer|mpg123)
start_player() {
    if pgrep -f "$player_regex" >/dev/null
    then
        echo "$player is already running"
        [[ -p $rpipe ]] || error_exit "fifo missing $rpipe"
        (:>"$rpipe") & test_pipe=$!
        (sleep 2; kill $test_pipe 2>/dev/null && kill -s SIGPIPE $selfpid) &
    else
        launch_player
    fi
}
radioplay() {
    wait $launching_player
    [[ -p $rpipe ]] || error_exit "fifo missing $rpipe"
    pgrep -f "$player_regex" >/dev/null || error_exit "$player not running"
    load_url "$1"
}
cleanup() { # run just before exit
    [[ -p $rpipe ]] || { player_ok=false; echo "Script error: fifo $rpipe does not exist." >&2 ;}
    pgrep -f "$player_regex" >/dev/null || { player_ok=false; echo "Script error: $player not running" >&2 ;}
    [[ $player_ok = true ]] && {
        [[ $keep_player = true ]] && {
            echo "$player will continue to play.
You can stop it with the command:
echo quit >$rpipe
or run the script again to choose another station."
            sleep 4
            return
        }
        echo "closing $player..."
        echo 'quit' >"$rpipe" # try to close player nicely
        sleep 2 # time for player to quit
    }
    pkill -f "$player_regex" && echo "$player close forced."
    echo "removing $rpipe"
    rm -f "$rpipe" # in case it has become a normal file
}
;;
##### END COMMON TO MPLAYER AND MPG123 #####

*)
echo "$0: chosen player $player has not been configured.
Please check line 17 of the script" >&2
exit 1
;;
esac

##########################################################################
selfpid=$$
player_ok=true
error_exit() {
    echo "Script error: $1" >&2
    player_ok=false
    exit 1
}
trap 'cleanup' EXIT
trap 'echo " Exit script
Goodbye..."; exit' SIGHUP SIGINT
trap 'echo " Exit script
($player will be shut down)
Goodbye..."; keep_player=false; exit' SIGQUIT
trap 'error_exit "script terminated"' SIGTERM
trap 'error_exit "broken pipe"' SIGPIPE
trap 'recorder "${playing_url%.m3u}"' SIGTSTP

missing_commands=
for i in $required_commands
do
    hash $i || missing_commands+=" $i"
done
[[ $missing_commands ]] && error_exit "This script requires the following commands: $missing_commands
Please install the packages containing the missing commands
and rerun the script."

query_shoutcast() {
    curl -s --data "query=$1" "http://www.shoutcast.com/Search/UpdateSearch" | awk '
    BEGIN {
        RS="},{"
    }
    {
        url = name = $0
        if($0=="[]") {exit}
        sub(/^.*\"ID\":/,"",url)
        sub(/,.*$/,"",url)
        url = "http://yp.shoutcast.com/sbin/tunein-station.pls?id=" url
        sub(/^.*\"Name\":\"/,"",name)
        sub(/\".*$/,"",name)
        print url,name
    }
    '
}
query_radionomy() {
    curl -sL "http://www.radionomy.com/en/search?q=$1" |awk '
    BEGIN {
        RS="<h2 class=\"radio-title-list\"><a href=\"/en/radio/"
        FS="</a></h2>"
    }
    NR < 2 {next}
    {
        url = name = $1
        sub(/^.*>/,"",name)
        sub(/\/index\".*$/,"",url)
        url="http://listen.radionomy.com/" url ".m3u"
        print url,name
    }
    '
}

start_player

unset playing_name playing_url
while true
do
echo "Please enter keyword(s)"
read keyword
#keyword_esc="${keyword// /%20}" # escape spaces for url
keyword_esc=$(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$keyword")
results_sh=$( query_shoutcast "$keyword_esc" )
results_ra=$( query_radionomy "$keyword_esc" )

if [[ $results_sh ]] && [[ $results_ra ]]
then
    results="$results_sh"$'\n'"$results_ra"
elif [[ $results_sh ]]
then
    echo "No results for $keyword on radionomy"
    results="$results_sh"
elif [[ $results_ra ]]
then
    echo "No results for $keyword on shoutcast"
    results="$results_ra"
else
    echo "Sorry, no results for $keyword"
    continue
fi

unset list
declare -A list # make associative array
while read -r url name # read in awk's output
do
    list["$name"]="$url"
done <<< "$results"

PS3='Please enter the number of your choice > '
while true
do
    menu=("${!list[@]}")
    [[ $playing_name && $playing_url ]] && menu+=("RECORD \"$playing_name\"")
    select station in "${menu[@]}" 'SEARCH AGAIN' QUIT
    do
        [[ $station = "RECORD \"$playing_name\"" ]] && {
            recorder "${playing_url%.m3u}" # streamripper won't take m3u urls
            break
        }
        [[ $station = 'SEARCH AGAIN' ]] && break 2
        [[ $station = QUIT ]] && { echo 'Goodbye...'; exit; }
        [[ $station ]] && {
# comment out next line if you don't use xsel
            printf '%s' "${list[$station]}" | xsel --input #--clipboard  # can paste url
            radioplay "${list[$station]}"
            playing_name=$station
            playing_url=${list[$station]}
            break
        }
    done
echo "
Station last chosen was \"$playing_name\" ( $playing_url )
"
done # closes loop started at line 274

done # closes loop started at line 241

exit

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