aboutsummaryrefslogtreecommitdiffstats
path: root/sbin/convertsession
blob: 794ef076bae0e9b29c4a5c1c15442f6e78c3f8f2 (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
30
31
#!/usr/bin/perl
# -*- Mode: cperl -*-
# Copyright (C) 2000 by Chmouel Boudjnah <chmouel@mandrakesoft.com>
# Redistribution of this file is permitted under the terms of the GNU 
# Public License (GPL)
## description: Convert a file /etc/X11/window-managers to a
##		/etc/X11/wmsession.d/ style files.

my $dir = '/etc/X11/wmsession.d/';

if ($ARGV[0] =~ /-f/ ) {
    $file = $ARGV[1];
} else {
    $file = '/etc/X11/window-managers';
}

my $cnt = 0;

open F, $file or die "Can't open $file\n";
while (<F>) {
    $/ = "--@@--";
    s|--@@--||g;
    if ($cnt != 0) {
	$content = "$_";
	$n = $1 if /^NAME=(.*)/m;
	open C, ">$dir/$cnt$n" or die "Can't open $dir/$cnt$n\n";
	print C $content;
	close C;
    }
    $cnt++;
}