<commit_before># my-scripts
Feel free to help yourself to anything you like here. Mail me if you have any
queries - my email address is on my profile page.

Please note that I have not tested any of these scripts outside of Arch Linux -
indeed, some of these scripts will work only in Arch Linux (though those should
just be the ones that use pacman).

If anyone has any suggestions for improvements (or even pull requests!) then
they will be gratefully recieved. What follows is a short description of each
script and a note on any dependencies it has.

* **aur-cache.py** - I'm not a fan of AUR helpers like yaourt - I prefer to
download the tarballs and install them manually. But what to do about the 
compiled package, the build directory and the AUR tarball? This script 
automates that cleanup. Say you downloaded foo.tar.gz from the AUR to 
~/Downloads and built foo-1.0-1.pkg.tar.xz. This script will copy the 
.pkg.tar.xz file to a cache directory (I use ~/.aurcache but that's completely 
arbitrary). It will then delete the ~/Downloads/foo directory and 
~/Downloads/foo.tar.gz. And it will do that for any build directory it finds in
~/Downloads. The ~/Downloads and ~/.aurcache directories are written into the 
program but you can supply different directories as arguments or you can just 
edit the script. - Depends: python
* **aur-ccache.py** - This clears out any packages in your AUR cache directory -
mine is ~/.aurcache - other than the ones currently installed. A bit like
running pacman -Sc basically. Depends: python, pacman
* **aurcheck.py** - This will check the AUR for any updates to your packages. 
If you have wget installed it will also offer to download the updated tarballs.
This doesn't use any APIs for interacting with the AUR - just web scraping. 
This is probably the script I use most. It works well for me though I'm not 
sure how fast it would be if you had a lot of AUR packages installed - I have 
only a few. - Depends: python, python-requests, python-beautifulsoup4, pacman,
wget (optional)
* **bin2text.py** - A silly little script that I wrote just for fun really. 
Does what it says on the tin. - Depends: python
* **display-conf-tool.py** - This is a general pupose Tk gui frontend to
xrandr. It can enable/disable displays, configure display resolutions, display
mirroring and display positioning. It started out as a reimplementation of
display-selector.sh in Tk because zenity is slow and working fast is more
important to me than looking good! But later I re-wrote it to make it work in
all contexts (i.e. no hardcoded display names) and to add more features. - 
Depends: python, tk, xorg-xrandr
* **display-selector.sh** - A zenity dialogue for calling xrandr. This allows me
to switch between my laptop screen and the HDMI port. Note that the display
names are hardcoded and the functionality is very limited. This can only
enable or disable displays. You should use display-conf-tool.py instead
which is faster, detects displays instead of relying on hardcoded names
and has many more xrandr settings exposed. - Depends: bash, zenity, xorg-xrandr
* **end-session.py** - A python Tk dialogue that can call systemctl 
{reboot,poweroff,suspend...}. Not particularly useful to me now. I can't 
remember why I wrote this one. - Depends: python, tk, systemd
* **fat_copy.sh** - This is quite useful actually. It can copy directories and 
files, replacing any characters in filenames or directory names
that are illegal for the FAT filesystem with underscores. It should be noted 
that this doesn't actually 'copy' directories strictly speaking. 
It only copies files - directories are created in the new location using mkdir.
There was some good reason for that though I can't remember what it was right 
now ;) - Depends: bash, coreutils
* **fvwm-recent-files.py** - This script parses the recently-used.xbel file
which is written to by GTK+ applications, determines the 10 most
recently used files, which applications are the correct ones for opening
those files and then outputs the results in FVWM menu format, essentially
giving you a dynamic 'recently used' menu similar to the one found in MATE's
Places menu. Whilst the output is in FVWM format, one could easily add
support for other WM formats. I just don't have any reason to do that at the
moment. - Depends: python, python-urllib3
* **gnome-screensaver-idlelock.sh** - I wrote this one when I was still using
GNOME Screensaver 3.6 with Xfce. And I was doing that because XScreenSaver's
DPMS timeouts conflict with xfce-power-manager's timeouts. It uses xprintidle
to get the idle time and then locks the screen when the timeout is reached
as long as Xfce's presentation mode is not engaged. Xautolock does this sort of
thing much better though so just use that. Personally, I don't use this or 
xautolock. Instead, I ditched the pointless power manager and just went back to
the excellent XScreenSaver. - Depends: bash, xprintidle, gnome-screensaver, 
xfconf
* **mcityconf.py** - This is another python Tk program. It can read and write to
a few of Metacity's DConf keys - namely, the ones controlling themes and fonts.
This was written back when I was still using Compiz 0.9 with Xfce - the
gtk-window-decorator reads from Metacity's settings so I was actually using it
to change the Compiz theme. I no longer use this (or Compiz for that matter)
but I think it still works fine. - Depends: python, tk, metacity, glib2
(for gsettings)
* **mp3-range.sh** - This is one of two scripts I wrote that analyse an mp3 
collection by date. Basically, you supply two arbitrary dates - 1980 and
1989 for instance - and it will tell you how many tracks you have that have a
date tag in that range. - Depends: bash, id3lib (for id3info)
* **mp3-renamer.py** - This is one of my genuinely useful scripts. Supply it 
with a directory of mp3 files and it will scan their tags and rename them all
according to a standard format: "Track number" "Track name.mp3". It's recursive<commit_msg>Amend readme entry for fat_copy.sh, providing an explanation as to why directories are recreated instead of copied<commit_after># my-scripts
Feel free to help yourself to anything you like here. Mail me if you have any
queries - my email address is on my profile page.

Please note that I have not tested any of these scripts outside of Arch Linux -
indeed, some of these scripts will work only in Arch Linux (though those should
just be the ones that use pacman).

If anyone has any suggestions for improvements (or even pull requests!) then
they will be gratefully recieved. What follows is a short description of each
script and a note on any dependencies it has.

* **aur-cache.py** - I'm not a fan of AUR helpers like yaourt - I prefer to
download the tarballs and install them manually. But what to do about the 
compiled package, the build directory and the AUR tarball? This script 
automates that cleanup. Say you downloaded foo.tar.gz from the AUR to 
~/Downloads and built foo-1.0-1.pkg.tar.xz. This script will copy the 
.pkg.tar.xz file to a cache directory (I use ~/.aurcache but that's completely 
arbitrary). It will then delete the ~/Downloads/foo directory and 
~/Downloads/foo.tar.gz. And it will do that for any build directory it finds in
~/Downloads. The ~/Downloads and ~/.aurcache directories are written into the 
program but you can supply different directories as arguments or you can just 
edit the script. - Depends: python
* **aur-ccache.py** - This clears out any packages in your AUR cache directory -
mine is ~/.aurcache - other than the ones currently installed. A bit like
running pacman -Sc basically. Depends: python, pacman
* **aurcheck.py** - This will check the AUR for any updates to your packages. 
If you have wget installed it will also offer to download the updated tarballs.
This doesn't use any APIs for interacting with the AUR - just web scraping. 
This is probably the script I use most. It works well for me though I'm not 
sure how fast it would be if you had a lot of AUR packages installed - I have 
only a few. - Depends: python, python-requests, python-beautifulsoup4, pacman,
wget (optional)
* **bin2text.py** - A silly little script that I wrote just for fun really. 
Does what it says on the tin. - Depends: python
* **display-conf-tool.py** - This is a general pupose Tk gui frontend to
xrandr. It can enable/disable displays, configure display resolutions, display
mirroring and display positioning. It started out as a reimplementation of
display-selector.sh in Tk because zenity is slow and working fast is more
important to me than looking good! But later I re-wrote it to make it work in
all contexts (i.e. no hardcoded display names) and to add more features. - 
Depends: python, tk, xorg-xrandr
* **display-selector.sh** - A zenity dialogue for calling xrandr. This allows me
to switch between my laptop screen and the HDMI port. Note that the display
names are hardcoded and the functionality is very limited. This can only
enable or disable displays. You should use display-conf-tool.py instead
which is faster, detects displays instead of relying on hardcoded names
and has many more xrandr settings exposed. - Depends: bash, zenity, xorg-xrandr
* **end-session.py** - A python Tk dialogue that can call systemctl 
{reboot,poweroff,suspend...}. Not particularly useful to me now. I can't 
remember why I wrote this one. - Depends: python, tk, systemd
* **fat_copy.sh** - This is quite useful actually. It can copy directories and 
files, replacing any characters in filenames or directory names
that are illegal for the FAT filesystem with underscores. It should be noted 
that this doesn't actually 'copy' directories strictly speaking. 
It only copies files - directories are created in the new location using mkdir.
This is because copying directories can only be done recursively which means
the entire directory tree would be copied over to the FAT filesystem without
the necessary changes to the names of any of the files or subdirectories in
the tree. - Depends: bash, coreutils
* **fvwm-recent-files.py** - This script parses the recently-used.xbel file
which is written to by GTK+ applications, determines the 10 most
recently used files, which applications are the correct ones for opening
those files and then outputs the results in FVWM menu format, essentially
giving you a dynamic 'recently used' menu similar to the one found in MATE's
Places menu. Whilst the output is in FVWM format, one could easily add
support for other WM formats. I just don't have any reason to do that at the
moment. - Depends: python, python-urllib3
* **gnome-screensaver-idlelock.sh** - I wrote this one when I was still using
GNOME Screensaver 3.6 with Xfce. And I was doing that because XScreenSaver's
DPMS timeouts conflict with xfce-power-manager's timeouts. It uses xprintidle
to get the idle time and then locks the screen when the timeout is reached
as long as Xfce's presentation mode is not engaged. Xautolock does this sort of
thing much better though so just use that. Personally, I don't use this or 
xautolock. Instead, I ditched the pointless power manager and just went back to
the excellent XScreenSaver. - Depends: bash, xprintidle, gnome-screensaver, 
xfconf
* **mcityconf.py** - This is another python Tk program. It can read and write to
a few of Metacity's DConf keys - namely, the ones controlling themes and fonts.
This was written back when I was still using Compiz 0.9 with Xfce - the
gtk-window-decorator reads from Metacity's settings so I was actually using it
to change the Compiz theme. I no longer use this (or Compiz for that matter)
but I think it still works fine. - Depends: python, tk, metacity, glib2
(for gsettings)
* **mp3-range.sh** - This is one of two scripts I wrote that analyse an mp3 
collection by date. Basically, you supply two arbitrary dates - 1980 and
1989 for instance - and it will tell you how many tracks you have that have a
date tag in that range. - Depends: bash, id3lib (for id3info)
* **mp3-renamer.py** - This is one of my genuinely useful scripts. Supply it 
with a directory of mp3 files and it will scan their tags and rename them all
according to a standard format: "Track number" "Track name.mp3". It's recursive
{'fraction_non_alphanumeric': 0.056105340639568166, 'fraction_numerical': 0.0045800278073116875, 'mean_word_length': 4.061258278145695, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1105146', 'n_tokens_mistral': 3436, 'n_tokens_neox': 3262, 'n_words': 1924}