This repo contains a few sundry scripts potentially useful to the general GNU/Linux-using public. The scripts are categorized into directories as follows:
arch
- Arch Linux-specific scriptsdev
- generic software development-related scriptseesti
- scripts specific to Estonian servicesperl
- Perl-specific scriptsX
- scripts useful within a graphical user environment (X11)
The root directory contains miscellaneous other scripts, lib
currently only
contains backends for backup
, data
contains configuration files. The scripts
expect a full-featured modern Linux system as their environment; standard
requirements like perl
, awk
, wget
etc. are not listed for each script.
Many scripts can be run with no arguments, -h
or --help
for usage info. I'm
guilty of the mortal sin of using tabs (4) instad of spaces, so beware.
A multi-purpose script for backing up a directory tree into a tarball or via
duplicity. The script sources .backup.conf
from the current working directory for options. See .backup.conf.example
for a
template and explanations of options. The tar backend supports
- numbered backups (000, 001, ...)
- rotating a fixed maximum number of backups through
logrotate
- e-mailing the tarball through
mutt
- keeping a log file for backups in README
Requires:
- GNU
tar
(for the tar backed) duplicity
(for the duplicity backend)logrotate
(for rotating the backups)mutt
(for e-mailing the backups)
See backup
, lib/backup*
and .backup.conf.example
for details.
mp3tag {-t | -f} filename [filename ...]
Copy mp3 tags to the filename as ARTIST - TITLE.mp3
(-f
) or write the artist
and title tags to the mp3 file (-t
) based on the filename formatted as such. Requires
eyeD3.
Convert a video stream into high quality x264; by default 720p, CRF 20,
preset: slow.
Convenience frontend to ffmpeg
. Convert input to x264 video, based on a
hardcoded profile. Available profiles are currently 720high
and 480med
.
Usage example:
vid2x264 -i input.mp4 -p 720high output.mkv
Convert a Youtube video or playlist specified by a passed URL to mp3, use
mp3tag to write ID3 tags. Arguments are passed to youtube-dl.
Requires youtube-dl
and mp3tag
(see above) on $PATH
.
Check whether foreign packages have become available in binary
repositories
List explicitly-installed packages that are not part of a group
Output packages sorted by install date, one per line with the install
date prepended to the package name. All command line arguments are
passed on to pacman.
List foreign packages (e.g. from AUR) that are required by other
packages
A Perl script accepting a block of comments (lines starting with #
or //
;
also handles Python docstrings) on its standard input and piping a nicely
formatted result to its standard output. Use as an editor extension (Geany,
vim, ...). Requires
Text::Autoformat
and pipes the cleaned input through its main routine. As an extended feature,
supports formatting argument list documentation, i.e.
// Add a tool to the toolbar. Attributes:
//
// id - identifier string, required
// toggle - a boolean specifying whether the tool is a toggle button
// handlers - an object of [jQuery] event handlers, keyed by event. The handler will
// receive the tool spec object as event.data.
will be formatted as
// Add a tool to the toolbar. Attributes:
//
// id - identifier string, required
// toggle - a boolean specifying whether the tool is a toggle button
// handlers - an object of [jQuery] event handlers, keyed by event. The
// handler will receive the tool spec object as event.data.
This script attempts to solve the problem that we would like to have a) secure and b) convenient SSH authentication even in environments that are volatile, lack secure storage or are not entirely under our control. The specific case that inspired creation of this script was SSH access to git remotes from Docker containers on a shared server. Setting up SSH keys is beyond the scope of this document, but this is covered in detail elsewhere.
sshagconn
connects to a running
ssh-agent
or launches one if it is
not running and consigns the desired SSH private key under its management. The
private key should be encrypted with a passphrase and in this case, the
passphrase is requested only once between container or machine reboots. On
other terminals, the script may simply be run without any further involvement
from the user to set up environment variables pointing to the running
ssh-agent
instance. sshagconn
is meant to run just as ssh-agent
itself,
i.e. it outputs some instructions to be parsed by the shell. In Bash, this is
best achieved with process substitution:
$ source <(sshagconn /path/to/keyfile)
It is convenient to alias this to a easily remembered token:
$ alias github='source <(sshagconn /path/to/keyfile)'
$ alias > ~/.bash_aliases
$ echo 'source ~/.bash_aliases' >> ~/.bashrc
The final step is to link the key file to the host name in SSH configuration.
Add a similar block to ~/.ssh/config
for each host:
Host github
HostName github.com
IdentityFile /path/to/keyfile
In the future, you only need to invoke github
on each terminal that you wish
to use for pushing to remotes:
$ github
$ git push
A script to analyze a Swedbank CSV bank statement and group
expenditures by function, based on the groups defined in
`statementgroups`. Pass the statement and statement groups filenames as
the arguments.
What it says on the tin. Pass a CSV account statement from Swedbank and a
statement groups file (see data/statementgroups.example
, first column is the
group, second column is a pattern (full Perl regexp, really) to match against
the transaction comment or recipient). The output is a neat table of grouped
expenditures and incomes. Requires
Text::ASCIITable
and Text::CSV.
A script for watching or capturing Elion's multicast-based IPTV. Reads data/iptvrc
for channel
definitions. If the passed network interface is on IPTV_NET, attempt to open the multicast stream,
otherwise fall back to the web stream. For use with the new router firmware (>=8.C.D.9); see older
versions (<2016-05) for use with the separate IPTV subnet.
Requires:
iptvrc
format:
- 1st column - channel ID
- 2nd column - mcast stream URL
- 3rd column - fallback (web) stream URL
Usage:
iptv [-c output.mp4] [-a] [-i interface]
-i interface
- network interface to use-c filename
- dump stream tofilename
instead of opening in VLC-a
- use alternative (fallback) stream
Note: This script possibly requires one or more of the following to use: a) spoof a set-top
box's MAC address to the desired network interface, b) set up the multicast route (route add -net 224.0.0.0 netmask 240.0.0.0 dev interface_name
) c) force your system to use IGMPv2 d) add an
iptables
rule to accept multicast packets, if using the firewall. Please do not contact me about
troubleshooting your network configuration.
A script for downloading shows from Raadio 2. See r2get.py -h
for more or less comprehensive usage instructions, and the file header for
technical details.
Requirements:
Without arguments, print the current temperature from
meteo.physic.ut.ee If -R is given, print the record temperature days
this year. If -r is given, reverse the order (i.e. display the coldest
dates). If -i is given, invert minima and maxima (i.e. show warmest
daily minima with -R, coldest daily maxima with -Rr). -n determines the
number of dates to output. -y determines year, current year by default.
Utility for finding all Perl files under the current directory and
listing dependency modules. $* is passed to scandeps.pl. Pass -n to
list unavailable dependencies, in such case $* is ignored.
Requires scandeps.pl
Install Perl modules to a specific directory. Pass the prefix as the
first argument and any modules to install as subsequent arguments.
Check availability of a Perl module
Dump the contents of a Storable serialized in a file, file name passed
as the command line argument
Check if there are full-screen windows with title matching a pattern,
in which case disable power management. Useful for running as a
frequent cron job or from a periodic script.
Command-line control of Pidgin via D-Bus. Currently toggles available /
offline mode.
A remote control daemon leveraging the power of LIRC to turn your Android device into a remote for your machine using a client such as this one.
Usage:
-
Set up LIRC on your machine. You may use the generic remote definition, either way,
remoted.pl
expectsdevinput
as the remote's ID. -
Set up the client on your android device, download the
devinput
definition from your LIRC server and configure your remote. Note: make sure to use SIMULATE mode. -
Create an action mapping file, see
data/remotedrc
as an example. This either maps actions to a command to run (two fields) or invokes an internal function (three or more fields). In the latter form, the second field is the name of the function in angle brackets and the rest are its arguments. Two functions are available:<mpris>
- Control VLC via D-Bus / MPRIS. See the specification for details; methods for most expected actions (play, stop, seek, etc.) are available.<vlc_start>
- Start VLC and open the passed URI (3rd field). If VLC is already running, no new instance is spawned.
-
Run
remoted.pl
, passing the action mapping file as a parameter. You should be able to control VLC and invoke any other actions via your Android device now.
Command-line control of Spotify. Pass "play", "pause", "next", "prev"
or "previous" as the argument.
Resize a window (partially) matching the title.
Requires xdotool
, xwininfo
.