Re: Post your handy self made command line utilities

karol wrote:

AaronBP wrote:

Get info from whatever package owns a file:

#!/bin/sh
package=$(pacman -Qqo "$1")
pacman -Qi $package

Why not

pacman -Qi $(pacman -Qqo $@)

No particular reason other than readability. I used $1 because listing -Qi output for multiple files at once didn't seem particularly useful, and the command already takes about 5 seconds on this crap machine.

karol wrote:

or use expac if you want e.g. just the name & description:

$ expac "%n: %d" -Q $(pacman -Qqo date time)
coreutils: The basic file, shell and text manipulation utilities of the GNU operating system
time: Utility for monitoring a program's use of system resources

That's interesting; I like that. I'd never heard of expac. I'll try it out.

Re: Post your handy self made command line utilities

Re: Post your handy self made command line utilities

I've still got a few functions in my ~/.bashrc, but I've gotten into the habit of putting everything in ~/bin. There are a couple advantages:

The only thing that uses ~/.bashrc is bash. Things that are only used in an interactive shell anyway, like pacinfo above, could go in ~/.bashrc anyway, but other scripts I might otherwise run in a launcher, and also it would be a pain to have to move everything over if I got a bug and suddenly decided to switch to, say, zsh.

It could potentially get difficult to keep up with ~/.bashrc very quickly. I can see all my scripts and get an idea of what they do from their name by typing ls ~/bin. It's self-documenting and easier to maintain.

Re: Post your handy self made command line utilities

May have posted this before. May post it again. Very much a work in progress.

Basically made to make my life easier when compiling packages over ssh on my phone (via connectbot), then became a feature of my everyday life. Unless you use abs/aur on a regular basis, and have devtools installed, it probably won't be of any use to you.

Re: Post your handy self made command line utilities

imgupload is a bit like my earlier in the thread imgreview application. It uses feh and its actions to cycle through a set of images and queue them for ftp upload.It is mainly designed to be wrapped for different sites (eg I have a devupload wrapper for deviantart).

It uses ncftp and their login file for sites. This is not ideal and once I've finally sorted out my passwords system, I'll hopefully add a hook in for that. Up 'til then I use a 600 permission file in the format the ncftp recognises.

It uses a separate script to remove the queued images which is listed afterwards.

I only finished it yesterday and have only used it twice, so there could be undiscovered issues in with it.

#!/bin/bash
#
# imgupload
#
# Enable to go through a folder of images and allow select
# for upload to a passed in ftp site.
#
# $1 - ftp address to upload any selected images to.
#
# Depends on feh, ncftp
#
#
# TODO
# *) pass in a gpg file to get the username etc.
THIS=$(basename $0)
TRGDIR=.
SRC=.
UPLOAD=on
# Usage function
usage () { echo "Usage: $THIS [-h] [-s source_dir] [-u off/on] user_login_file" ; }
# Dislays help information
help () {
cat << ENDHELP
$THIS: Uses feh(1) to sort through a list of images in the current directory.
Using feh's ACTIONS the user can upload the displayed image to
the supplied ftp site. The image will be queued for uploading. Once
The user has escaped from feh(1), the uploading will start and be
carried out by ncftp.
The site and logon details are specied in a file. The details of this
file's format can be found at ncftpput(1). The name of the file must
be passed in as the first parameter.
When an image is displayed, pressing <ENTER> will select the file for
upload.
Normal feh commands are all usable.
<ESCAPE> is used to exit feh, and the script will then start the upload
process.
To view running or spooled upload jobs, use:
$ ncftpbatch -l
Options:
-s directory changes the source directory for the images.
-h display this help and exit
-u off/on whether or not to start the upload immediately.
Default: on
ENDHELP
}
# getopts
while getopts "s:hu:" opt; do
case $opt in
s ) SRC="$OPTARG" ;;
h ) help
exit 0 ;;
u ) UPLOAD="$OPTARG" ;;
\? ) usage
exit 1
esac
done
shift $(($OPTIND -1))
# Check we have an upload site:
if [ -z "$@" ]; then
usage
exit 1
else
USER="$1"
fi
# Build action command
ACTION="--draw-actions --action 'ncftpput -f $USER -bb $TRGDIR %f'"
ACTION="$ACTION --action1 'unqimgupload %n'"
# feh command
eval feh -dF $ACTION "${SRC}"/*.{jpg,JPG,png,PNG,gif,GIF}
# Uploader organiser, keeps things polite
if [ "$UPLOAD" = on ]; then
ncftpbatch -d
fi
ncftpbatch -l
# vim:set sts=4 ts=4 sw=4 ft=sh et:

Re: Post your handy self made command line utilities

Record part of your desktop using ffmpeg.Depends on xorg-xwininfo.What needs to be done: record application sounds using alsa.If you want to record microphone on a seperate file you have to first use "--file name" and then "--mic-sep" so that video/audio have the same name.

Re: Post your handy self made command line utilities

Re: Post your handy self made command line utilities

My internet radio script. Has some coloring and you can change station by pressing q to exit mplayer and choose another station.If no response is given atthe prompt in 5secs, it exits.Also pressing 'c' while playing a station starts capturing the stream in pwd as stationname_time_date.mp3