source: lliurex-mate-welcome/trunk/fuentes/update-lliurex-menu-welcome @ 5163

Last change on this file since 5163 was 3933, checked in by alviboi, 2 years ago
  • Property svn:executable set to *
File size: 1.9 KB
Line 
1#!/usr/bin/perl
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the
15# Free Software Foundation, Inc.,
16# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
17#
18# Copyright (C) 2007-2015 Oleksandr Shneyder <oleksandr.shneyder@obviously-nice.de>
19# Copyright (C) 2007-2015 Heinz-Markus Graesing <heinz-m.graesing@obviously-nice.de>
20# Copyright (C) 2013-2015 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
21# Copyright (C) 2015 Martin Wimpress <code@flexion.org>
22
23use strict;
24
25my $mode=shift;
26if( $mode eq "--help" )
27{
28     print "Usage: $0 [--remove]\n";
29     print "       Add (or remove) \"Lliurex MATE Welcome\" button to (from) MATE's Settings menu.\n";
30     exit;
31}
32my $menu;
33if ( -e "/etc/xdg/menus/mate-settings.menu" )
34{
35    $menu="/etc/xdg/menus/mate-settings.menu";
36}
37else
38{
39    die "MATE Settings menu not found in /etc/xdg/menus";
40}
41
42my $menustr="<MergeFile>/etc/xdg/menus/lliurex-settings-welcome.menu</MergeFile>\n";
43
44open(FILE,"<$menu");
45my @ln=<FILE>;
46close(FILE);
47my $text=join("",@ln);
48
49if( $mode eq "--remove" )
50{
51    if($text =~ m/$menustr/)
52    {
53        $text =~ s/\n$menustr//;
54        open(FILE,">$menu");
55        print FILE $text;
56        close(FILE);
57    }
58}
59else
60{
61    if(! ($text =~ m/$menustr/))
62    {
63        $text =~ s/<\/Layout>/<\/Layout>\n$menustr/;
64        open(FILE,">$menu");
65        print FILE $text;
66        close(FILE);
67    }
68}
Note: See TracBrowser for help on using the repository browser.