aboutsummaryrefslogtreecommitdiffstats
path: root/sbin/kdeDesktopCleanup
blob: e92ea2c591e18387f72f824c6589561760db6baa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/perl
# (c) MandrakeSoft,  Pixel <pixel@mandrakesoft.com>
# 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 (<F>) {
	  $_ = "Exec=linuxconf" if $f =~ /linuxconf/i; # hack

	  ($l) = /^Exec=(?:kdesu\s+-c\s+)?"?(\S+)/ or next;
	  -x "$_/$l" and last L foreach '', @path;
	  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;
}