Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

rmshit: delete files that EXIST upon execution. Added POD

  • Loading branch information...
commit 3ea00455c0576387a4f89736fd71c84192dd845b 1 parent 91fa5b4
@trapd00r authored
Showing with 85 additions and 9 deletions.
  1. +77 −8 rmshit
  2. +8 −1 rmshit.conf
View
85 rmshit
@@ -1,5 +1,56 @@
#!/usr/bin/perl
-our $VERSION = 0.3;
+=pod
+
+=head1 NAME
+
+ rmshit - keep a directory structure clean at all times
+
+=head1 SYNOPSIS
+
+ rmshit [OPTION]
+
+=head1 DESCRIPTION
+
+B<rmshit> was born out of plain rage and frustation, seeing that nobody seems to
+care about the XDG specifications, and dumping configuration files, temporary
+data and logs straight into $HOME.
+
+Even if you manually delete these files, they will be recreated when the
+Application of Sin wants to (when it's executed, seeing default data is missing,
+for example).
+
+The most well known application that does this, as of this writing, is Mozilla
+Firefox, creating $HOME/Desktop, over and over again.
+
+rmshit uses inotify to keep an eye on a directory structure, instantly removing
+data upon it's creation.
+
+=head1 OPTIONS
+
+ -k, --kill kill a running rmshit process
+ -h, --help this help
+ -m, --man manpage
+
+=head1 ENVIRONMENT
+
+rmshit watches the directories you specify in the configuration file. It should
+be placed in $XDG_CONFIG_HOME/rmshit/rmshit.conf or
+$HOME/.config/rmshit/rmshit.conf.
+
+=head1 REPORTING BUGS
+
+Report bugs to trapd00r@trapd00r.se
+
+rmshit homepage: http://github.com/trapd00r/rmshit
+
+=head1 COPYRIGHT
+
+Copyright 2010 Magnus Woldrich. License GPLv2: GNU GPL version 2 or later
+
+=cut
+
+
+our $VERSION = 0.5;
=rmshit
rmshit
instantly deletes the cocksucking good for nothing motherfucking piece of
@@ -66,6 +117,28 @@ else {
}
our ($watchdir,%shittyfiles); # imported from the config file
+my @date = localtime();
+my $nicetime = sprintf("%d-%02d-%02d %02d:%02d:%02d",
+ $date[5]+1900, $date[4], $date[3], $date[2], $date[1], $date[0]);
+
+for my $dir(keys(%shittyfiles)) {
+ for my $file(@{$shittyfiles{$dir}}) {
+ if(-d "$dir/$file") {
+ if(remove_tree("$dir/$file")) {
+ open(my $fh, '>>', $log);
+ print $fh "[PD] $nicetime: ", "$dir/$file\n";
+ close($fh);
+ }
+ }
+ if(-f "$dir/$file") {
+ if(unlink("$dir/$file")) {
+ open(my $fh, '>>', $log);
+ print $fh "[PF] $nicetime: ", "$dir/$file\n";
+ close($fh);
+ }
+ }
+ }
+}
$inotify->watch($watchdir, IN_CREATE) or die;
@@ -75,7 +148,6 @@ sub daemonize {
$daemon->do_action;
}
-print "Bye. If you're wondering what I'm doing, check $log\n";
daemonize();
while () {
@@ -89,14 +161,10 @@ while () {
if($shitfile eq $event->name) { # remove the stupid piece of shit
open(my $fh, '>>', $log); # I'll let it freak out for now
- my @date = localtime();
- my $nicetime = sprintf("%d-%02d-%02d %02d:%02d:%02d", $date[5]+1900,
- $date[4], $date[3], $date[2], $date[1], $date[0]);
-
if(-d $event->fullname) {
if(remove_tree($event->fullname)) {
- print $fh " [DIR] $nicetime: ",$event->fullname,"\n";
+ print $fh "[CD] $nicetime: ",$event->fullname,"\n";
}
else {
print $fh "[ERROR] $nicetime: ", $event->fullname,"\n";
@@ -104,7 +172,7 @@ while () {
}
else {
if(unlink($event->fullname)) {
- print $fh " [FILE] $nicetime: ", $event->fullname,"\n";
+ print $fh " [CF] $nicetime: ", $event->fullname,"\n";
}
else {
print $fh "[ERROR] $nicetime: ",$event->fullname,"\n";
@@ -116,3 +184,4 @@ while () {
}
}
+
View
9 rmshit.conf
@@ -19,6 +19,7 @@ our %shittyfiles = (
],
# Authors choice
# "$ENV{HOME}" => ['.adobe',
+# '.cache',
# '.esd_auth',
# '.macromedia',
# '.dbus',
@@ -36,9 +37,15 @@ our %shittyfiles = (
# '.fontconfig',
# 'Desktop',
# '.local/share/gegl-0.1',
+# '.thumbnails',
+# 'Downloads',
+# '.gimp-2.6',
+# '.apvlvinfo',
+# '.pki',
+
# ],
- # Example.
+# Example.
# "/var/log" => ['mail.log.1',
# 'syslog.log.1',
# 'uucp.log.1',
Please sign in to comment.
Something went wrong with that request. Please try again.