--- /dev/null
+#!/usr/bin/env perl
+#ArchLinux Daemon Manager Gui! by Harvie 2oo9
+use strict;
+use warnings;
+use utf8;
+use Gtk2 qw(-init);
+
+if($< > 0) {
+ #run as root
+ print "You are not root! Trying GKSU...\n";
+ system("gksu ".$0);
+ exit;
+}
+
+my $aldm = '/usr/sbin/aldm';
+
+my %iterators = {};
+
+my $builder = Gtk2::Builder->new();
+$builder->add_from_file('/usr/share/aldm-gui/aldm.ui');
+
+my %widgets;
+foreach my $widget qw(window1 aboutdialog1 treeview1 liststore1 label2)
+{
+ $widgets{$widget}=$builder->get_object($widget);
+}
+
+$builder->connect_signals( undef );
+$builder = undef;
+
+#create columns in treeview
+ my $column = Gtk2::TreeViewColumn->new_with_attributes('Daemon', Gtk2::CellRendererText->new, text => 0);
+ $widgets{'treeview1'}->append_column($column);
+
+ $column = Gtk2::TreeViewColumn->new_with_attributes('Running', Gtk2::CellRendererText->new, text => 1);
+ $widgets{'treeview1'}->append_column($column);
+
+ $column = Gtk2::TreeViewColumn->new_with_attributes('WhatIs', Gtk2::CellRendererText->new, text => 2);
+ $widgets{'treeview1'}->append_column($column);
+
+refresh_view();
+
+$widgets{'window1'}->show();
+
+
+Gtk2->main();
+exit;
+
+sub on_window1_destroy
+{
+ Gtk2->main_quit();
+}
+
+sub on_imagemenuitem10_activate
+{
+ $widgets{'aboutdialog1'}->show();
+}
+
+sub on_aboutdialog1_close
+{
+ $widgets{'aboutdialog1'}->hide();
+}
+
+sub refresh_view
+{
+ #clear
+ #$widgets{'liststore1'}->clear();
+
+ #list daemons
+ open(my $daemon_list, "$aldm list|");
+ while(<$daemon_list>) {
+ no warnings 'uninitialized';
+ $_ =~ s/^\s+|\s+$//g; #trim
+ open(my $whatis, "'$aldm' whatis '$_'|"); my $w = <$whatis>; close($whatis); $w =~ s/^\s+|\s+$//g; #trim
+ (my $run, $w) = split(/ /,$w,2);
+
+ #my $iter = $widgets{'liststore1'}->append();
+ #$widgets{'liststore1'}->set($iter, 0 => "$_", 1=> "$run", 2 => "$w");
+
+ my $serv = $_;
+ $serv =~ s/^(!|@)//g;
+
+ if(!defined($iterators{$serv})) {
+ $iterators{$serv} = $widgets{'liststore1'}->append();
+ }
+ $widgets{'liststore1'}->set($iterators{$serv}, 0 => "$_", 1=> "$run", 2 => "$w");
+ }
+ close($daemon_list);
+}
+
+sub get_selected_daemon
+{
+ my $path = $widgets{'treeview1'}->get_selection->get_selected_rows;
+ my $model = $widgets{'treeview1'}->get_model;
+ my $iter = $model->get_iter($path);
+ my $str = $model->get ($iter, 0);
+ return $str;
+}
+
+sub status
+{
+ $_[0] =~ s/^\s+|\s+$//g; #trim
+ $widgets{'label2'}->set_text($_[0]);
+}
+
+sub s_system
+{
+ open(my $pipe, "$_[0]|");
+ while(<$pipe>) { status($_); }
+ close($pipe);
+}
+
+sub on_button_start_clicked { s_system "$aldm start ".get_selected_daemon(); refresh_view(); }
+sub on_button_stop_clicked { s_system "$aldm stop ".get_selected_daemon(); refresh_view(); }
+sub on_button_restart_clicked { s_system "$aldm restart ".get_selected_daemon(); refresh_view(); }
+
+sub on_button_enable_fg_clicked {
+ my $d = get_selected_daemon();
+ system "$aldm enable-fg ".$d;
+ refresh_view();
+ status($d." enabled on init!");
+}
+
+sub on_button_enable_bg_clicked {
+ my $d = get_selected_daemon();
+ system "$aldm enable-bg ".$d;
+ refresh_view();
+ status($d." enabled on init background!");
+}
+
+sub on_button_disable_clicked {
+ my $d = get_selected_daemon();
+ system "$aldm disable ".$d;
+ refresh_view();
+ status($d." disabled!");
+}
--- /dev/null
+<?xml version="1.0"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <!-- interface-naming-policy project-wide -->
+ <object class="GtkListStore" id="liststore1">
+ <columns>
+ <!-- column-name daemon -->
+ <column type="gchararray"/>
+ <!-- column-name running -->
+ <column type="gchararray"/>
+ <!-- column-name whatis -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkWindow" id="window1">
+ <property name="title" translatable="yes">ArchLinux Daemon Manager</property>
+ <property name="window_position">center</property>
+ <property name="default_height">400</property>
+ <property name="icon_name">server</property>
+ <signal name="destroy" handler="on_window1_destroy"/>
+ <child>
+ <object class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="xpad">5</property>
+ <property name="ypad">5</property>
+ <property name="pixel_size">32</property>
+ <property name="icon_name">server</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">ArchLinux Daemon Manager GUI
+CopyLefted by: Harvie 2oo9 ( http://blog.harvie.cz/ )</property>
+ <property name="justify">center</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <child>
+ <object class="GtkTreeView" id="treeview1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="tooltip_text" translatable="yes">Note that only services specified in rc.conf are listed here.
+You can still add more services to rc.conf as disabled with exclamation mark.
+
+services with ! are disabled.
+services with @ will be started on background during init.
+services without these signs will be started as blocking during init.
+
+It is NOT good idea to stop/restart services related to X server or graphical environment using this tool!</property>
+ <property name="model">liststore1</property>
+ <property name="enable_grid_lines">both</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHButtonBox" id="hbuttonbox1">
+ <property name="visible">True</property>
+ <property name="spacing">3</property>
+ <property name="homogeneous">True</property>
+ <property name="layout_style">center</property>
+ <child>
+ <object class="GtkButton" id="button_start">
+ <property name="label" translatable="yes">start</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="image">image2</property>
+ <signal name="clicked" handler="on_button_start_clicked"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_stop">
+ <property name="label" translatable="yes">stop</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="image">image3</property>
+ <signal name="clicked" handler="on_button_stop_clicked"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_restart">
+ <property name="label" translatable="yes">restart</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="image">image4</property>
+ <signal name="clicked" handler="on_button_restart_clicked"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_enable_fg">
+ <property name="label" translatable="yes">enable-fg</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="image">image5</property>
+ <signal name="clicked" handler="on_button_enable_fg_clicked"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_enable_bg">
+ <property name="label" translatable="yes">@enable-bg</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="image">image7</property>
+ <signal name="clicked" handler="on_button_enable_bg_clicked"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_disable">
+ <property name="label" translatable="yes">!disable</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="image">image6</property>
+ <signal name="clicked" handler="on_button_disable_clicked"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="xpad">5</property>
+ <property name="label" translatable="yes">Welcome to ALDM-GUI!</property>
+ <property name="selectable">True</property>
+ <property name="single_line_mode">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <object class="GtkImage" id="image2">
+ <property name="visible">True</property>
+ <property name="stock">gtk-media-play</property>
+ </object>
+ <object class="GtkImage" id="image3">
+ <property name="visible">True</property>
+ <property name="stock">gtk-media-stop</property>
+ </object>
+ <object class="GtkImage" id="image4">
+ <property name="visible">True</property>
+ <property name="stock">gtk-refresh</property>
+ </object>
+ <object class="GtkImage" id="image5">
+ <property name="visible">True</property>
+ <property name="stock">gtk-apply</property>
+ </object>
+ <object class="GtkImage" id="image6">
+ <property name="visible">True</property>
+ <property name="stock">gtk-cancel</property>
+ </object>
+ <object class="GtkImage" id="image7">
+ <property name="visible">True</property>
+ <property name="stock">gtk-apply</property>
+ </object>
+</interface>