Mageia Bugzilla – Attachment 7451 Details for
Bug 17617
[mga6-dev1] autologin seems to need the files in /etc/X11/wmsession.d
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
[patch]
A patch to modify chksession behaviour
chksession.patch (text/plain), 5.23 KB, created by
Nicolas Salguero
on 2016-02-12 13:25:22 CET
(
hide
)
Description:
A patch to modify chksession behaviour
Filename:
MIME Type:
Creator:
Nicolas Salguero
Created:
2016-02-12 13:25:22 CET
Size:
5.23 KB
patch
obsolete
>diff --git a/sbin/chksession b/sbin/chksession >index 46a6071..3acbd05 100644 >--- a/sbin/chksession >+++ b/sbin/chksession >@@ -4,6 +4,7 @@ > ## For info, see "chksession --help" or "man chksession" > > # Modified by Bernard Lang on August 21, 2003. >+# Modified by ns80 on February 12, 2016. > > > my @lf; >@@ -20,15 +21,7 @@ Usage: $0 [OPTION]... > -L: List window-managers including the order number > > -d=DIR, --dir=DIR: Specifies a directory of w-m configuration files. >- Default is /etc/X11/wmsession.d/ >- >- -x=ENTRY, --xsession=ENTRY: Produce window-managers script of ENTRY. >- >- --generate=DIR: Produce window-manager .desktop files into DIR. >- --wrap-sessions: Wrap window-managers with /usr/share/X11/xdm/Xsession. >- >- -K, --kdm4: Shortcut for --generate=/usr/share/apps/kdm/sessions >- -g, --gdm: Shortcut for --generate=/etc/X11/dm/Sessions --wrap-sessions >+ Default is /usr/share/xsessions/ > > -h, --help: Produce this help. > >@@ -45,41 +38,32 @@ sub cat { # returns content of argument file as a single string > } > > sub parse_file { # parse a session descriptor file >- my ($fn) = @_; >+ my ($fn) = @_; > $_ = cat ($fn); >- ($n = $1) =~ s| ||g if /^NAME=(.*)/m; >- $e = $1 if /^EXEC=(.*)/m; >- my $dn = $1 if /^DESKTOPNAMES=(.*)/m; >-# $d = $1 if /^DESC=(.*)/m; >-# $i = $1 if /^ICON=(.*)/m; >- $s = $1 while /SCRIPT:(.*?)$/gs; chomp $s; >- if (-x $e) { $script{$n} = $s; $exe{$n} = $e; $desktopnames{$n} = $dn; 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, $usesession) = @_; >- -d $d or system("mkdir -p $d"); >- system("rm -f $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 "DesktopNames=$desktopnames{$file}\n" if $desktopnames{$file}; >- if ($usesession) { >- print FH "Exec=/usr/share/X11/xdm/Xsession $file\n"; >- } else { >- print FH "Exec=$file\n"; >- } >- print FH "Icon=\n"; >- print FH "Type=Application\n"; >- close FH; >- chmod 0755, $file; >- } >+ ($n = $1) =~ s| ||g if /^Name=(.*)/m; >+ $e = $1 if /^Exec=(.*)/m; >+ my $dn = $1 if /^Desktopnames=(.*)/m; >+ $s = $1 if /^Exec=(.*)/m; >+ $script{$n} = $s; >+ $exe{$n} = $e; >+ $desktopnames{$n} = $dn; >+ push @lf, $n; >+ if (lc $fn eq lc "icewm.desktop") { >+ ($order{$n}) = 99; >+ } elsif (opendir (DIR, $dir)) { >+ my $cpt = 1; >+ for my $xsessions_file (sort { "\L$a" cmp "\L$b" } readdir(DIR)) { >+ next if ($xsessions_file =~ m/^\./); >+ next if (lc $xsessions_file eq lc "icewm.desktop"); >+ if ($fn eq $xsessions_file) { >+ ($order{$n}) = sprintf ("%02d", $cpt); >+ last; >+ } else { >+ $cpt++; >+ } >+ } >+ closedir(DIR); >+ } > } > > usage(1) >@@ -87,23 +71,12 @@ usage(1) > > while ($ARGV[0] =~ /^--/ || $ARGV[0] =~ /^-/) { > $_ = shift; >- if (/^--xsession=([^ ]+)/ || /^-x=([^ ]+)/) { >- $xsession = $1; >- } elsif (/^--first/ || /^-F/) { >+ if (/^--first/ || /^-F/) { > $first++; >- } elsif (/^--generate=([^ ]+)/) { >- $generate = $1; >- } elsif (/^--wrap-sessions/) { >- $wrap_sessions++; >- } elsif (/^--gdm/ || /^-g/) { >- die "You should be root to build gdm session\n" if $< != 0; >- $gdm++; > } elsif (/^--list/ || /^-l/) { > $list++; > } elsif (/^-L/) { > $list_order++; >- } elsif (/^--kdm4/ || /^-K/) { >- $kdm4++; > } elsif (/^--test/ || /^-t/) { > $test++; > } elsif (/^--dir=([^ ]+)/ || /^-d=([^ ]+)/) { >@@ -117,7 +90,7 @@ while ($ARGV[0] =~ /^--/ || $ARGV[0] =~ /^-/) { > } > > # Parse all relevant files in session directory $dir >-$dir = $test ? './wmsession.d/' : '/etc/X11/wmsession.d/' unless $dir; >+$dir = $test ? './xsessions/' : '/usr/share/xsessions/' unless $dir; > chdir $dir; > for (<*>) { > next if /.*~/; >@@ -125,6 +98,9 @@ for (<*>) { > parse_file ("$_"); > } > >+# Put IceWM in last position >+@lf = sort { $a =~ /^IceWM$/i <=> $b =~ /^IceWM$/i } @lf; >+ > my ($e) = eval {cat("/etc/sysconfig/desktop")} =~ /DESKTOP=(\S+)/; > # The first string (without spaces) in the file is copied to $e. > >@@ -132,36 +108,6 @@ my ($e) = eval {cat("/etc/sysconfig/desktop")} =~ /DESKTOP=(\S+)/; > # Order of names in @lf is otherwise unchanged. > @lf = sort { $b =~ /^$e$/i <=> $a =~ /^$e$/i } @lf; > >- >-if ($generate) { >- gen_desktops($generate, $wrap_sessions); >-} >- >-if ($kdm4) { >- gen_desktops('/usr/share/apps/kdm/sessions', 0); >-} >- >-if ($gdm) { >- gen_desktops('/etc/X11/dm/Sessions', 1); >-} >- >-if ($xsession) { >- if ($script{$xsession}) { >- print "#!/bin/sh\n"; >- print $script{$xsession} >- } else { >- print "xterm -geometry 100x25+0+0 &\n"; >- if ( -x '/usr/bin/icewm' ) { >- print "icewm\n"; >- } elsif ( -x '/usr/bin/twm' ) { >- print "twm\n"; >- } else { >- print "xterm -geometry 67x14+384+446\n"; >- } >- } >- exit (0); >-} >- > @lf ? print shift @lf, "\n" : print "default\n" > if $first; >
diff --git a/sbin/chksession b/sbin/chksession index 46a6071..3acbd05 100644 --- a/sbin/chksession +++ b/sbin/chksession @@ -4,6 +4,7 @@ ## For info, see "chksession --help" or "man chksession" # Modified by Bernard Lang on August 21, 2003. +# Modified by ns80 on February 12, 2016. my @lf; @@ -20,15 +21,7 @@ Usage: $0 [OPTION]... -L: List window-managers including the order number -d=DIR, --dir=DIR: Specifies a directory of w-m configuration files. - Default is /etc/X11/wmsession.d/ - - -x=ENTRY, --xsession=ENTRY: Produce window-managers script of ENTRY. - - --generate=DIR: Produce window-manager .desktop files into DIR. - --wrap-sessions: Wrap window-managers with /usr/share/X11/xdm/Xsession. - - -K, --kdm4: Shortcut for --generate=/usr/share/apps/kdm/sessions - -g, --gdm: Shortcut for --generate=/etc/X11/dm/Sessions --wrap-sessions + Default is /usr/share/xsessions/ -h, --help: Produce this help. @@ -45,41 +38,32 @@ sub cat { # returns content of argument file as a single string } sub parse_file { # parse a session descriptor file - my ($fn) = @_; + my ($fn) = @_; $_ = cat ($fn); - ($n = $1) =~ s| ||g if /^NAME=(.*)/m; - $e = $1 if /^EXEC=(.*)/m; - my $dn = $1 if /^DESKTOPNAMES=(.*)/m; -# $d = $1 if /^DESC=(.*)/m; -# $i = $1 if /^ICON=(.*)/m; - $s = $1 while /SCRIPT:(.*?)$/gs; chomp $s; - if (-x $e) { $script{$n} = $s; $exe{$n} = $e; $desktopnames{$n} = $dn; 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, $usesession) = @_; - -d $d or system("mkdir -p $d"); - system("rm -f $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 "DesktopNames=$desktopnames{$file}\n" if $desktopnames{$file}; - if ($usesession) { - print FH "Exec=/usr/share/X11/xdm/Xsession $file\n"; - } else { - print FH "Exec=$file\n"; - } - print FH "Icon=\n"; - print FH "Type=Application\n"; - close FH; - chmod 0755, $file; - } + ($n = $1) =~ s| ||g if /^Name=(.*)/m; + $e = $1 if /^Exec=(.*)/m; + my $dn = $1 if /^Desktopnames=(.*)/m; + $s = $1 if /^Exec=(.*)/m; + $script{$n} = $s; + $exe{$n} = $e; + $desktopnames{$n} = $dn; + push @lf, $n; + if (lc $fn eq lc "icewm.desktop") { + ($order{$n}) = 99; + } elsif (opendir (DIR, $dir)) { + my $cpt = 1; + for my $xsessions_file (sort { "\L$a" cmp "\L$b" } readdir(DIR)) { + next if ($xsessions_file =~ m/^\./); + next if (lc $xsessions_file eq lc "icewm.desktop"); + if ($fn eq $xsessions_file) { + ($order{$n}) = sprintf ("%02d", $cpt); + last; + } else { + $cpt++; + } + } + closedir(DIR); + } } usage(1) @@ -87,23 +71,12 @@ usage(1) while ($ARGV[0] =~ /^--/ || $ARGV[0] =~ /^-/) { $_ = shift; - if (/^--xsession=([^ ]+)/ || /^-x=([^ ]+)/) { - $xsession = $1; - } elsif (/^--first/ || /^-F/) { + if (/^--first/ || /^-F/) { $first++; - } elsif (/^--generate=([^ ]+)/) { - $generate = $1; - } elsif (/^--wrap-sessions/) { - $wrap_sessions++; - } elsif (/^--gdm/ || /^-g/) { - die "You should be root to build gdm session\n" if $< != 0; - $gdm++; } elsif (/^--list/ || /^-l/) { $list++; } elsif (/^-L/) { $list_order++; - } elsif (/^--kdm4/ || /^-K/) { - $kdm4++; } elsif (/^--test/ || /^-t/) { $test++; } elsif (/^--dir=([^ ]+)/ || /^-d=([^ ]+)/) { @@ -117,7 +90,7 @@ while ($ARGV[0] =~ /^--/ || $ARGV[0] =~ /^-/) { } # Parse all relevant files in session directory $dir -$dir = $test ? './wmsession.d/' : '/etc/X11/wmsession.d/' unless $dir; +$dir = $test ? './xsessions/' : '/usr/share/xsessions/' unless $dir; chdir $dir; for (<*>) { next if /.*~/; @@ -125,6 +98,9 @@ for (<*>) { parse_file ("$_"); } +# Put IceWM in last position +@lf = sort { $a =~ /^IceWM$/i <=> $b =~ /^IceWM$/i } @lf; + my ($e) = eval {cat("/etc/sysconfig/desktop")} =~ /DESKTOP=(\S+)/; # The first string (without spaces) in the file is copied to $e. @@ -132,36 +108,6 @@ my ($e) = eval {cat("/etc/sysconfig/desktop")} =~ /DESKTOP=(\S+)/; # Order of names in @lf is otherwise unchanged. @lf = sort { $b =~ /^$e$/i <=> $a =~ /^$e$/i } @lf; - -if ($generate) { - gen_desktops($generate, $wrap_sessions); -} - -if ($kdm4) { - gen_desktops('/usr/share/apps/kdm/sessions', 0); -} - -if ($gdm) { - gen_desktops('/etc/X11/dm/Sessions', 1); -} - -if ($xsession) { - if ($script{$xsession}) { - print "#!/bin/sh\n"; - print $script{$xsession} - } else { - print "xterm -geometry 100x25+0+0 &\n"; - if ( -x '/usr/bin/icewm' ) { - print "icewm\n"; - } elsif ( -x '/usr/bin/twm' ) { - print "twm\n"; - } else { - print "xterm -geometry 67x14+384+446\n"; - } - } - exit (0); -} - @lf ? print shift @lf, "\n" : print "default\n" if $first;
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 17617
: 7451 |
8348