diff options
author | Frederic Lepied <flepied@mandriva.com> | 2004-02-27 16:56:31 +0000 |
---|---|---|
committer | Frederic Lepied <flepied@mandriva.com> | 2004-02-27 16:56:31 +0000 |
commit | eb0e92f8dd6195914d14902530a9b6d7edaa5a9f (patch) | |
tree | 0e656fb0331cc3b23720bcf9c171d9cabd10af60 /sbin/chksession | |
parent | fcfc43154c79bfa8d7d95c65b7a0405bcbb1f772 (diff) | |
download | common-data-eb0e92f8dd6195914d14902530a9b6d7edaa5a9f.tar common-data-eb0e92f8dd6195914d14902530a9b6d7edaa5a9f.tar.gz common-data-eb0e92f8dd6195914d14902530a9b6d7edaa5a9f.tar.bz2 common-data-eb0e92f8dd6195914d14902530a9b6d7edaa5a9f.tar.xz common-data-eb0e92f8dd6195914d14902530a9b6d7edaa5a9f.zip |
fix KDE sessions
Diffstat (limited to 'sbin/chksession')
-rw-r--r-- | sbin/chksession | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/sbin/chksession b/sbin/chksession index cb8603c..d0ac569 100644 --- a/sbin/chksession +++ b/sbin/chksession @@ -37,16 +37,47 @@ sub cat { # returns content of argument file as a single string } sub parse_file { # parse a session descriptor file - $_ = cat (shift @_); + my ($fn) = @_; + $_ = cat ($fn); ($n = $1) =~ s| ||g if /^NAME=(.*)/m; $e = $1 if /^EXEC=(.*)/m; # $d = $1 if /^DESC=(.*)/m; # $i = $1 if /^ICON=(.*)/m; $s = $1 while /SCRIPT:(.*?)$/gs; chomp $s; - if (-x $e) { $script{$n} = $s; push @lf, $n; } + if (-x $e) { $script{$n} = $s; $exe{$n} = $e; push @lf, $n; ($order{$n}) = $fn =~ m/(^[0-9][0-9])/; } # if (-x $e) { $script{$n} = $s; $exec{$n} = $e; $desc{$n} = $d; $icon{$n} = $i; push @lf, $n; } } +sub gen_desktops { + my ($d) = @_; + -d $d or system("mkdir -p $d"); + chdir $d; + + for my $file (@lf) { + open FH, ">$d/$order{$file}$file.desktop" or die "Can't write to $d/$order{$file}.desktop\n"; + print FH "[Desktop Entry]\n"; + print FH "Encoding=UTF-8\n"; + print FH "Name=$file\n"; + print FH "Comment=$file\n"; + print FH "TryExec=$exe{$file}\n" if $exe{$file}; + print FH "Exec=/etc/X11/xdm/Xsession $file\n"; + print FH "Icon=\n"; + print FH "Type=Application\n"; + close FH; + chmod 0755, $file; + } + open FH, ">$d/Default.desktop" or die "Can't write to $d/Default.desktop\n"; + print FH "[Desktop Entry]\n"; + print FH "Encoding=UTF-8\n"; + print FH "Name=Default\n"; + print FH "Comment=Default\n"; + print FH "Exec=/etc/X11/xdm/Xsession\n"; + print FH "Icon=\n"; + print FH "Type=Application\n"; + close FH; + chmod 0755, $file; +} + usage(1) if @ARGV < 1; @@ -84,7 +115,7 @@ for (<*>) { parse_file ("$_"); } -my ($e) = eval {cat("/etc/sysconfig/desktop")} =~ /(\S+)/; +my ($e) = eval {cat("/etc/sysconfig/desktop")} =~ /DESKTOP=(\S+)/; # The first string (without spaces) in the file is copied to $e. # If $e is one of the names in @lf, then it is placed first (leftmost). @@ -93,41 +124,11 @@ my ($e) = eval {cat("/etc/sysconfig/desktop")} =~ /(\S+)/; if ($kdm) { - $session="SessionTypes="; - for(@lf) { $session .= /$lf[-1]$/ ? "$_,failsafe,default" : "$_," } - print "$session\n"; - exit(0); + gen_desktops '/usr/share/apps/kdm/sessions'; } if ($gdm) { - my $d = '/etc/X11/dm/Sessions/'; - -d $d or system("mkdir -p $d"); - chdir $d; - - for my $file (@lf) { - open FH, ">/etc/X11/dm/Sessions/$file.desktop" or die "Can't write to /etc/X11/dm/Sessions/$file.desktop\n"; - print FH "[Desktop Entry]\n"; - print FH "Encoding=UTF-8\n"; - print FH "Name=$file\n"; - print FH "Comment=$file\n"; - print FH "Exec=/etc/X11/xdm/Xsession $file\n"; - print FH "Icon=\n"; - print FH "Type=Application\n"; - close FH; - chmod 0755, $file; - } - open FH, ">/etc/X11/dm/Sessions/Default.desktop" or die "Can't write to /etc/X11/dm/Sessions/Default.desktop\n"; - print FH "[Desktop Entry]\n"; - print FH "Encoding=UTF-8\n"; - print FH "Name=Default\n"; - print FH "Comment=Default\n"; - print FH "Exec=/etc/X11/xdm/Xsession\n"; - print FH "Icon=\n"; - print FH "Type=Application\n"; - close FH; - chmod 0755, $file; - - + gen_desktops '/etc/X11/dm/Sessions'; } if ($xsession) { |