#!/usr/bin/perl # (c) Mandriva, Pixel # Copyright under GPL @dirs = (qw(/etc/skel /root), glob("/home/*")); @path = split ":", "/sbin:/usr/sbin:/usr/X11R6/bin:/bin:/usr/bin"; foreach $f (map { grep { /\.kdelnk$/ } eval { all("$_/Desktop") } } @dirs) { open F, $f or next; L: foreach () { if (/^Exec=(?:kdesu\s+-c\s+)?"?(\S+)/) { -x "$_/$1" and last L foreach '', @path; } elsif (m|^URL=file:(/.*)|) { -e $1 and last; } else { next } print STDERR "removing $f\n"; unlink $f; last; } } sub all { my $d = shift; local *F; opendir F, $d or die "all: can't open dir $d: $!\n"; my @l = grep { $_ ne '.' && $_ ne '..' } readdir F; closedir F; map { "$d/$_" } @l; }