[Xfce4-commits] <xfce4-power-manager:master> Merge branch 'devkit-power'

Ali Abdallah noreply at xfce.org
Sat Jan 30 02:18:43 CET 2010


Updating branch refs/heads/master
         to 228c0263e31cb19683bd1d4c5a528574c7b8e041 (commit)
       from bb70cbf94b138c8a07b5ee2877274323fc109555 (commit)

commit 228c0263e31cb19683bd1d4c5a528574c7b8e041
Merge: bb70cbf94b138c8a07b5ee2877274323fc109555 6bd47c8721340bce3f23db207209cbad49ce4123
Author: Ali Abdallah <aliov at xfce.org>
Date:   Sat Jan 30 02:09:58 2010 +0100

    Merge branch 'devkit-power'
    
    Conflicts:
    	data/interfaces/xfpm-settings.ui
    	src/Makefile.am
    	src/xfpm-brightness-hal.c
    	src/xfpm-engine.c
    	src/xfpm-supply.c
    	src/xfpm-tray-icon.c

commit 6bd47c8721340bce3f23db207209cbad49ce4123
Author: Ali Abdallah <aliov at xfce.org>
Date:   Sat Jan 23 01:40:09 2010 +0100

    User XfpmPower instead of XfpmDkp, as this is going to be either devicekit-power or upower,
    nothing seems to be changed between, just the D-Bus name and services, ouf!

commit 74bf8625d934013d932f8dd10be8eb2caa47a95c
Author: Ali Abdallah <aliov at xfce.org>
Date:   Sat Jan 23 01:07:49 2010 +0100

    Added png icons for people without librsvg.

commit 772b5ffeafaf4e80b197db84dc247a9fd7308f4a
Author: Ali Abdallah <aliov at xfce.org>
Date:   Sat Jan 23 00:03:53 2010 +0100

    Fix 'make distcheck'

commit 86c848dc1aad88f772500c4e25feabdd36e41a4f
Author: Ali Abdallah <aliov at xfce.org>
Date:   Fri Jan 22 16:16:10 2010 +0100

    Replace Information tray menu item by Power information, the new dialog in an external program, xfce4-power-information
    will be able to show information about power devices+processor wakeups.

commit f654a43b5d33a50ac63c15178c75c2a9d80b6012
Author: Ali Abdallah <aliov at xfce.org>
Date:   Fri Jan 22 16:14:41 2010 +0100

    Added GObject for handling unique instances of xfpm via D-Bus.

commit 9e431c76cfb93e09b99fa0e5badbcb6c603b85ef
Author: Ali Abdallah <aliov at xfce.org>
Date:   Wed Jan 20 15:05:34 2010 +0100

    Use the nice OSD from gnome-settings-daemon and use it for brightness level feedback.

commit acb8b3dc9b72c5f1abe79a512f0e60dad28ce04b
Author: Ali Abdallah <aliov at xfce.org>
Date:   Sat Jan 16 01:37:33 2010 +0100

    Avoid sending notification when battery is criticaly low and system is charging.

commit 53264a017ece7d4a27c7cce1d32158aa5f52ca2b
Author: Ali Abdallah <aliov at xfce.org>
Date:   Fri Dec 18 18:37:37 2009 +0100

    Drop the pot file

commit c51995c35c6ccff06060095a47091987bc42adf2
Author: Ali Abdallah <aliov at xfce.org>
Date:   Mon Dec 7 15:30:22 2009 +0100

    Drop a message when polkit auth changed.

commit a867dcf2324c44bb2ce59c2b391e38ce8fde58df
Author: Ali Abdallah <aliov at xfce.org>
Date:   Sun Nov 29 17:09:55 2009 +0100

    Use desktop file in xfce_sm_clien

commit 1a05f46a8bb24eff0d1af6b55cdf8001b1fea1a6
Author: Ali Abdallah <aliov at xfce.org>
Date:   Sun Nov 29 17:09:26 2009 +0100

    Fix brightness notification feedback level.

commit e58f1477f7011a1f9d2e5a65d6c9aecf17e57e41
Author: Ali Abdallah <aliov at xfce.org>
Date:   Sun Nov 29 17:08:52 2009 +0100

    Fix xrandr brightness support.

commit 2153e95ad6388d0c6c7b2f2d5b2f84c42befadb9
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Fri Nov 27 11:08:07 2009 +0100

    Use EggIdletime.

commit e350197a6ce92baa487ca8a3d40a90d873ed0edc
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Fri Nov 27 11:06:42 2009 +0100

    sleep for 0.5 second when sleeping to allow the nm applet to disconnect properly

commit 5de7fccd34753c63e355a070fe8e3e4d65023de9
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Sat Nov 21 13:47:50 2009 +0100

    Reset XScreen saver counter on lid open.

commit 24a8c20db4e41eaca593512d57b36936155695cd
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Wed Nov 11 14:50:24 2009 +0100

    Fix segfault when devkit-power isn't present.

commit 4f6383677fc989431b893f5d7a28e1a45235de15
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Wed Nov 11 09:08:27 2009 +0100

    Expose device_type and battery_charge_status as enum properties.

commit 4e3974f46b3c4b2e8112596a07fec40f99e8b244
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Wed Nov 11 08:51:24 2009 +0100

    Fix inactivity check box not appearing on Desktop system.

commit 6a9baf4d17328d995be2ff4bdca893ea23b8214b
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Mon Nov 9 20:06:14 2009 +0100

    Better brightness level dimming handling.

commit b4211ea84016787e1fa4350a19ff1562e101d970
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Mon Nov 9 15:15:43 2009 +0100

    Fix dump data when xfpm is not running.

commit f867843829bf5d2acf34f8d75a93033558e944e3
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Sun Nov 8 18:58:35 2009 +0100

    Added idle sleep timeouts, xfpm devkit-power branch should be
    fully functional now.

commit 45837424d849565a9ee5966dc84e3208905649fc
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Sun Nov 8 14:02:13 2009 +0100

    Added adaptor icon to show when no battery present.
    Fix consolekit can-reboot property name.

commit 54e6b0834337de07f9832588c4cbf5714cbf2769
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Fri Nov 6 21:14:12 2009 +0100

    Fix some typos and chane 15 to 11 as dkp version (was set for testing).

commit 13c68f4148f2ffd91a3c562bc5588c42a3d3219d
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Fri Nov 6 20:58:02 2009 +0100

    Check dkp daemon version as the minimum allowed version is 011 since
    earlier versions of devkit-power uses dash-dash property names
    while newer version uses FirstLetterCaps.

commit 4ab79e4744caf4a5649407d44df025d1122451dd
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Fri Nov 6 20:20:17 2009 +0100

    Added --dump command line to dump important information.

commit 5a75c358a7d887e9fe63cd255a50826b3eb5d91d
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Fri Nov 6 19:30:58 2009 +0100

    Make debugging doesn't depend on configuration+add --debug
    in the command line for debugging output.

commit d27dce4bcf8e144dd5265b084e25ca4d0300b267
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Fri Nov 6 18:34:38 2009 +0100

    Don't leak when reload brightness information.

commit a830826ce72d043c7d6575ca110deb0e51ca9b2d
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Fri Nov 6 17:17:01 2009 +0100

    Fix some typos in the previous commit concerning devicekit-disks.

commit f9292aa5c359545cf2043d8c58899367d113bdcf
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Fri Nov 6 17:00:06 2009 +0100

    Support for spinning downs hard disks via device-kit-disks
    to use this feature use has to have the policy kit permission on
    "org.freedesktop.devicekit.disks.drive-set-spindown"

commit 8510408fe399538d6644428b2dd6c1cbaa72e168
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Fri Nov 6 14:37:41 2009 +0100

    Added shutdown permission handler in the settings dialog.

commit 6eb3d89aee72a635f7e479ca3d45874c53718b88
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Fri Nov 6 14:07:26 2009 +0100

    Fix console kit D-Bus path and interface names

commit 9b5cb60049ed2c355a0c498bde810fb6f7fa937f
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Fri Nov 6 14:06:47 2009 +0100

    Survive D-Bus system bus restarts.

commit 7d69232b827bfacb160dc2b501588023dac92141
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Fri Nov 6 13:55:38 2009 +0100

    Added support for console kit to use Shutdown and Reboot.

commit 23116a1fca688d481ed8f7d3448b829d0f54eb32
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Fri Nov 6 13:05:34 2009 +0100

    Support for shutdown via the session manager.

commit cdc132a83cd7785319170eef508338bedf52fc21
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Fri Nov 6 12:45:24 2009 +0100

    Fallback to HaL in case of failure on mapping X button.
    Use gint instead of guint for the brightness level.

commit df7818730f752678a89baf9625f798943401b95f
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Fri Nov 6 10:46:18 2009 +0100

    Fix some issues with low power notifications.
    
    Brightness control now should be fully working, control of the lcd
    backlight is done using xrandr by default but if this fails and if
    HAL support is compiled then fallback, but still probably we need
    to provide a key to force the power manager to use HAL when HAL
    support is compiled because sometimes xrand reports that everything
    is fine but it fails silently to change the brightness level, uhh
    still too much suckiness in the backlight control on Linux.

commit 805ac7034c1ace6ba2e417e4a9bded100c24920d
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Thu Nov 5 15:42:14 2009 +0100

    Added battery information from devicekit power.

commit cda9fdcb513e9fb17f63588b63626f76a3af7acc
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Thu Nov 5 14:14:46 2009 +0100

    Make the battery tooltips information better.

commit 14d0c8e0da97157b3acf127086c7a79be73961c3
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Thu Nov 5 10:04:22 2009 +0100

    Query notification server capabilities for adding actions to
    notification, if server supports actions use them to show a
    notification warning about the low power level if not use gtk.
    
    Re-Enable suspend/hibernate/lid actions.

commit 44f74bccaf9cedbf1e245d372152055f487e52ad
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Wed Nov 4 09:26:41 2009 +0100

    Re-add hibernate/Suspend functionality via devicekit power and make
    sure that xfpm is not inhibited in case of no urgent sleep request.

commit c4bab4c1be603614ace33b914d155c12223e762e
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Tue Nov 3 16:07:11 2009 +0100

    Creating the devkit-power branch, this brank is highly experimental
    a big part of xfpm and its configuration settings are broken.
    
    In this branch polkit is a new optional dependency, this is for
    getting if the user is permitted to use org.freedesktop.Devicekit.Power
    sleep interfaces, also by default the power manager will try to
    manipulate the lcd brightness using xrandr (doesn't work yet),
    HAL remains an optional dependency of fall back for the lcd
    brightness and in case of mapping failure of keyboard sleep keys.
    
    If HAL support is compiled but HAL is not running
    or stopped, xfpm should in future commits be able to handle this.

 INSTALL                                            |   97 +-
 Makefile.am                                        |    8 +-
 README                                             |    5 +-
 TODO                                               |    9 +-
 common/Makefile.am                                 |   27 +
 common/xfpm-brightness.c                           |  685 ++++++++
 common/xfpm-brightness.h                           |   85 +
 common/xfpm-common.c                               |  216 +++
 common/xfpm-common.h                               |   58 +
 common/xfpm-debug.c                                |  109 ++
 common/xfpm-debug.h                                |   77 +
 common/xfpm-icons.h                                |   53 +
 configure.ac.in                                    |   62 +-
 data/icons/128x128/Makefile.am                     |    1 +
 data/icons/128x128/devices/Makefile.am             |    7 +
 data/icons/128x128/devices/processor.png           |  Bin 0 -> 10783 bytes
 data/icons/{scalable => 16x16}/Makefile.am         |    0
 data/icons/16x16/actions/Makefile.am               |    8 +
 data/icons/16x16/actions/xfpm-hibernate.png        |  Bin 0 -> 685 bytes
 data/icons/16x16/actions/xfpm-suspend.png          |  Bin 0 -> 801 bytes
 data/icons/16x16/status/Makefile.am                |   49 +
 data/icons/16x16/status/xfpm-ac-adapter.png        |  Bin 0 -> 719 bytes
 .../16x16/status/xfpm-brightness-lcd-invalid.png   |  Bin 0 -> 546 bytes
 data/icons/16x16/status/xfpm-brightness-lcd.png    |  Bin 0 -> 546 bytes
 data/icons/16x16/status/xfpm-keyboard-000.png      |  Bin 0 -> 670 bytes
 data/icons/16x16/status/xfpm-keyboard-030.png      |  Bin 0 -> 683 bytes
 data/icons/16x16/status/xfpm-keyboard-060.png      |  Bin 0 -> 696 bytes
 data/icons/16x16/status/xfpm-keyboard-100.png      |  Bin 0 -> 679 bytes
 data/icons/16x16/status/xfpm-mouse-000.png         |  Bin 0 -> 718 bytes
 data/icons/16x16/status/xfpm-mouse-030.png         |  Bin 0 -> 732 bytes
 data/icons/16x16/status/xfpm-mouse-060.png         |  Bin 0 -> 737 bytes
 data/icons/16x16/status/xfpm-mouse-100.png         |  Bin 0 -> 710 bytes
 data/icons/16x16/status/xfpm-phone-000.png         |  Bin 0 -> 833 bytes
 data/icons/16x16/status/xfpm-phone-030.png         |  Bin 0 -> 846 bytes
 data/icons/16x16/status/xfpm-phone-060.png         |  Bin 0 -> 834 bytes
 data/icons/16x16/status/xfpm-phone-100.png         |  Bin 0 -> 796 bytes
 .../16x16/status/xfpm-primary-000-charging.png     |  Bin 0 -> 911 bytes
 data/icons/16x16/status/xfpm-primary-000.png       |  Bin 0 -> 648 bytes
 .../16x16/status/xfpm-primary-020-charging.png     |  Bin 0 -> 915 bytes
 data/icons/16x16/status/xfpm-primary-020.png       |  Bin 0 -> 662 bytes
 .../16x16/status/xfpm-primary-040-charging.png     |  Bin 0 -> 915 bytes
 data/icons/16x16/status/xfpm-primary-040.png       |  Bin 0 -> 644 bytes
 .../16x16/status/xfpm-primary-060-charging.png     |  Bin 0 -> 913 bytes
 data/icons/16x16/status/xfpm-primary-060.png       |  Bin 0 -> 645 bytes
 .../16x16/status/xfpm-primary-080-charging.png     |  Bin 0 -> 914 bytes
 data/icons/16x16/status/xfpm-primary-080.png       |  Bin 0 -> 623 bytes
 .../16x16/status/xfpm-primary-100-charging.png     |  Bin 0 -> 924 bytes
 data/icons/16x16/status/xfpm-primary-100.png       |  Bin 0 -> 601 bytes
 data/icons/16x16/status/xfpm-primary-charged.png   |  Bin 0 -> 1404 bytes
 data/icons/16x16/status/xfpm-primary-missing.png   |  Bin 0 -> 810 bytes
 data/icons/16x16/status/xfpm-ups-000-charging.png  |  Bin 0 -> 586 bytes
 data/icons/16x16/status/xfpm-ups-000.png           |  Bin 0 -> 522 bytes
 data/icons/16x16/status/xfpm-ups-020-charging.png  |  Bin 0 -> 612 bytes
 data/icons/16x16/status/xfpm-ups-020.png           |  Bin 0 -> 544 bytes
 data/icons/16x16/status/xfpm-ups-040-charging.png  |  Bin 0 -> 605 bytes
 data/icons/16x16/status/xfpm-ups-040.png           |  Bin 0 -> 547 bytes
 data/icons/16x16/status/xfpm-ups-060-charging.png  |  Bin 0 -> 622 bytes
 data/icons/16x16/status/xfpm-ups-060.png           |  Bin 0 -> 565 bytes
 data/icons/16x16/status/xfpm-ups-080-charging.png  |  Bin 0 -> 587 bytes
 data/icons/16x16/status/xfpm-ups-080.png           |  Bin 0 -> 533 bytes
 data/icons/16x16/status/xfpm-ups-100-charging.png  |  Bin 0 -> 604 bytes
 data/icons/16x16/status/xfpm-ups-100.png           |  Bin 0 -> 527 bytes
 data/icons/16x16/status/xfpm-ups-charged.png       |  Bin 0 -> 744 bytes
 data/icons/16x16/status/xfpm-ups-missing.png       |  Bin 0 -> 694 bytes
 data/icons/{scalable => 22x22}/Makefile.am         |    0
 data/icons/22x22/actions/Makefile.am               |    8 +
 data/icons/22x22/actions/xfpm-hibernate.png        |  Bin 0 -> 1042 bytes
 data/icons/22x22/actions/xfpm-suspend.png          |  Bin 0 -> 1032 bytes
 data/icons/22x22/status/Makefile.am                |   49 +
 data/icons/22x22/status/xfpm-ac-adapter.png        |  Bin 0 -> 1168 bytes
 .../22x22/status/xfpm-brightness-lcd-invalid.png   |  Bin 0 -> 1240 bytes
 data/icons/22x22/status/xfpm-brightness-lcd.png    |  Bin 0 -> 1157 bytes
 data/icons/22x22/status/xfpm-keyboard-000.png      |  Bin 0 -> 1065 bytes
 data/icons/22x22/status/xfpm-keyboard-030.png      |  Bin 0 -> 1098 bytes
 data/icons/22x22/status/xfpm-keyboard-060.png      |  Bin 0 -> 1112 bytes
 data/icons/22x22/status/xfpm-keyboard-100.png      |  Bin 0 -> 1074 bytes
 data/icons/22x22/status/xfpm-mouse-000.png         |  Bin 0 -> 1102 bytes
 data/icons/22x22/status/xfpm-mouse-030.png         |  Bin 0 -> 1135 bytes
 data/icons/22x22/status/xfpm-mouse-060.png         |  Bin 0 -> 1118 bytes
 data/icons/22x22/status/xfpm-mouse-100.png         |  Bin 0 -> 1050 bytes
 data/icons/22x22/status/xfpm-phone-000.png         |  Bin 0 -> 1189 bytes
 data/icons/22x22/status/xfpm-phone-030.png         |  Bin 0 -> 1198 bytes
 data/icons/22x22/status/xfpm-phone-060.png         |  Bin 0 -> 1180 bytes
 data/icons/22x22/status/xfpm-phone-100.png         |  Bin 0 -> 1134 bytes
 .../22x22/status/xfpm-primary-000-charging.png     |  Bin 0 -> 1276 bytes
 data/icons/22x22/status/xfpm-primary-000.png       |  Bin 0 -> 909 bytes
 .../22x22/status/xfpm-primary-020-charging.png     |  Bin 0 -> 1315 bytes
 data/icons/22x22/status/xfpm-primary-020.png       |  Bin 0 -> 915 bytes
 .../22x22/status/xfpm-primary-040-charging.png     |  Bin 0 -> 1270 bytes
 data/icons/22x22/status/xfpm-primary-040.png       |  Bin 0 -> 917 bytes
 .../22x22/status/xfpm-primary-060-charging.png     |  Bin 0 -> 1289 bytes
 data/icons/22x22/status/xfpm-primary-060.png       |  Bin 0 -> 900 bytes
 .../22x22/status/xfpm-primary-080-charging.png     |  Bin 0 -> 1262 bytes
 data/icons/22x22/status/xfpm-primary-080.png       |  Bin 0 -> 863 bytes
 .../22x22/status/xfpm-primary-100-charging.png     |  Bin 0 -> 1244 bytes
 data/icons/22x22/status/xfpm-primary-100.png       |  Bin 0 -> 832 bytes
 data/icons/22x22/status/xfpm-primary-charged.png   |  Bin 0 -> 1897 bytes
 data/icons/22x22/status/xfpm-primary-missing.png   |  Bin 0 -> 1001 bytes
 data/icons/22x22/status/xfpm-ups-000-charging.png  |  Bin 0 -> 844 bytes
 data/icons/22x22/status/xfpm-ups-000.png           |  Bin 0 -> 764 bytes
 data/icons/22x22/status/xfpm-ups-020-charging.png  |  Bin 0 -> 873 bytes
 data/icons/22x22/status/xfpm-ups-020.png           |  Bin 0 -> 798 bytes
 data/icons/22x22/status/xfpm-ups-040-charging.png  |  Bin 0 -> 881 bytes
 data/icons/22x22/status/xfpm-ups-040.png           |  Bin 0 -> 793 bytes
 data/icons/22x22/status/xfpm-ups-060-charging.png  |  Bin 0 -> 886 bytes
 data/icons/22x22/status/xfpm-ups-060.png           |  Bin 0 -> 805 bytes
 data/icons/22x22/status/xfpm-ups-080-charging.png  |  Bin 0 -> 864 bytes
 data/icons/22x22/status/xfpm-ups-080.png           |  Bin 0 -> 793 bytes
 data/icons/22x22/status/xfpm-ups-100-charging.png  |  Bin 0 -> 762 bytes
 data/icons/22x22/status/xfpm-ups-100.png           |  Bin 0 -> 762 bytes
 data/icons/22x22/status/xfpm-ups-charged.png       |  Bin 0 -> 762 bytes
 data/icons/22x22/status/xfpm-ups-missing.png       |  Bin 0 -> 924 bytes
 data/icons/{scalable => 24x24}/Makefile.am         |    0
 data/icons/24x24/actions/Makefile.am               |    8 +
 data/icons/24x24/actions/xfpm-hibernate.png        |  Bin 0 -> 1035 bytes
 data/icons/24x24/actions/xfpm-suspend.png          |  Bin 0 -> 1031 bytes
 data/icons/24x24/status/Makefile.am                |   49 +
 data/icons/24x24/status/xfpm-ac-adapter.png        |  Bin 0 -> 1170 bytes
 .../24x24/status/xfpm-brightness-lcd-invalid.png   |  Bin 0 -> 1876 bytes
 data/icons/24x24/status/xfpm-brightness-lcd.png    |  Bin 0 -> 1160 bytes
 data/icons/24x24/status/xfpm-keyboard-000.png      |  Bin 0 -> 1073 bytes
 data/icons/24x24/status/xfpm-keyboard-030.png      |  Bin 0 -> 1087 bytes
 data/icons/24x24/status/xfpm-keyboard-060.png      |  Bin 0 -> 1099 bytes
 data/icons/24x24/status/xfpm-keyboard-100.png      |  Bin 0 -> 1067 bytes
 data/icons/24x24/status/xfpm-mouse-000.png         |  Bin 0 -> 1110 bytes
 data/icons/24x24/status/xfpm-mouse-030.png         |  Bin 0 -> 1141 bytes
 data/icons/24x24/status/xfpm-mouse-060.png         |  Bin 0 -> 1123 bytes
 data/icons/24x24/status/xfpm-mouse-100.png         |  Bin 0 -> 1050 bytes
 data/icons/24x24/status/xfpm-phone-000.png         |  Bin 0 -> 1882 bytes
 data/icons/24x24/status/xfpm-phone-030.png         |  Bin 0 -> 1891 bytes
 data/icons/24x24/status/xfpm-phone-060.png         |  Bin 0 -> 1891 bytes
 data/icons/24x24/status/xfpm-phone-100.png         |  Bin 0 -> 1835 bytes
 .../24x24/status/xfpm-primary-000-charging.png     |  Bin 0 -> 1270 bytes
 data/icons/24x24/status/xfpm-primary-000.png       |  Bin 0 -> 922 bytes
 .../24x24/status/xfpm-primary-020-charging.png     |  Bin 0 -> 1297 bytes
 data/icons/24x24/status/xfpm-primary-020.png       |  Bin 0 -> 923 bytes
 .../24x24/status/xfpm-primary-040-charging.png     |  Bin 0 -> 1288 bytes
 data/icons/24x24/status/xfpm-primary-040.png       |  Bin 0 -> 925 bytes
 .../24x24/status/xfpm-primary-060-charging.png     |  Bin 0 -> 1305 bytes
 data/icons/24x24/status/xfpm-primary-060.png       |  Bin 0 -> 912 bytes
 .../24x24/status/xfpm-primary-080-charging.png     |  Bin 0 -> 1280 bytes
 data/icons/24x24/status/xfpm-primary-080.png       |  Bin 0 -> 872 bytes
 .../24x24/status/xfpm-primary-100-charging.png     |  Bin 0 -> 1261 bytes
 data/icons/24x24/status/xfpm-primary-100.png       |  Bin 0 -> 839 bytes
 data/icons/24x24/status/xfpm-primary-charged.png   |  Bin 0 -> 1913 bytes
 data/icons/24x24/status/xfpm-primary-missing.png   |  Bin 0 -> 1021 bytes
 data/icons/24x24/status/xfpm-ups-000-charging.png  |  Bin 0 -> 862 bytes
 data/icons/24x24/status/xfpm-ups-000.png           |  Bin 0 -> 783 bytes
 data/icons/24x24/status/xfpm-ups-020-charging.png  |  Bin 0 -> 891 bytes
 data/icons/24x24/status/xfpm-ups-020.png           |  Bin 0 -> 812 bytes
 data/icons/24x24/status/xfpm-ups-040-charging.png  |  Bin 0 -> 897 bytes
 data/icons/24x24/status/xfpm-ups-040.png           |  Bin 0 -> 816 bytes
 data/icons/24x24/status/xfpm-ups-060-charging.png  |  Bin 0 -> 902 bytes
 data/icons/24x24/status/xfpm-ups-060.png           |  Bin 0 -> 830 bytes
 data/icons/24x24/status/xfpm-ups-080-charging.png  |  Bin 0 -> 883 bytes
 data/icons/24x24/status/xfpm-ups-080.png           |  Bin 0 -> 816 bytes
 data/icons/24x24/status/xfpm-ups-100-charging.png  |  Bin 0 -> 785 bytes
 data/icons/24x24/status/xfpm-ups-100.png           |  Bin 0 -> 785 bytes
 data/icons/24x24/status/xfpm-ups-charged.png       |  Bin 0 -> 785 bytes
 data/icons/24x24/status/xfpm-ups-missing.png       |  Bin 0 -> 917 bytes
 data/icons/{scalable => 48x48}/Makefile.am         |    0
 data/icons/48x48/actions/Makefile.am               |    8 +
 data/icons/48x48/actions/xfpm-hibernate.png        |  Bin 0 -> 2703 bytes
 data/icons/48x48/actions/xfpm-suspend.png          |  Bin 0 -> 2591 bytes
 data/icons/48x48/status/Makefile.am                |   49 +
 data/icons/48x48/status/xfpm-ac-adapter.png        |  Bin 0 -> 3155 bytes
 .../48x48/status/xfpm-brightness-lcd-invalid.png   |  Bin 0 -> 3509 bytes
 data/icons/48x48/status/xfpm-brightness-lcd.png    |  Bin 0 -> 2844 bytes
 data/icons/48x48/status/xfpm-keyboard-000.png      |  Bin 0 -> 3176 bytes
 data/icons/48x48/status/xfpm-keyboard-030.png      |  Bin 0 -> 3242 bytes
 data/icons/48x48/status/xfpm-keyboard-060.png      |  Bin 0 -> 3211 bytes
 data/icons/48x48/status/xfpm-keyboard-100.png      |  Bin 0 -> 2914 bytes
 data/icons/48x48/status/xfpm-mouse-000.png         |  Bin 0 -> 3302 bytes
 data/icons/48x48/status/xfpm-mouse-030.png         |  Bin 0 -> 3472 bytes
 data/icons/48x48/status/xfpm-mouse-060.png         |  Bin 0 -> 3430 bytes
 data/icons/48x48/status/xfpm-mouse-100.png         |  Bin 0 -> 3191 bytes
 data/icons/48x48/status/xfpm-phone-000.png         |  Bin 0 -> 4043 bytes
 data/icons/48x48/status/xfpm-phone-030.png         |  Bin 0 -> 4102 bytes
 data/icons/48x48/status/xfpm-phone-060.png         |  Bin 0 -> 4036 bytes
 data/icons/48x48/status/xfpm-phone-100.png         |  Bin 0 -> 3901 bytes
 .../48x48/status/xfpm-primary-000-charging.png     |  Bin 0 -> 4051 bytes
 data/icons/48x48/status/xfpm-primary-000.png       |  Bin 0 -> 2443 bytes
 .../48x48/status/xfpm-primary-020-charging.png     |  Bin 0 -> 4053 bytes
 data/icons/48x48/status/xfpm-primary-020.png       |  Bin 0 -> 2460 bytes
 .../48x48/status/xfpm-primary-040-charging.png     |  Bin 0 -> 4160 bytes
 data/icons/48x48/status/xfpm-primary-040.png       |  Bin 0 -> 2548 bytes
 .../48x48/status/xfpm-primary-060-charging.png     |  Bin 0 -> 4124 bytes
 data/icons/48x48/status/xfpm-primary-060.png       |  Bin 0 -> 2450 bytes
 .../48x48/status/xfpm-primary-080-charging.png     |  Bin 0 -> 4173 bytes
 data/icons/48x48/status/xfpm-primary-080.png       |  Bin 0 -> 2413 bytes
 .../48x48/status/xfpm-primary-100-charging.png     |  Bin 0 -> 4059 bytes
 data/icons/48x48/status/xfpm-primary-100.png       |  Bin 0 -> 2214 bytes
 data/icons/48x48/status/xfpm-primary-charged.png   |  Bin 0 -> 3737 bytes
 data/icons/48x48/status/xfpm-primary-missing.png   |  Bin 0 -> 2851 bytes
 data/icons/48x48/status/xfpm-ups-000-charging.png  |  Bin 0 -> 2094 bytes
 data/icons/48x48/status/xfpm-ups-000.png           |  Bin 0 -> 1804 bytes
 data/icons/48x48/status/xfpm-ups-020-charging.png  |  Bin 0 -> 2128 bytes
 data/icons/48x48/status/xfpm-ups-020.png           |  Bin 0 -> 1845 bytes
 data/icons/48x48/status/xfpm-ups-040-charging.png  |  Bin 0 -> 2150 bytes
 data/icons/48x48/status/xfpm-ups-040.png           |  Bin 0 -> 1869 bytes
 data/icons/48x48/status/xfpm-ups-060-charging.png  |  Bin 0 -> 2174 bytes
 data/icons/48x48/status/xfpm-ups-060.png           |  Bin 0 -> 1904 bytes
 data/icons/48x48/status/xfpm-ups-080-charging.png  |  Bin 0 -> 2176 bytes
 data/icons/48x48/status/xfpm-ups-080.png           |  Bin 0 -> 1895 bytes
 data/icons/48x48/status/xfpm-ups-100-charging.png  |  Bin 0 -> 2089 bytes
 data/icons/48x48/status/xfpm-ups-100.png           |  Bin 0 -> 1890 bytes
 data/icons/48x48/status/xfpm-ups-charged.png       |  Bin 0 -> 1862 bytes
 data/icons/48x48/status/xfpm-ups-missing.png       |  Bin 0 -> 2746 bytes
 data/icons/Makefile.am                             |   11 +-
 data/interfaces/Makefile.am                        |    7 +-
 data/interfaces/acme.ui                            |   41 +
 data/interfaces/xfpm-settings.ui                   |   74 +-
 libdbus/Makefile.am                                |   43 +
 libdbus/org.xfce.unique.xml                        |   10 +
 libdbus/xfpm-dbus-marshal.list                     |    2 +
 libdbus/xfpm-dbus-monitor.c                        |  446 +++++
 libdbus/xfpm-dbus-monitor.h                        |   92 ++
 {libxfpm => libdbus}/xfpm-dbus.c                   |    0
 libdbus/xfpm-dbus.h                                |   36 +
 libdbus/xfpm-unique.c                              |  243 +++
 libdbus/xfpm-unique.h                              |   57 +
 libhal/Makefile.am                                 |   40 +
 {libxfpm => libhal}/hal-device.c                   |    0
 {libxfpm => libhal}/hal-device.h                   |    0
 libhal/hal-manager.c                               |  282 ++++
 libhal/hal-manager.h                               |   69 +
 {libxfpm => libhal}/hal-marshal.list               |    0
 libxfpm/Makefile.am                                |   69 -
 libxfpm/hal-battery.c                              |  554 -------
 libxfpm/hal-battery.h                              |   57 -
 libxfpm/hal-enum.h                                 |   37 -
 libxfpm/hal-manager.c                              |  250 ---
 libxfpm/hal-manager.h                              |   64 -
 libxfpm/hal-power.c                                |  386 -----
 libxfpm/hal-power.h                                |   67 -
 libxfpm/xfpm-common.c                              |  182 ---
 libxfpm/xfpm-common.h                              |   51 -
 libxfpm/xfpm-dbus.h                                |   34 -
 libxfpm/xfpm-icons.h                               |   44 -
 libxfpm/xfpm-notify.c                              |  283 ----
 libxfpm/xfpm-popups.c                              |   79 -
 libxfpm/xfpm-popups.h                              |   35 -
 libxfpm/xfpm-string.c                              |   47 -
 libxfpm/xfpm-string.h                              |   35 -
 panel-plugins/brightness/Makefile.am               |   21 +-
 panel-plugins/brightness/brightness-button.c       |   65 +-
 panel-plugins/brightness/brightness-plugin.c       |    2 -
 panel-plugins/brightness/brightness-proxy.c        |  237 ---
 panel-plugins/brightness/brightness-proxy.h        |   62 -
 po/POTFILES.in                                     |   25 +-
 settings/Makefile.am                               |   11 +-
 settings/xfpm-settings-main.c                      |  160 +-
 settings/xfpm-settings.c                           |  257 ++--
 settings/xfpm-settings.h                           |   10 +-
 src/Makefile.am                                    |  171 ++-
 src/gsd-media-keys-window.c                        | 1078 ++++++++++++
 src/gsd-media-keys-window.h                        |   71 +
 src/org.freedesktop.PowerManagement.Backlight.xml  |   15 -
 src/org.freedesktop.PowerManagement.xml            |    4 +-
 src/xfpm-adapter.c                                 |  214 ---
 src/xfpm-adapter.h                                 |   61 -
 src/xfpm-backlight.c                               |  472 +++++--
 src/xfpm-backlight.h                               |   21 +-
 src/xfpm-battery-info.c                            |  222 ---
 src/xfpm-battery-info.h                            |   35 -
 src/xfpm-battery.c                                 | 1018 ++++++------
 src/xfpm-battery.h                                 |   36 +-
 src/xfpm-brightness-hal.c                          |  594 -------
 src/xfpm-brightness-hal.h                          |   64 -
 src/xfpm-brightness-widget.c                       |  352 ----
 src/xfpm-brightness-widget.h                       |   60 -
 src/xfpm-button-hal.c                              |  327 ----
 src/xfpm-button-hal.h                              |   67 -
 src/xfpm-button-xf86.c                             |  271 ----
 src/xfpm-button-xf86.h                             |   59 -
 src/xfpm-button.c                                  |  394 ++++-
 src/xfpm-button.h                                  |   26 +-
 src/xfpm-config.h                                  |   42 +-
 src/xfpm-console-kit.c                             |  235 +++
 src/xfpm-console-kit.h                             |   59 +
 src/xfpm-cpu.c                                     |  427 -----
 src/xfpm-cpu.h                                     |   59 -
 src/xfpm-dbus-monitor.c                            |  485 ------
 src/xfpm-dbus-monitor.h                            |   99 --
 src/xfpm-debug.c                                   |   81 -
 src/xfpm-debug.h                                   |   65 -
 src/xfpm-disks.c                                   |  279 ++++
 src/xfpm-disks.h                                   |   57 +
 src/xfpm-dpms.c                                    |   69 +-
 src/xfpm-engine.c                                  |  957 -----------
 src/xfpm-engine.h                                  |   62 -
 src/xfpm-enum-glib.h                               |   52 +-
 src/xfpm-enum.h                                    |    9 +-
 src/xfpm-inhibit.c                                 |   15 +-
 src/xfpm-main.c                                    |  292 +++-
 src/xfpm-manager.c                                 |  583 ++++++--
 src/xfpm-manager.h                                 |    5 +-
 src/xfpm-network-manager.c                         |    3 +
 src/xfpm-notify.c                                  |  374 +++++
 {libxfpm => src}/xfpm-notify.h                     |    0
 src/xfpm-polkit.c                                  |  191 +++
 src/xfpm-polkit.h                                  |   58 +
 src/xfpm-power-common.c                            |  197 +++
 src/xfpm-power-common.h                            |   61 +
 src/xfpm-power-info.c                              |  986 +++++++++++
 src/xfpm-power.c                                   | 1709 ++++++++++++++++++++
 src/xfpm-power.h                                   |   79 +
 src/xfpm-screen-saver.c                            |  157 --
 src/xfpm-screen-saver.h                            |   62 -
 src/xfpm-session.c                                 |  279 ----
 src/xfpm-session.h                                 |   69 -
 src/xfpm-shutdown.c                                |  532 ------
 src/xfpm-shutdown.h                                |   83 -
 src/xfpm-supply.c                                  |  637 --------
 src/xfpm-supply.h                                  |   66 -
 src/xfpm-tray-icon.c                               |  558 -------
 src/xfpm-tray-icon.h                               |   73 -
 src/xfpm-xfconf.c                                  |   67 +-
 src/xfpm-xfconf.h                                  |    3 +
 319 files changed, 11085 insertions(+), 11027 deletions(-)

diff --git a/INSTALL b/INSTALL
index 2550dab..7d1c323 100644
--- a/INSTALL
+++ b/INSTALL
@@ -4,8 +4,10 @@ Installation Instructions
 Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 
-   This file is free documentation; the Free Software Foundation gives
-unlimited permission to copy, distribute and modify it.
+   Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.  This file is offered as-is,
+without warranty of any kind.
 
 Basic Installation
 ==================
@@ -13,7 +15,11 @@ Basic Installation
    Briefly, the shell commands `./configure; make; make install' should
 configure, build, and install this package.  The following
 more-detailed instructions are generic; see the `README' file for
-instructions specific to this package.
+instructions specific to this package.  Some packages provide this
+`INSTALL' file but do not implement all of the features documented
+below.  The lack of an optional feature in a given package is not
+necessarily a bug.  More recommendations for GNU packages can be found
+in *note Makefile Conventions: (standards)Makefile Conventions.
 
    The `configure' shell script attempts to guess correct values for
 various system-dependent variables used during compilation.  It uses
@@ -42,7 +48,7 @@ may remove or edit it.
 you want to change it or regenerate `configure' using a newer version
 of `autoconf'.
 
-The simplest way to compile this package is:
+   The simplest way to compile this package is:
 
   1. `cd' to the directory containing the package's source code and type
      `./configure' to configure the package for your system.
@@ -53,12 +59,22 @@ The simplest way to compile this package is:
   2. Type `make' to compile the package.
 
   3. Optionally, type `make check' to run any self-tests that come with
-     the package.
+     the package, generally using the just-built uninstalled binaries.
 
   4. Type `make install' to install the programs and any data files and
-     documentation.
-
-  5. You can remove the program binaries and object files from the
+     documentation.  When installing into a prefix owned by root, it is
+     recommended that the package be configured and built as a regular
+     user, and only the `make install' phase executed with root
+     privileges.
+
+  5. Optionally, type `make installcheck' to repeat any self-tests, but
+     this time using the binaries in their final installed location.
+     This target does not install anything.  Running this target as a
+     regular user, particularly if the prior `make install' required
+     root privileges, verifies that the installation completed
+     correctly.
+
+  6. You can remove the program binaries and object files from the
      source code directory by typing `make clean'.  To also remove the
      files that `configure' created (so you can compile the package for
      a different kind of computer), type `make distclean'.  There is
@@ -67,8 +83,15 @@ The simplest way to compile this package is:
      all sorts of other programs in order to regenerate files that came
      with the distribution.
 
-  6. Often, you can also type `make uninstall' to remove the installed
-     files again.
+  7. Often, you can also type `make uninstall' to remove the installed
+     files again.  In practice, not all packages have tested that
+     uninstallation works correctly, even though it is required by the
+     GNU Coding Standards.
+
+  8. Some packages, particularly those that use Automake, provide `make
+     distcheck', which can by used by developers to test that all other
+     targets like `make install' and `make uninstall' work correctly.
+     This target is generally not run by end users.
 
 Compilers and Options
 =====================
@@ -93,7 +116,8 @@ same time, by placing the object files for each architecture in their
 own directory.  To do this, you can use GNU `make'.  `cd' to the
 directory where you want the object files and executables to go and run
 the `configure' script.  `configure' automatically checks for the
-source code in the directory that `configure' is in and in `..'.
+source code in the directory that `configure' is in and in `..'.  This
+is known as a "VPATH" build.
 
    With a non-GNU `make', it is safer to compile the package for one
 architecture at a time in the source code directory.  After you have
@@ -120,7 +144,8 @@ Installation Names
    By default, `make install' installs the package's commands under
 `/usr/local/bin', include files under `/usr/local/include', etc.  You
 can specify an installation prefix other than `/usr/local' by giving
-`configure' the option `--prefix=PREFIX'.
+`configure' the option `--prefix=PREFIX', where PREFIX must be an
+absolute file name.
 
    You can specify separate installation prefixes for
 architecture-specific files and architecture-independent files.  If you
@@ -131,15 +156,46 @@ Documentation and other data files still use the regular prefix.
    In addition, if you use an unusual directory layout you can give
 options like `--bindir=DIR' to specify different values for particular
 kinds of files.  Run `configure --help' for a list of the directories
-you can set and what kinds of files go in them.
+you can set and what kinds of files go in them.  In general, the
+default for these options is expressed in terms of `${prefix}', so that
+specifying just `--prefix' will affect all of the other directory
+specifications that were not explicitly provided.
+
+   The most portable way to affect installation locations is to pass the
+correct locations to `configure'; however, many packages provide one or
+both of the following shortcuts of passing variable assignments to the
+`make install' command line to change installation locations without
+having to reconfigure or recompile.
+
+   The first method involves providing an override variable for each
+affected directory.  For example, `make install
+prefix=/alternate/directory' will choose an alternate location for all
+directory configuration variables that were expressed in terms of
+`${prefix}'.  Any directories that were specified during `configure',
+but not in terms of `${prefix}', must each be overridden at install
+time for the entire installation to be relocated.  The approach of
+makefile variable overrides for each directory variable is required by
+the GNU Coding Standards, and ideally causes no recompilation.
+However, some platforms have known limitations with the semantics of
+shared libraries that end up requiring recompilation when using this
+method, particularly noticeable in packages that use GNU Libtool.
+
+   The second method involves providing the `DESTDIR' variable.  For
+example, `make install DESTDIR=/alternate/directory' will prepend
+`/alternate/directory' before all installation names.  The approach of
+`DESTDIR' overrides is not required by the GNU Coding Standards, and
+does not work on platforms that have drive letters.  On the other hand,
+it does better at avoiding recompilation issues, and works well even
+when some directory options were not specified in terms of `${prefix}'
+at `configure' time.
+
+Optional Features
+=================
 
    If the package supports it, you can cause programs to be installed
 with an extra prefix or suffix on their names by giving `configure' the
 option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
 
-Optional Features
-=================
-
    Some packages pay attention to `--enable-FEATURE' options to
 `configure', where FEATURE indicates an optional part of the package.
 They may also pay attention to `--with-PACKAGE' options, where PACKAGE
@@ -152,6 +208,13 @@ find the X include and library files automatically, but if it doesn't,
 you can use the `configure' options `--x-includes=DIR' and
 `--x-libraries=DIR' to specify their locations.
 
+   Some packages offer the ability to configure how verbose the
+execution of `make' will be.  For these packages, running `./configure
+--enable-silent-rules' sets the default to minimal output, which can be
+overridden with `make V=1'; while running `./configure
+--disable-silent-rules' sets the default to verbose, which can be
+overridden with `make V=0'.
+
 Particular systems
 ==================
 
@@ -288,7 +351,7 @@ operates.
      `configure' can determine that directory automatically.
 
 `--prefix=DIR'
-     Use DIR as the installation prefix.  *Note Installation Names::
+     Use DIR as the installation prefix.  *note Installation Names::
      for more details, including other options available for fine-tuning
      the installation locations.
 
diff --git a/Makefile.am b/Makefile.am
index fa225bb..7827b2d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,9 +4,15 @@ if BUILD_PANEL_PLUGINS
 plugins_dir = panel-plugins
 endif
 
+if ENABLE_HAL
+libhal_dir = libhal
+endif
+
 SUBDIRS =        	\
 	data		\
-	libxfpm		\
+	libdbus		\
+	$(libhal_dir)	\
+	common		\
 	src		\
 	settings	\
 	$(plugins_dir)	\
diff --git a/README b/README
index d2746da..54a79b6 100644
--- a/README
+++ b/README
@@ -15,11 +15,14 @@ Xfce Power Manager depends on the following packages:
  - Glib 2.16 or above.
  - DBus 0.60 or above.
  - DBus glib 0.70 or above.
- - libxfcegui4 4.6.0 or above.
+ - libxfce4ui 4.7.0 or above.
  - libxfce4util 4.6.0 or above
  - libnotify 0.4.1 or above.
  - xfconf 4.6.0 or above.
  - libxfce4panel 4.6.0 or above (for the panel plugins).
+ - Xrandr 1.2.0 or above.
+ - Polkit 0.91 or above (optional but recommended).
+ - Consolekit (optional but recommended).
  - DPMS X extension ( for DPMS support);
 
  - HAL daemon version 0.5.6 or above is needed.
diff --git a/TODO b/TODO
index 00e9a83..7b97d07 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,4 @@
-* : Solve the problem of possible multiple sleep requests between us and the session manager.
-
-* : Probably provide a PermissionDenied error on the inhibit interface?
-
-* : Updating the documentations.
+* Use devkit-power device statistics.
+* Use devkit-power QoS interface.
+* Probably provide a PermissionDenied error on the inhibit interface?
+* Update the documentations.
diff --git a/common/Makefile.am b/common/Makefile.am
new file mode 100644
index 0000000..fd5d98c
--- /dev/null
+++ b/common/Makefile.am
@@ -0,0 +1,27 @@
+noinst_LTLIBRARIES =                    \
+        libxfpmcommon.la
+
+libxfpmcommon_la_SOURCES =              \
+	xfpm-common.c			\
+	xfpm-common.h			\
+	xfpm-brightness.c		\
+	xfpm-brightness.h		\
+	xfpm-debug.c			\
+	xfpm-debug.h			\
+	xfpm-icons.h
+
+libxfpmcommon_la_CFLAGS =               \
+	-I$(top_srcdir) 	        \
+	$(GTK_CFLAGS)                   \
+	$(GLIB_CFLAGS)                  \
+	$(LIBXFCE4UTIL_CFLAGS)
+
+if ENABLE_HAL
+
+libxfpmcommon_la_CFLAGS += 		\
+	$(DBUS_GLIB_CFLAGS)		\
+	-I$(top_srcdir)/libhal
+
+libxfpmcommon_la_LIBADD =		\
+	$(top_builddir)/libhal/libxfpmhal.la
+endif
\ No newline at end of file
diff --git a/common/xfpm-brightness.c b/common/xfpm-brightness.c
new file mode 100644
index 0000000..887aeb1
--- /dev/null
+++ b/common/xfpm-brightness.c
@@ -0,0 +1,685 @@
+/*
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <gtk/gtk.h>
+#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
+
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/Xrandr.h>
+
+#include <libxfce4util/libxfce4util.h>
+
+#ifdef WITH_HAL
+#include <dbus/dbus-glib.h>
+#include "libhal/hal-manager.h"
+#include "libhal/hal-device.h"
+#endif
+
+#include "xfpm-brightness.h"
+#include "xfpm-debug.h"
+
+static void xfpm_brightness_finalize   (GObject *object);
+
+#define XFPM_BRIGHTNESS_GET_PRIVATE(o) \
+(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_BRIGHTNESS, XfpmBrightnessPrivate))
+
+struct XfpmBrightnessPrivate
+{
+    XRRScreenResources *resource;
+    Atom		backlight;
+    gint 		output;
+    gboolean		xrandr_has_hw;
+    
+    gint		max_level;
+    gint		current_level;
+    gint		min_level;
+    gint		step;
+    
+#ifdef WITH_HAL
+    HalManager	       *manager;
+    DBusGConnection    *bus;
+    DBusGProxy         *hal_proxy;
+    gboolean		hal_brightness_in_hw;
+    gboolean		hal_hw_found;
+    gboolean		connected;
+#endif
+};
+
+G_DEFINE_TYPE (XfpmBrightness, xfpm_brightness, G_TYPE_OBJECT)
+
+static gboolean
+xfpm_brightness_xrand_get_limit (XfpmBrightness *brightness, RROutput output, gint *min, gint *max)
+{
+    XRRPropertyInfo *info;
+    gboolean ret = TRUE;
+
+    info = XRRQueryOutputProperty (GDK_DISPLAY (), output, brightness->priv->backlight);
+    
+    if (info == NULL) 
+    {
+	g_warning ("could not get output property");
+	return FALSE;
+    }
+    
+    if (!info->range || info->num_values != 2) 
+    {
+	g_warning ("no range found");
+	ret = FALSE;
+	goto out;
+    }
+    
+    *min = info->values[0];
+    *max = info->values[1];
+    
+out:
+    XFree (info);
+    return ret;
+}
+
+static gboolean
+xfpm_brightness_xrandr_get_level (XfpmBrightness *brightness, RROutput output, gint *current)
+{
+    unsigned long nitems;
+    unsigned long bytes_after;
+    gint *prop;
+    Atom actual_type;
+    int actual_format;
+    gboolean ret = FALSE;
+
+    if (XRRGetOutputProperty (GDK_DISPLAY (), output, brightness->priv->backlight,
+			      0, 4, False, False, None,
+			      &actual_type, &actual_format,
+			      &nitems, &bytes_after, ((unsigned char **)&prop)) != Success) 
+    {
+	g_warning ("failed to get property");
+	return FALSE;
+    }
+    
+    if (actual_type == XA_INTEGER && nitems == 1 && actual_format == 32) 
+    {
+	memcpy (current, prop, sizeof (gint));
+	ret = TRUE;
+    }
+    
+    XFree (prop);
+    
+    return ret;
+}
+
+static gboolean
+xfpm_brightness_xrandr_set_level (XfpmBrightness *brightness, RROutput output, gint level)
+{
+    gboolean ret = TRUE;
+
+    gdk_error_trap_push ();
+    XRRChangeOutputProperty (GDK_DISPLAY (), output, brightness->priv->backlight, XA_INTEGER, 32,
+			     PropModeReplace, (unsigned char *) &level, 1);
+			     
+    XFlush (GDK_DISPLAY ());
+    gdk_flush ();
+    
+    if ( gdk_error_trap_pop () ) 
+    {
+	    g_warning ("failed to XRRChangeOutputProperty for brightness %i", level);
+	    ret = FALSE;
+    }
+    
+    return ret;
+}
+
+static gboolean
+xfpm_brightness_setup_xrandr (XfpmBrightness *brightness)
+{
+    GdkScreen *screen;
+    XRROutputInfo *info;
+    Window window;
+    gint major, minor, screen_num;
+    gint min, max;
+    gboolean ret = FALSE;
+    gint i;
+    
+    if ( !XRRQueryVersion (GDK_DISPLAY (), &major, &minor) )
+    {
+	g_warning ("No XRANDR extension found");
+	return FALSE;
+    }
+    
+    brightness->priv->backlight = XInternAtom (GDK_DISPLAY (), "BACKLIGHT", True);
+    
+    if (brightness->priv->backlight == None) 
+    {
+	g_warning ("No outputs have backlight property");
+	return FALSE;
+    }
+	
+    screen = gdk_display_get_default_screen (gdk_display_get_default ());
+    
+    screen_num = gdk_screen_get_number (screen);
+    
+    window = RootWindow (GDK_DISPLAY (), screen_num);
+    
+#if (RANDR_MAJOR == 1 && RANDR_MINOR >=3 )
+    brightness->priv->resource = XRRGetScreenResourcesCurrent (GDK_DISPLAY (), window);
+#else
+    brightness->priv->resource = XRRGetScreenResources (GDK_DISPLAY (), window);
+#endif
+
+    for ( i = 0; i < brightness->priv->resource->noutput; i++)
+    {
+	info = XRRGetOutputInfo (GDK_DISPLAY (), brightness->priv->resource, brightness->priv->resource->outputs[i]);
+
+	if ( g_str_has_prefix (info->name, "LVDS") )
+	{
+	    
+	    if ( xfpm_brightness_xrand_get_limit (brightness, brightness->priv->resource->outputs[i], &min, &max) &&
+		 min != max )
+	    {
+		ret = TRUE;
+		brightness->priv->output = brightness->priv->resource->outputs[i];
+		brightness->priv->step =  max <= 20 ? 1 : max / 10;
+	    }
+	    
+	}
+	XRRFreeOutputInfo (info);
+    }
+    
+    return ret;
+}
+
+static gboolean
+xfpm_brightness_xrand_up (XfpmBrightness *brightness, gint *new_level)
+{
+    gint hw_level;
+    gboolean ret = FALSE;
+    gint set_level;
+    
+    ret = xfpm_brightness_xrandr_get_level (brightness, brightness->priv->output, &hw_level);
+    
+    if ( !ret )
+	return FALSE;
+
+    if ( hw_level == brightness->priv->max_level )
+    {
+	*new_level = brightness->priv->max_level;
+	return TRUE;
+    }
+	
+    set_level = MIN (hw_level + brightness->priv->step, brightness->priv->max_level );
+	
+    g_warn_if_fail (xfpm_brightness_xrandr_set_level (brightness, brightness->priv->output, set_level));
+	
+    ret = xfpm_brightness_xrandr_get_level (brightness, brightness->priv->output, new_level);
+    
+    if ( !ret )
+    {
+	g_warning ("xfpm_brightness_xrand_up failed for %d", set_level);
+	return FALSE;
+    }
+	
+    /* Nothing changed in the hardware*/
+    if ( *new_level == hw_level )
+    {
+	g_warning ("xfpm_brightness_xrand_up did not change the hw level to %d", set_level);
+	return FALSE;
+    }
+    
+    return TRUE;
+}
+
+static gboolean
+xfpm_brightness_xrand_down (XfpmBrightness *brightness, gint *new_level)
+{
+    gint hw_level;
+    gboolean ret;
+    gint set_level;
+    
+    ret = xfpm_brightness_xrandr_get_level (brightness, brightness->priv->output, &hw_level);
+    
+    if ( !ret )
+	return FALSE;
+    
+    if ( hw_level == brightness->priv->min_level )
+    {
+	*new_level = brightness->priv->min_level;
+	return TRUE;
+    }
+    
+    set_level = MAX (hw_level - brightness->priv->step, brightness->priv->min_level);
+    
+    g_warn_if_fail (xfpm_brightness_xrandr_set_level (brightness, brightness->priv->output, set_level));
+	
+    ret = xfpm_brightness_xrandr_get_level (brightness, brightness->priv->output, new_level);
+    
+    if ( !ret )
+    {
+	g_warning ("xfpm_brightness_xrand_down failed for %d", set_level);
+	return FALSE;
+    }
+    
+    /* Nothing changed in the hardware*/
+    if ( *new_level == hw_level )
+    {
+	g_warning ("xfpm_brightness_xrand_down did not change the hw level to %d", set_level);
+	return FALSE;
+    }
+    
+    return TRUE;
+}
+
+/*
+ * Begin HAL optional brightness code. 
+ * 
+ */
+
+#ifdef WITH_HAL
+static gboolean
+xfpm_brightness_hal_get_level (XfpmBrightness *brg, gint *level)
+{
+    GError *error = NULL;
+    gboolean ret = FALSE;
+    
+    if (!brg->priv->connected)
+	return FALSE;
+    
+    ret = dbus_g_proxy_call (brg->priv->hal_proxy, "GetBrightness", &error,
+	 		     G_TYPE_INVALID,
+			     G_TYPE_INT, level,
+			     G_TYPE_INVALID);
+
+    if (error)
+    {
+	g_warning ("GetBrightness failed : %s\n", error->message);
+	g_error_free (error);
+    }
+    
+    return ret;
+}
+
+static gboolean
+xfpm_brightness_hal_set_level (XfpmBrightness *brg, gint level)
+{
+    GError *error = NULL;
+    gboolean ret = FALSE;
+    gint dummy;
+    
+    if (!brg->priv->connected)
+	return FALSE;
+    
+    TRACE ("Setting level %d", level);
+    
+    ret = dbus_g_proxy_call (brg->priv->hal_proxy, "SetBrightness", &error,
+			     G_TYPE_INT, level,
+			     G_TYPE_INVALID,
+			     G_TYPE_INT, &dummy, /* Just to avoid a warning! */
+			     G_TYPE_INVALID );
+		       
+    if ( error )
+    {
+	g_critical ("Error setting brightness level: %s\n", error->message);
+	g_error_free (error);
+	return FALSE;
+    }
+    
+    if (!ret)
+    {
+	g_warning ("SetBrightness failed\n");
+    }
+    
+    return TRUE;
+}
+
+
+static gboolean
+xfpm_brightness_hal_up (XfpmBrightness *brightness)
+{
+    gint hw_level;
+    gint set_level;
+    gboolean ret = TRUE;
+    
+    ret = xfpm_brightness_hal_get_level (brightness, &hw_level);
+    
+    if ( !ret )
+	return FALSE;
+	
+    if ( hw_level == brightness->priv->max_level )
+    {
+	return TRUE;
+    }
+    
+    set_level =  MIN (hw_level + brightness->priv->step, brightness->priv->max_level );
+    
+    ret = xfpm_brightness_hal_set_level (brightness, set_level);
+    
+    return ret;
+}
+
+static gboolean
+xfpm_brightness_hal_down (XfpmBrightness *brightness)
+{
+    gint hw_level;
+    gint set_level;
+    gboolean ret = TRUE;
+    
+    ret = xfpm_brightness_hal_get_level (brightness, &hw_level);
+    
+    if ( !ret )
+	return FALSE;
+
+    if ( hw_level == brightness->priv->min_level )
+	return TRUE;
+	
+    set_level = MAX (hw_level - brightness->priv->step, brightness->priv->min_level);
+    
+    ret = xfpm_brightness_hal_set_level (brightness, brightness->priv->min_level);
+    
+    return ret;
+}
+
+static void
+xfpm_brightness_hal_connection_changed_cb (HalManager *manager, gboolean connected, XfpmBrightness *brightness)
+{
+    brightness->priv->connected = connected;
+}
+
+static gboolean
+xfpm_brightness_setup_hal (XfpmBrightness *brightness)
+{
+    DBusGConnection *bus;
+    HalDevice *device;
+    gchar **udi = NULL;
+    
+    
+    if ( !brightness->priv->manager )
+    {
+	brightness->priv->manager = hal_manager_new ();
+	
+	g_signal_connect (brightness->priv->manager, "connection-changed",
+			  G_CALLBACK (xfpm_brightness_hal_connection_changed_cb), brightness);
+    }
+    brightness->priv->connected = hal_manager_get_is_connected (brightness->priv->manager);
+		      
+    udi = hal_manager_find_device_by_capability (brightness->priv->manager, "laptop_panel");
+
+    if ( !udi || !udi[0])
+    {
+    	return FALSE;
+    }
+    
+    device = hal_device_new ();
+    hal_device_set_udi (device, udi[0]);
+    
+    brightness->priv->max_level = hal_device_get_property_int (device, "laptop_panel.num_levels") - 1;
+    brightness->priv->step = brightness->priv->max_level <= 20 ? 1 : brightness->priv->max_level / 20;
+    brightness->priv->min_level = brightness->priv->step;
+    brightness->priv->hal_hw_found = TRUE;
+    
+    if ( hal_device_has_key (device, "laptop_panel.brightness_in_hardware") )
+	brightness->priv->hal_brightness_in_hw = hal_device_get_property_bool (device ,"laptop_panel.brightness_in_hardware");
+	
+    TRACE ("laptop_panel.num_levels=%d\n", brightness->priv->max_level);
+    
+    g_object_unref (device);
+
+    bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
+    
+    brightness->priv->hal_proxy = dbus_g_proxy_new_for_name (bus,
+							     "org.freedesktop.Hal",
+							     udi[0],
+							     "org.freedesktop.Hal.Device.LaptopPanel");
+     
+    if ( !brightness->priv->hal_proxy )
+    {
+	g_warning ("Unable to get proxy for device %s\n", udi[0]);
+	brightness->priv->hal_hw_found = FALSE;
+    }
+    
+    hal_manager_free_string_array (udi);
+    brightness->priv->bus = bus;
+    
+    return brightness->priv->hal_hw_found;
+}
+#endif /* WITH_HAL*/
+
+static void
+xfpm_brightness_class_init (XfpmBrightnessClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    object_class->finalize = xfpm_brightness_finalize;
+
+    g_type_class_add_private (klass, sizeof (XfpmBrightnessPrivate));
+}
+
+static void
+xfpm_brightness_init (XfpmBrightness *brightness)
+{
+    brightness->priv = XFPM_BRIGHTNESS_GET_PRIVATE (brightness);
+    
+    brightness->priv->resource = NULL;
+    brightness->priv->xrandr_has_hw = FALSE;
+    brightness->priv->max_level = 0;
+    brightness->priv->min_level = 0;
+    brightness->priv->current_level = 0;
+    brightness->priv->output = 0;
+    brightness->priv->step = 0;
+    
+#ifdef WITH_HAL
+    brightness->priv->bus = NULL;
+    brightness->priv->hal_proxy = NULL;
+    brightness->priv->hal_brightness_in_hw = FALSE;
+    brightness->priv->hal_hw_found = FALSE;
+    brightness->priv->manager = NULL;
+#endif
+}
+
+static void
+xfpm_brightness_free_data (XfpmBrightness *brightness)
+{
+    if ( brightness->priv->resource )
+	XRRFreeScreenResources (brightness->priv->resource);
+
+#ifdef WITH_HAL
+    if ( brightness->priv->bus )
+	dbus_g_connection_unref (brightness->priv->bus);
+	
+    if ( brightness->priv->hal_proxy )
+	g_object_unref (brightness->priv->hal_proxy);
+#endif
+}
+
+static void
+xfpm_brightness_finalize (GObject *object)
+{
+    XfpmBrightness *brightness;
+
+    brightness = XFPM_BRIGHTNESS (object);
+
+    xfpm_brightness_free_data (brightness);
+
+#ifdef WITH_HAL
+    if ( brightness->priv->manager )
+	g_object_unref (brightness->priv->manager);
+#endif
+
+    G_OBJECT_CLASS (xfpm_brightness_parent_class)->finalize (object);
+}
+
+XfpmBrightness *
+xfpm_brightness_new (void)
+{
+    XfpmBrightness *brightness = NULL;
+    brightness = g_object_new (XFPM_TYPE_BRIGHTNESS, NULL);
+    return brightness;
+}
+
+gboolean
+xfpm_brightness_setup (XfpmBrightness *brightness)
+{
+    xfpm_brightness_free_data (brightness);
+    brightness->priv->xrandr_has_hw = xfpm_brightness_setup_xrandr (brightness);
+
+    if ( brightness->priv->xrandr_has_hw )
+    {
+	xfpm_brightness_xrand_get_limit (brightness,
+					 brightness->priv->output, 
+					 &brightness->priv->min_level, 
+					 &brightness->priv->max_level);
+	g_debug ("Brightness controlled by xrandr, min_level=%d max_level=%d", 
+		 brightness->priv->min_level, 
+		 brightness->priv->max_level);
+		 
+    }
+#ifdef WITH_HAL    
+    else if ( !brightness->priv->xrandr_has_hw )
+    {
+	g_debug ("Unable to control brightness via xrandr, trying to use HAL");
+	if ( xfpm_brightness_setup_hal (brightness) )
+	    return TRUE;
+    }
+#endif
+    
+    return brightness->priv->xrandr_has_hw;
+}
+
+gboolean xfpm_brightness_up (XfpmBrightness *brightness, gint *new_level)
+{
+    gboolean ret = FALSE;
+    
+    if ( brightness->priv->xrandr_has_hw )
+    {
+	ret = xfpm_brightness_xrand_up (brightness, new_level);
+    }	
+#ifdef WITH_HAL
+    else if ( brightness->priv->hal_hw_found )
+    {
+	ret = xfpm_brightness_hal_up (brightness);
+	if ( ret )
+	    ret = xfpm_brightness_hal_get_level (brightness, new_level);
+    }
+#endif
+    return ret;
+}
+
+gboolean xfpm_brightness_down (XfpmBrightness *brightness, gint *new_level)
+{
+    gboolean ret = FALSE;
+    
+    if ( brightness->priv->xrandr_has_hw )
+    {
+	ret = xfpm_brightness_xrand_down (brightness, new_level);
+	if ( ret )
+	    ret = xfpm_brightness_xrandr_get_level (brightness, brightness->priv->output, new_level);
+    }	
+#ifdef WITH_HAL
+    else if ( brightness->priv->hal_hw_found )
+    {
+	ret = xfpm_brightness_hal_down (brightness);
+	if ( ret )
+	    ret = xfpm_brightness_hal_get_level (brightness, new_level);
+    }
+#endif
+    return ret;
+}
+
+gboolean xfpm_brightness_has_hw (XfpmBrightness *brightness)
+{
+#ifdef WITH_HAL
+    if ( !brightness->priv->xrandr_has_hw )
+	return brightness->priv->hal_hw_found;
+#endif
+    
+    return brightness->priv->xrandr_has_hw;
+}
+
+gint xfpm_brightness_get_max_level (XfpmBrightness *brightness)
+{
+    return brightness->priv->max_level;
+}
+
+gboolean xfpm_brightness_get_level	(XfpmBrightness *brightness, gint *level)
+{
+    gboolean ret = FALSE;
+    
+    if ( brightness->priv->xrandr_has_hw )
+	ret = xfpm_brightness_xrandr_get_level (brightness, brightness->priv->output, level);
+#ifdef WITH_HAL
+    else if ( brightness->priv->hal_hw_found )
+	ret = xfpm_brightness_hal_get_level (brightness, level);
+#endif
+
+    return ret;
+}
+
+gboolean xfpm_brightness_set_level (XfpmBrightness *brightness, gint level)
+{
+    gboolean ret = FALSE;
+    
+    if (brightness->priv->xrandr_has_hw )
+	ret = xfpm_brightness_xrandr_set_level (brightness, brightness->priv->output, level);
+#ifdef WITH_HAL
+    else if ( brightness->priv->hal_hw_found )
+	ret = xfpm_brightness_hal_set_level (brightness, level);
+#endif
+    
+    return ret;
+}
+
+gboolean xfpm_brightness_dim_down (XfpmBrightness *brightness)
+{
+    gboolean ret = FALSE;
+    
+    if (brightness->priv->xrandr_has_hw )
+	ret = xfpm_brightness_xrandr_set_level (brightness, brightness->priv->output, brightness->priv->min_level);
+#ifdef WITH_HAL
+    else if ( brightness->priv->hal_hw_found )
+	ret = xfpm_brightness_hal_set_level (brightness, brightness->priv->min_level);
+#endif
+    
+    return ret;
+}
+
+XfpmBrightnessControl xfpm_brightness_get_control (XfpmBrightness *brightness)
+{
+    if ( brightness->priv->xrandr_has_hw )
+	return XFPM_BRIGHTNESS_CONTROL_XRANDR;
+#ifdef WITH_HAL
+    else if ( brightness->priv->hal_hw_found )
+	return XFPM_BRIGHTNESS_CONTROL_HAL;
+#endif
+    return XFPM_BRIGHTNESS_CONTROL_UNKNOWN;
+}
+
+gboolean xfpm_brightness_in_hw	(XfpmBrightness *brightness)
+{
+#ifdef WITH_HAL
+    return brightness->priv->hal_brightness_in_hw;
+#endif
+    return FALSE;
+}
diff --git a/common/xfpm-brightness.h b/common/xfpm-brightness.h
new file mode 100644
index 0000000..4fa37d7
--- /dev/null
+++ b/common/xfpm-brightness.h
@@ -0,0 +1,85 @@
+/*
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __XFPM_BRIGHTNESS_H
+#define __XFPM_BRIGHTNESS_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define XFPM_TYPE_BRIGHTNESS        (xfpm_brightness_get_type () )
+#define XFPM_BRIGHTNESS(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_BRIGHTNESS, XfpmBrightness))
+#define XFPM_IS_BRIGHTNESS(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_BRIGHTNESS))
+
+typedef enum
+{
+    XFPM_BRIGHTNESS_CONTROL_UNKNOWN,
+    XFPM_BRIGHTNESS_CONTROL_XRANDR,
+    XFPM_BRIGHTNESS_CONTROL_HAL
+    
+} XfpmBrightnessControl;
+
+typedef struct XfpmBrightnessPrivate XfpmBrightnessPrivate;
+
+typedef struct
+{
+    GObject         		parent;
+    XfpmBrightnessPrivate      *priv;
+    
+} XfpmBrightness;
+
+typedef struct
+{
+    GObjectClass 		parent_class;
+    
+} XfpmBrightnessClass;
+
+GType        			xfpm_brightness_get_type        (void) G_GNUC_CONST;
+
+XfpmBrightness       	       *xfpm_brightness_new             (void);
+
+gboolean			xfpm_brightness_setup 		(XfpmBrightness *brightness);
+
+gboolean			xfpm_brightness_up		(XfpmBrightness *brightness,
+								 gint *new_level);
+
+gboolean			xfpm_brightness_down		(XfpmBrightness *brightness,
+								 gint *new_level);
+
+gboolean			xfpm_brightness_has_hw 		(XfpmBrightness *brightness);
+
+gint 				xfpm_brightness_get_max_level   (XfpmBrightness *brightness);
+
+gboolean			xfpm_brightness_get_level	(XfpmBrightness *brightness,
+								 gint *level);
+
+gboolean			xfpm_brightness_set_level	(XfpmBrightness *brightness,
+								 gint level);
+
+gboolean			xfpm_brightness_dim_down	(XfpmBrightness *brightness);
+
+XfpmBrightnessControl		xfpm_brightness_get_control	(XfpmBrightness *brightness);
+
+gboolean			xfpm_brightness_in_hw		(XfpmBrightness *brightness);
+
+G_END_DECLS
+
+#endif /* __XFPM_BRIGHTNESS_H */
diff --git a/common/xfpm-common.c b/common/xfpm-common.c
new file mode 100644
index 0000000..cde612a
--- /dev/null
+++ b/common/xfpm-common.c
@@ -0,0 +1,216 @@
+/*
+ * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <glib.h>
+
+#include <libxfce4util/libxfce4util.h>
+
+#include "xfpm-common.h"
+
+const gchar *xfpm_bool_to_string (gboolean value)
+{
+    if ( value == TRUE ) return "TRUE";
+    else 		 return "FALSE";
+}
+
+gboolean xfpm_string_to_bool (const gchar *string)
+{
+    if ( !g_strcmp0 (string, "TRUE") ) return TRUE;
+    else if ( !g_strcmp0 (string, "FALSE") ) return FALSE;
+    
+    return FALSE;
+}
+
+GtkBuilder *xfpm_builder_new_from_string (const gchar *ui, GError **error)
+{
+    GtkBuilder *builder;
+
+    builder = gtk_builder_new ();
+    
+    gtk_builder_add_from_string (GTK_BUILDER (builder),
+                                 ui,
+                                 -1,
+                                 error);
+    
+    return builder;
+}
+
+static void
+xfpm_link_browser (GtkAboutDialog *about, const gchar *link, gpointer data)
+{
+    gchar *cmd;
+    
+    cmd = g_strdup_printf ("%s %s","xdg-open", link);
+    
+    if ( !g_spawn_command_line_async (cmd, NULL) )
+    {
+	g_free (cmd);
+	cmd = g_strdup_printf ("%s %s","xfbrowser4", link);
+	g_spawn_command_line_async (cmd, NULL);
+    }
+    g_free (cmd);
+	
+}
+
+static void
+xfpm_link_mailto (GtkAboutDialog *about, const gchar *link, gpointer data)
+{
+    gchar *cmd = g_strdup_printf( "%s %s", "xdg-email", link);
+
+    g_spawn_command_line_async (cmd, NULL);
+    
+    g_free (cmd);
+}
+	
+void       
+xfpm_lock_screen (void)
+{
+    gboolean ret = g_spawn_command_line_async ("xflock4", NULL);
+    
+    if ( !ret )
+    {
+        g_spawn_command_line_async ("gnome-screensaver-command -l", NULL);
+    }
+    
+    if ( !ret )
+    {
+        /* this should be the default*/
+        ret = g_spawn_command_line_async ("xdg-screensaver lock", NULL);
+    }
+    
+    if ( !ret )
+    {
+        ret = g_spawn_command_line_async ("xscreensaver-command -lock", NULL);
+    }
+    
+    if ( !ret )
+    {
+        g_critical ("Connot lock screen\n");
+    }
+}
+
+void       
+xfpm_preferences (void) 
+{
+    g_spawn_command_line_async ("xfce4-power-manager-settings", NULL);
+}
+
+void       
+xfpm_help (void)
+{
+    g_spawn_command_line_async ("xfhelp4 xfce4-power-manager.html", NULL);
+}
+
+void
+xfpm_quit (void)
+{
+    g_spawn_command_line_async ("xfce4-power-manager -q", NULL);
+}
+
+void       
+xfpm_about (GtkWidget *widget, gpointer data)
+{
+    gchar *package = (gchar *)data;
+    
+    const gchar* authors[3] = 
+    {
+	"Ali Abdallah <aliov at xfce.org>", 
+	 NULL
+    };
+							    
+    static const gchar *documenters[] =
+    {
+	"Ali Abdallah <aliov at xfce.org>",
+	NULL,
+    };
+    
+
+    gtk_about_dialog_set_url_hook (xfpm_link_browser, NULL, NULL);
+    gtk_about_dialog_set_email_hook (xfpm_link_mailto, NULL, NULL);
+    
+    gtk_show_about_dialog (NULL,
+		     "authors", authors,
+		     "copyright", "Copyright \302\251 2008-2009 Ali Abdallah",
+		     "destroy-with-parent", TRUE,
+		     "documenters", documenters,
+		     "license", XFCE_LICENSE_GPL,
+		     "name", package,
+		     "translator-credits", _("translator-credits"),
+		     "version", PACKAGE_VERSION,
+		     "website", "http://goodies.xfce.org",
+		     NULL);
+						 
+}
+
+gboolean xfpm_is_multihead_connected (void)
+{
+    GdkDisplay *dpy;
+    GdkScreen *screen;
+    gint nscreen;
+    gint nmonitor;
+    
+    dpy = gdk_display_get_default ();
+    
+    nscreen = gdk_display_get_n_screens (dpy);
+    
+    if ( nscreen == 1 )
+    {
+	screen = gdk_display_get_screen (dpy, 0);
+	if ( screen )
+	{
+	    nmonitor = gdk_screen_get_n_monitors (screen);
+	    if ( nmonitor > 1 )
+	    {
+		g_debug ("Multiple monitor connected");
+		return TRUE; 
+	    }
+	    else
+		return FALSE;
+	}
+    }
+    else if ( nscreen > 1 )
+    {
+	g_debug ("Multiple screen connected");
+	return TRUE;
+    }
+    
+    return FALSE;
+}
+
+GdkPixbuf *xfpm_icon_load (const gchar *icon_name, gint size)
+{
+    GdkPixbuf *pix = NULL;
+    GError *error = NULL;
+    
+    pix = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), 
+				    icon_name, 
+				    size,
+				    GTK_ICON_LOOKUP_USE_BUILTIN,
+				    &error);
+				    
+    if ( error )
+    {
+	g_warning ("Unable to load icon : %s : %s", icon_name, error->message);
+	g_error_free (error);
+    }
+    
+    return pix;
+}
+
diff --git a/common/xfpm-common.h b/common/xfpm-common.h
new file mode 100644
index 0000000..80f47cd
--- /dev/null
+++ b/common/xfpm-common.h
@@ -0,0 +1,58 @@
+/*
+ * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __XFPM_COMMON_H
+#define __XFPM_COMMON_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+GdkPixbuf      *xfpm_icon_load			(const gchar *icon_name,
+						 gint size);
+
+const gchar    *xfpm_bool_to_string     	(gboolean value) G_GNUC_PURE;
+
+gboolean        xfpm_string_to_bool     	(const gchar *string) G_GNUC_PURE;
+
+GtkBuilder     *xfpm_builder_new_from_string   	(const gchar *file,
+						 GError **error);
+
+void       	xfpm_lock_screen  		(void);
+
+void       	xfpm_preferences		(void);
+
+void       	xfpm_help			(void);
+
+void            xfpm_quit                       (void);
+
+void       	xfpm_about			(GtkWidget *widget, 
+						 gpointer data);
+
+gboolean	xfpm_is_multihead_connected	(void);
+
+G_END_DECLS
+
+#endif /* XFPM_COMMON_H */
diff --git a/common/xfpm-debug.c b/common/xfpm-debug.c
new file mode 100644
index 0000000..c0956b2
--- /dev/null
+++ b/common/xfpm-debug.c
@@ -0,0 +1,109 @@
+/*
+ * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include <glib-object.h>
+#include <glib/gprintf.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include <unistd.h>
+
+#include "xfpm-debug.h"
+
+static gboolean enable_debug = FALSE;
+
+#if defined(G_HAVE_ISO_VARARGS)
+
+void
+xfpm_debug (const char *func, const char *file, int line, const char *format, ...)
+{
+    va_list args;
+    
+    if ( !enable_debug )
+	return;
+
+    va_start (args, format);
+
+    fprintf (stdout, "TRACE[%s:%d] %s(): ", file, line, func);
+    vfprintf (stdout, format, args);
+    fprintf (stdout, "\n");
+    
+    va_end (args);
+
+}
+
+void
+xfpm_warn (const char *func, const char *file, int line, const char *format, ...)
+{
+    va_list args;
+
+    if ( !enable_debug )
+	return;
+
+    va_start (args, format);
+    
+    fprintf(stdout, "TRACE[%s:%d] %s(): ", file, line, func);
+    fprintf (stdout, "***WARNING***: ");
+    vfprintf (stdout, format, args);
+    fprintf (stdout, "\n");
+    va_end (args);
+}
+
+void xfpm_debug_enum (const gchar *func, const gchar *file, gint line,
+		      gint v_enum, GType type, const gchar *format, ...)
+{
+    va_list args;
+    gchar *buffer;
+    
+    gchar *content = NULL;
+    GValue __value__ = { 0, };
+    
+    if ( !enable_debug )
+	return;
+    
+    g_value_init (&__value__, type);
+    g_value_set_enum (&__value__, v_enum);
+    
+    content = g_strdup_value_contents (&__value__);
+    
+    va_start (args, format);
+    g_vasprintf (&buffer, format, args);
+    va_end (args);
+	
+    fprintf(stdout, "TRACE[%s:%d] %s(): ", file, line, func);
+    fprintf(stdout, "%s: %s", buffer, content);
+    fprintf(stdout, "\n");
+    
+    g_value_unset (&__value__);	
+    g_free (content);
+    g_free (buffer);
+}
+
+#endif /*defined(G_HAVE_ISO_VARARGS)*/
+
+void xfpm_debug_init (gboolean debug)
+{
+    enable_debug = debug;
+}
diff --git a/common/xfpm-debug.h b/common/xfpm-debug.h
new file mode 100644
index 0000000..d18c970
--- /dev/null
+++ b/common/xfpm-debug.h
@@ -0,0 +1,77 @@
+/*
+ * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __XFPM_DEBUG_H
+#define __XFPM_DEBUG_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdarg.h>
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#if defined(G_HAVE_ISO_VARARGS)
+
+#define XFPM_DEBUG(...)\
+    xfpm_debug (__func__, __FILE__, __LINE__, __VA_ARGS__)
+
+#define XFPM_WARNING(...)\
+    xfpm_warn (__func__, __FILE__, __LINE__, __VA_ARGS__)
+
+#define XFPM_DEBUG_ENUM(_value, _type, ...)\
+    xfpm_debug_enum (__func__, __FILE__, __LINE__, _value, _type, __VA_ARGS__)
+
+					 
+void		xfpm_debug_enum         (const gchar *func,
+					 const gchar *file,
+					 gint line,
+					 gint v_enum,
+					 GType type,
+					 const gchar *format,
+					 ...) __attribute__((format (printf,6,7)));
+
+void		xfpm_debug 		(const char *func,
+					 const char *file,
+					 int line,
+					 const char *format,
+					 ...) __attribute__((format (printf,4,5)));
+
+void		xfpm_warn 		(const char *func,
+					 const char *file,
+					 int line,
+					 const char *format,
+					 ...) __attribute__((format (printf,4,5)));
+
+#else
+
+#define XFPM_DEBUG(...)
+#define XFPM_WARNING(...)
+#define XFPM_DEBUG_ENUM(_value, _type, ...)
+
+#endif
+
+void		xfpm_debug_init		(gboolean debug);
+
+G_END_DECLS
+
+#endif /* __XFPM_DEBUG_H */
diff --git a/common/xfpm-icons.h b/common/xfpm-icons.h
new file mode 100644
index 0000000..6d6bba9
--- /dev/null
+++ b/common/xfpm-icons.h
@@ -0,0 +1,53 @@
+/*
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __XFPM_ICONS_H
+#define __XFPM_ICONS_H
+
+G_BEGIN_DECLS
+
+#define XFPM_AC_ADAPTER_ICON			"xfpm-ac-adapter"
+
+#define XFPM_BATTERY_ICON			"battery"
+#define XFPM_UPS_ICON				"xfpm-ups-100"
+#define XFPM_KBD_ICON				"xfpm-keyboard-100"
+#define XFPM_MOUSE_ICON				"xfpm-mouse-100"
+#define XFPM_PHONE_ICON				"xfpm-phone-100"
+#define XFPM_PDA_ICON				"xfpm-pda-100"
+
+#define XFPM_PROCESSOR_ICON			"processor"
+
+#define XFPM_PRIMARY_ICON_PREFIX		"xfpm-primary-"
+#define XFPM_UPS_ICON_PREFIX			"xfpm-ups-"
+#define XFPM_MOUSE_ICON_PREFIX			"xfpm-mouse-"
+#define XFPM_KBD_ICON_PREFIX			"xfpm-keyboard-"
+#define XFPM_CAMERA_ICON_PREFIX			"xfpm-camera-"
+#define XFPM_PDA_ICON_PREFIX			"xfpm-pda-"
+#define XFPM_PHONE_ICON_PREFIX			"xfpm-phone-"
+#define XFPM_KBD_MOUSE_ICON_PREFIX		"xfpm-keyboard-mouse-"
+
+#define XFPM_DISPLAY_BRIGHTNESS_ICON	        "xfpm-brightness-lcd"
+#define XFPM_DISPLAY_BRIGHTNESS_INVALID_ICON	"xfpm-brightness-lcd-invalid" /* When no hw found */
+#define XFPM_HIBERNATE_ICON			"xfpm-hibernate"
+#define XFPM_SUSPEND_ICON			"xfpm-suspend"
+
+G_END_DECLS
+
+#endif
diff --git a/configure.ac.in b/configure.ac.in
index a2919d4..19b7f93 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -1,7 +1,7 @@
 m4_define([intltool_minimum_version], [0.31])
 m4_define([xfpm_version_major],  [0])
-m4_define([xfpm_version_minor],  [8])
-m4_define([xfpm_version_micro],  [4.1])
+m4_define([xfpm_version_minor],  [9])
+m4_define([xfpm_version_micro],  [90])
 m4_define([xfpm_version_build],  [@REVISION@])
 m4_define([xfpm_version_tag],[git])
 m4_define([xfpm_version], [xfpm_version_major().xfpm_version_minor().xfpm_version_micro()ifelse(xfpm_version_tag(), [git], [xfpm_version_tag().xfpm_version_build()], [xfpm_version_tag()])])
@@ -54,11 +54,13 @@ m4_define([dbus_minimum_version], [0.60])
 m4_define([dbus_glib_minimum_version], [0.70])
 
 m4_define([xfconf_minimum_version], [4.6.0])
-m4_define([libxfcegui4_minimum_version],[4.6.0])
+m4_define([libxfce4ui_minimum_version],[4.7.0])
 m4_define([libxfce4util_minimum_version],[4.6.0])
 m4_define([libxfce4panel_minimum_version],[4.6.0])
 
 m4_define([libnotify_minimum_version], [0.4.1])
+m4_define([xrandr_minimum_version], [1.2.0])
+m4_define([polkit_minimum_version], [0.91])
 
 XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [gtk_minimum_version])
 XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [glib_minimum_version])
@@ -68,9 +70,29 @@ XDT_CHECK_PACKAGE([GMODULE], [gmodule-2.0], [glib_minimum_version])
 XDT_CHECK_PACKAGE([DBUS], [dbus-1], [dbus_minimum_version])
 XDT_CHECK_PACKAGE([DBUS_GLIB], [dbus-glib-1], [dbus_glib_minimum_version])
 XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0],[xfconf_minimum_version])
-XDT_CHECK_PACKAGE([LIBXFCE4GUI], [libxfcegui4-1.0],[libxfcegui4_minimum_version])
+XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-1],[libxfce4ui_minimum_version])
 XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0],[libxfce4util_minimum_version])
 XDT_CHECK_PACKAGE([LIBNOTIFY],[libnotify], [libnotify_minimum_version])
+XDT_CHECK_PACKAGE([XRANDR],[xrandr], [xrandr_minimum_version])
+
+POLKIT="no"
+XDT_CHECK_OPTIONAL_PACKAGE([POLKIT], [polkit-gobject-1], [polkit_minimum_version], [polkit], [Polkit support])
+
+#=======================================================#
+#              Use HAL?			                #
+#=======================================================#
+AC_ARG_ENABLE([hal],
+	[AC_HELP_STRING([--disable-hal],
+		[Do not enable HAL (default=enabled)])],
+	[ac_cv_enable_hal=$enableval],
+	[ac_cv_enable_hal=yes])
+if test "x$ac_cv_enable_hal" = "xno"; then
+	enable_hal="no"
+else
+	enable_hal="yes"
+	AC_DEFINE(WITH_HAL, 1 , [HAL support])
+fi
+AM_CONDITIONAL([ENABLE_HAL], [test "x$enable_hal" = "xyes"])
 
 #=======================================================#
 #           Check for DPMS support                      #
@@ -168,13 +190,29 @@ XDT_FEATURE_DEBUG
 
 AC_OUTPUT([
 Makefile
-libxfpm/Makefile
+libdbus/Makefile
+libhal/Makefile
+common/Makefile
 src/Makefile
 settings/Makefile
 panel-plugins/Makefile
 panel-plugins/brightness/Makefile
 data/Makefile
 data/icons/Makefile
+data/icons/16x16/Makefile
+data/icons/16x16/actions/Makefile
+data/icons/16x16/status/Makefile
+data/icons/22x22/Makefile
+data/icons/22x22/actions/Makefile
+data/icons/22x22/status/Makefile
+data/icons/24x24/Makefile
+data/icons/24x24/actions/Makefile
+data/icons/24x24/status/Makefile
+data/icons/48x48/Makefile
+data/icons/48x48/actions/Makefile
+data/icons/48x48/status/Makefile
+data/icons/128x128/Makefile
+data/icons/128x128/devices/Makefile
 data/icons/scalable/Makefile
 data/icons/scalable/status/Makefile
 data/icons/scalable/actions/Makefile
@@ -191,12 +229,14 @@ echo "
  	    Xfce Power Manager $VERSION
 	======================================
  
-	prefix:			$prefix
-	xdg autostart:		$sysconfdir/xdg/autostart
-   	DPMS:   		$have_dpms
-	Network manager:	$ac_network_manager
-  	Build panel plugins:	$build_panel_plugins
-   	Debug:		   	$enable_debug
+	prefix:			${prefix}
+	xdg autostart:		${sysconfdir/xdg/autostart}
+	HAL:			${enable_hal}
+	POLKIT:			${POLKIT_FOUND}
+   	DPMS:   		${have_dpms}
+	Network manager:	${ac_network_manager}
+  	Build panel plugins:	${build_panel_plugins}
+   	Debug:		   	${enable_debug}
 --------------------------------------------------
 
 Configuration finished, type make to compile"
diff --git a/data/icons/128x128/Makefile.am b/data/icons/128x128/Makefile.am
new file mode 100644
index 0000000..2b751b1
--- /dev/null
+++ b/data/icons/128x128/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = devices
\ No newline at end of file
diff --git a/data/icons/128x128/devices/Makefile.am b/data/icons/128x128/devices/Makefile.am
new file mode 100644
index 0000000..c7c8670
--- /dev/null
+++ b/data/icons/128x128/devices/Makefile.am
@@ -0,0 +1,7 @@
+EXTRA_DIST =				\
+	$(Data_DATA)
+
+Datadir = $(datadir)/icons/hicolor/128x128/devices
+
+Data_DATA =				\
+	processor.png		
diff --git a/data/icons/128x128/devices/processor.png b/data/icons/128x128/devices/processor.png
new file mode 100644
index 0000000..db578b6
Binary files /dev/null and b/data/icons/128x128/devices/processor.png differ
diff --git a/data/icons/scalable/Makefile.am b/data/icons/16x16/Makefile.am
similarity index 100%
copy from data/icons/scalable/Makefile.am
copy to data/icons/16x16/Makefile.am
diff --git a/data/icons/16x16/actions/Makefile.am b/data/icons/16x16/actions/Makefile.am
new file mode 100644
index 0000000..11e3e35
--- /dev/null
+++ b/data/icons/16x16/actions/Makefile.am
@@ -0,0 +1,8 @@
+EXTRA_DIST =				\
+	$(Data_DATA)
+
+Datadir = $(datadir)/icons/hicolor/16x16/actions
+
+Data_DATA =				\
+	xfpm-hibernate.png		\
+	xfpm-suspend.png		
diff --git a/data/icons/16x16/actions/xfpm-hibernate.png b/data/icons/16x16/actions/xfpm-hibernate.png
new file mode 100644
index 0000000..36dde47
Binary files /dev/null and b/data/icons/16x16/actions/xfpm-hibernate.png differ
diff --git a/data/icons/16x16/actions/xfpm-suspend.png b/data/icons/16x16/actions/xfpm-suspend.png
new file mode 100644
index 0000000..b435771
Binary files /dev/null and b/data/icons/16x16/actions/xfpm-suspend.png differ
diff --git a/data/icons/16x16/status/Makefile.am b/data/icons/16x16/status/Makefile.am
new file mode 100644
index 0000000..038842d
--- /dev/null
+++ b/data/icons/16x16/status/Makefile.am
@@ -0,0 +1,49 @@
+EXTRA_DIST =				\
+	$(Data_DATA)
+
+Datadir = $(datadir)/icons/hicolor/16x16/status
+
+Data_DATA =				\
+	xfpm-ac-adapter.png		\
+	xfpm-primary-000.png		\
+	xfpm-primary-020.png		\
+	xfpm-primary-040.png		\
+	xfpm-primary-060.png		\
+	xfpm-primary-080.png		\
+	xfpm-primary-100.png		\
+	xfpm-primary-000-charging.png	\
+	xfpm-primary-020-charging.png	\
+	xfpm-primary-040-charging.png	\
+	xfpm-primary-060-charging.png	\
+	xfpm-primary-080-charging.png	\
+	xfpm-primary-100-charging.png	\
+	xfpm-primary-charged.png		\
+	xfpm-primary-missing.png		\
+	xfpm-ups-000.png			\
+	xfpm-ups-020.png			\
+	xfpm-ups-040.png			\
+	xfpm-ups-060.png			\
+	xfpm-ups-080.png			\
+	xfpm-ups-100.png			\
+	xfpm-ups-000-charging.png	\
+	xfpm-ups-020-charging.png	\
+	xfpm-ups-040-charging.png	\
+	xfpm-ups-060-charging.png	\
+	xfpm-ups-080-charging.png	\
+	xfpm-ups-100-charging.png	\
+	xfpm-ups-charged.png		\
+	xfpm-ups-missing.png		\
+	xfpm-keyboard-000.png		\
+	xfpm-keyboard-030.png		\
+	xfpm-keyboard-060.png		\
+	xfpm-keyboard-100.png		\
+	xfpm-mouse-000.png		\
+	xfpm-mouse-030.png		\
+	xfpm-mouse-060.png		\
+	xfpm-mouse-100.png		\
+	xfpm-phone-000.png		\
+	xfpm-phone-030.png		\
+	xfpm-phone-060.png		\
+	xfpm-phone-100.png		\
+	xfpm-brightness-lcd-invalid.png	\
+	xfpm-brightness-lcd.png
diff --git a/data/icons/16x16/status/xfpm-ac-adapter.png b/data/icons/16x16/status/xfpm-ac-adapter.png
new file mode 100644
index 0000000..6020a29
Binary files /dev/null and b/data/icons/16x16/status/xfpm-ac-adapter.png differ
diff --git a/data/icons/16x16/status/xfpm-brightness-lcd-invalid.png b/data/icons/16x16/status/xfpm-brightness-lcd-invalid.png
new file mode 100644
index 0000000..6406490
Binary files /dev/null and b/data/icons/16x16/status/xfpm-brightness-lcd-invalid.png differ
diff --git a/data/icons/16x16/status/xfpm-brightness-lcd.png b/data/icons/16x16/status/xfpm-brightness-lcd.png
new file mode 100644
index 0000000..6406490
Binary files /dev/null and b/data/icons/16x16/status/xfpm-brightness-lcd.png differ
diff --git a/data/icons/16x16/status/xfpm-keyboard-000.png b/data/icons/16x16/status/xfpm-keyboard-000.png
new file mode 100644
index 0000000..417fa7c
Binary files /dev/null and b/data/icons/16x16/status/xfpm-keyboard-000.png differ
diff --git a/data/icons/16x16/status/xfpm-keyboard-030.png b/data/icons/16x16/status/xfpm-keyboard-030.png
new file mode 100644
index 0000000..822785e
Binary files /dev/null and b/data/icons/16x16/status/xfpm-keyboard-030.png differ
diff --git a/data/icons/16x16/status/xfpm-keyboard-060.png b/data/icons/16x16/status/xfpm-keyboard-060.png
new file mode 100644
index 0000000..9f147a3
Binary files /dev/null and b/data/icons/16x16/status/xfpm-keyboard-060.png differ
diff --git a/data/icons/16x16/status/xfpm-keyboard-100.png b/data/icons/16x16/status/xfpm-keyboard-100.png
new file mode 100644
index 0000000..c56a835
Binary files /dev/null and b/data/icons/16x16/status/xfpm-keyboard-100.png differ
diff --git a/data/icons/16x16/status/xfpm-mouse-000.png b/data/icons/16x16/status/xfpm-mouse-000.png
new file mode 100644
index 0000000..cf7a808
Binary files /dev/null and b/data/icons/16x16/status/xfpm-mouse-000.png differ
diff --git a/data/icons/16x16/status/xfpm-mouse-030.png b/data/icons/16x16/status/xfpm-mouse-030.png
new file mode 100644
index 0000000..793c091
Binary files /dev/null and b/data/icons/16x16/status/xfpm-mouse-030.png differ
diff --git a/data/icons/16x16/status/xfpm-mouse-060.png b/data/icons/16x16/status/xfpm-mouse-060.png
new file mode 100644
index 0000000..91a727d
Binary files /dev/null and b/data/icons/16x16/status/xfpm-mouse-060.png differ
diff --git a/data/icons/16x16/status/xfpm-mouse-100.png b/data/icons/16x16/status/xfpm-mouse-100.png
new file mode 100644
index 0000000..b52e9eb
Binary files /dev/null and b/data/icons/16x16/status/xfpm-mouse-100.png differ
diff --git a/data/icons/16x16/status/xfpm-phone-000.png b/data/icons/16x16/status/xfpm-phone-000.png
new file mode 100644
index 0000000..1426577
Binary files /dev/null and b/data/icons/16x16/status/xfpm-phone-000.png differ
diff --git a/data/icons/16x16/status/xfpm-phone-030.png b/data/icons/16x16/status/xfpm-phone-030.png
new file mode 100644
index 0000000..3dc211c
Binary files /dev/null and b/data/icons/16x16/status/xfpm-phone-030.png differ
diff --git a/data/icons/16x16/status/xfpm-phone-060.png b/data/icons/16x16/status/xfpm-phone-060.png
new file mode 100644
index 0000000..88f955e
Binary files /dev/null and b/data/icons/16x16/status/xfpm-phone-060.png differ
diff --git a/data/icons/16x16/status/xfpm-phone-100.png b/data/icons/16x16/status/xfpm-phone-100.png
new file mode 100644
index 0000000..c01357c
Binary files /dev/null and b/data/icons/16x16/status/xfpm-phone-100.png differ
diff --git a/data/icons/16x16/status/xfpm-primary-000-charging.png b/data/icons/16x16/status/xfpm-primary-000-charging.png
new file mode 100644
index 0000000..4b2e0a9
Binary files /dev/null and b/data/icons/16x16/status/xfpm-primary-000-charging.png differ
diff --git a/data/icons/16x16/status/xfpm-primary-000.png b/data/icons/16x16/status/xfpm-primary-000.png
new file mode 100644
index 0000000..eae4379
Binary files /dev/null and b/data/icons/16x16/status/xfpm-primary-000.png differ
diff --git a/data/icons/16x16/status/xfpm-primary-020-charging.png b/data/icons/16x16/status/xfpm-primary-020-charging.png
new file mode 100644
index 0000000..b312416
Binary files /dev/null and b/data/icons/16x16/status/xfpm-primary-020-charging.png differ
diff --git a/data/icons/16x16/status/xfpm-primary-020.png b/data/icons/16x16/status/xfpm-primary-020.png
new file mode 100644
index 0000000..51df811
Binary files /dev/null and b/data/icons/16x16/status/xfpm-primary-020.png differ
diff --git a/data/icons/16x16/status/xfpm-primary-040-charging.png b/data/icons/16x16/status/xfpm-primary-040-charging.png
new file mode 100644
index 0000000..dee5597
Binary files /dev/null and b/data/icons/16x16/status/xfpm-primary-040-charging.png differ
diff --git a/data/icons/16x16/status/xfpm-primary-040.png b/data/icons/16x16/status/xfpm-primary-040.png
new file mode 100644
index 0000000..e23d85f
Binary files /dev/null and b/data/icons/16x16/status/xfpm-primary-040.png differ
diff --git a/data/icons/16x16/status/xfpm-primary-060-charging.png b/data/icons/16x16/status/xfpm-primary-060-charging.png
new file mode 100644
index 0000000..45c83f8
Binary files /dev/null and b/data/icons/16x16/status/xfpm-primary-060-charging.png differ
diff --git a/data/icons/16x16/status/xfpm-primary-060.png b/data/icons/16x16/status/xfpm-primary-060.png
new file mode 100644
index 0000000..f3dc4b7
Binary files /dev/null and b/data/icons/16x16/status/xfpm-primary-060.png differ
diff --git a/data/icons/16x16/status/xfpm-primary-080-charging.png b/data/icons/16x16/status/xfpm-primary-080-charging.png
new file mode 100644
index 0000000..03fd467
Binary files /dev/null and b/data/icons/16x16/status/xfpm-primary-080-charging.png differ
diff --git a/data/icons/16x16/status/xfpm-primary-080.png b/data/icons/16x16/status/xfpm-primary-080.png
new file mode 100644
index 0000000..5c96281
Binary files /dev/null and b/data/icons/16x16/status/xfpm-primary-080.png differ
diff --git a/data/icons/16x16/status/xfpm-primary-100-charging.png b/data/icons/16x16/status/xfpm-primary-100-charging.png
new file mode 100644
index 0000000..b4714fc
Binary files /dev/null and b/data/icons/16x16/status/xfpm-primary-100-charging.png differ
diff --git a/data/icons/16x16/status/xfpm-primary-100.png b/data/icons/16x16/status/xfpm-primary-100.png
new file mode 100644
index 0000000..15ae4cb
Binary files /dev/null and b/data/icons/16x16/status/xfpm-primary-100.png differ
diff --git a/data/icons/16x16/status/xfpm-primary-charged.png b/data/icons/16x16/status/xfpm-primary-charged.png
new file mode 100644
index 0000000..ab08d6d
Binary files /dev/null and b/data/icons/16x16/status/xfpm-primary-charged.png differ
diff --git a/data/icons/16x16/status/xfpm-primary-missing.png b/data/icons/16x16/status/xfpm-primary-missing.png
new file mode 100644
index 0000000..b104d2a
Binary files /dev/null and b/data/icons/16x16/status/xfpm-primary-missing.png differ
diff --git a/data/icons/16x16/status/xfpm-ups-000-charging.png b/data/icons/16x16/status/xfpm-ups-000-charging.png
new file mode 100644
index 0000000..1de0f74
Binary files /dev/null and b/data/icons/16x16/status/xfpm-ups-000-charging.png differ
diff --git a/data/icons/16x16/status/xfpm-ups-000.png b/data/icons/16x16/status/xfpm-ups-000.png
new file mode 100644
index 0000000..495a08a
Binary files /dev/null and b/data/icons/16x16/status/xfpm-ups-000.png differ
diff --git a/data/icons/16x16/status/xfpm-ups-020-charging.png b/data/icons/16x16/status/xfpm-ups-020-charging.png
new file mode 100644
index 0000000..f00740e
Binary files /dev/null and b/data/icons/16x16/status/xfpm-ups-020-charging.png differ
diff --git a/data/icons/16x16/status/xfpm-ups-020.png b/data/icons/16x16/status/xfpm-ups-020.png
new file mode 100644
index 0000000..6e48980
Binary files /dev/null and b/data/icons/16x16/status/xfpm-ups-020.png differ
diff --git a/data/icons/16x16/status/xfpm-ups-040-charging.png b/data/icons/16x16/status/xfpm-ups-040-charging.png
new file mode 100644
index 0000000..bb4cf5c
Binary files /dev/null and b/data/icons/16x16/status/xfpm-ups-040-charging.png differ
diff --git a/data/icons/16x16/status/xfpm-ups-040.png b/data/icons/16x16/status/xfpm-ups-040.png
new file mode 100644
index 0000000..2cd9361
Binary files /dev/null and b/data/icons/16x16/status/xfpm-ups-040.png differ
diff --git a/data/icons/16x16/status/xfpm-ups-060-charging.png b/data/icons/16x16/status/xfpm-ups-060-charging.png
new file mode 100644
index 0000000..0bf4d31
Binary files /dev/null and b/data/icons/16x16/status/xfpm-ups-060-charging.png differ
diff --git a/data/icons/16x16/status/xfpm-ups-060.png b/data/icons/16x16/status/xfpm-ups-060.png
new file mode 100644
index 0000000..05ac77d
Binary files /dev/null and b/data/icons/16x16/status/xfpm-ups-060.png differ
diff --git a/data/icons/16x16/status/xfpm-ups-080-charging.png b/data/icons/16x16/status/xfpm-ups-080-charging.png
new file mode 100644
index 0000000..3a7596a
Binary files /dev/null and b/data/icons/16x16/status/xfpm-ups-080-charging.png differ
diff --git a/data/icons/16x16/status/xfpm-ups-080.png b/data/icons/16x16/status/xfpm-ups-080.png
new file mode 100644
index 0000000..a90f941
Binary files /dev/null and b/data/icons/16x16/status/xfpm-ups-080.png differ
diff --git a/data/icons/16x16/status/xfpm-ups-100-charging.png b/data/icons/16x16/status/xfpm-ups-100-charging.png
new file mode 100644
index 0000000..2c32484
Binary files /dev/null and b/data/icons/16x16/status/xfpm-ups-100-charging.png differ
diff --git a/data/icons/16x16/status/xfpm-ups-100.png b/data/icons/16x16/status/xfpm-ups-100.png
new file mode 100644
index 0000000..ad9c60a
Binary files /dev/null and b/data/icons/16x16/status/xfpm-ups-100.png differ
diff --git a/data/icons/16x16/status/xfpm-ups-charged.png b/data/icons/16x16/status/xfpm-ups-charged.png
new file mode 100644
index 0000000..1f58376
Binary files /dev/null and b/data/icons/16x16/status/xfpm-ups-charged.png differ
diff --git a/data/icons/16x16/status/xfpm-ups-missing.png b/data/icons/16x16/status/xfpm-ups-missing.png
new file mode 100644
index 0000000..7012903
Binary files /dev/null and b/data/icons/16x16/status/xfpm-ups-missing.png differ
diff --git a/data/icons/scalable/Makefile.am b/data/icons/22x22/Makefile.am
similarity index 100%
copy from data/icons/scalable/Makefile.am
copy to data/icons/22x22/Makefile.am
diff --git a/data/icons/22x22/actions/Makefile.am b/data/icons/22x22/actions/Makefile.am
new file mode 100644
index 0000000..99f65bf
--- /dev/null
+++ b/data/icons/22x22/actions/Makefile.am
@@ -0,0 +1,8 @@
+EXTRA_DIST =				\
+	$(Data_DATA)
+
+Datadir = $(datadir)/icons/hicolor/22x22/actions
+
+Data_DATA =				\
+	xfpm-hibernate.png		\
+	xfpm-suspend.png		
diff --git a/data/icons/22x22/actions/xfpm-hibernate.png b/data/icons/22x22/actions/xfpm-hibernate.png
new file mode 100644
index 0000000..30dbaad
Binary files /dev/null and b/data/icons/22x22/actions/xfpm-hibernate.png differ
diff --git a/data/icons/22x22/actions/xfpm-suspend.png b/data/icons/22x22/actions/xfpm-suspend.png
new file mode 100644
index 0000000..0b663a6
Binary files /dev/null and b/data/icons/22x22/actions/xfpm-suspend.png differ
diff --git a/data/icons/22x22/status/Makefile.am b/data/icons/22x22/status/Makefile.am
new file mode 100644
index 0000000..3922edd
--- /dev/null
+++ b/data/icons/22x22/status/Makefile.am
@@ -0,0 +1,49 @@
+EXTRA_DIST =				\
+	$(Data_DATA)
+
+Datadir = $(datadir)/icons/hicolor/22x22/status
+
+Data_DATA =				\
+	xfpm-ac-adapter.png		\
+	xfpm-primary-000.png		\
+	xfpm-primary-020.png		\
+	xfpm-primary-040.png		\
+	xfpm-primary-060.png		\
+	xfpm-primary-080.png		\
+	xfpm-primary-100.png		\
+	xfpm-primary-000-charging.png	\
+	xfpm-primary-020-charging.png	\
+	xfpm-primary-040-charging.png	\
+	xfpm-primary-060-charging.png	\
+	xfpm-primary-080-charging.png	\
+	xfpm-primary-100-charging.png	\
+	xfpm-primary-charged.png		\
+	xfpm-primary-missing.png		\
+	xfpm-ups-000.png			\
+	xfpm-ups-020.png			\
+	xfpm-ups-040.png			\
+	xfpm-ups-060.png			\
+	xfpm-ups-080.png			\
+	xfpm-ups-100.png			\
+	xfpm-ups-000-charging.png	\
+	xfpm-ups-020-charging.png	\
+	xfpm-ups-040-charging.png	\
+	xfpm-ups-060-charging.png	\
+	xfpm-ups-080-charging.png	\
+	xfpm-ups-100-charging.png	\
+	xfpm-ups-charged.png		\
+	xfpm-ups-missing.png		\
+	xfpm-keyboard-000.png		\
+	xfpm-keyboard-030.png		\
+	xfpm-keyboard-060.png		\
+	xfpm-keyboard-100.png		\
+	xfpm-mouse-000.png		\
+	xfpm-mouse-030.png		\
+	xfpm-mouse-060.png		\
+	xfpm-mouse-100.png		\
+	xfpm-phone-000.png		\
+	xfpm-phone-030.png		\
+	xfpm-phone-060.png		\
+	xfpm-phone-100.png		\
+	xfpm-brightness-lcd-invalid.png	\
+	xfpm-brightness-lcd.png
diff --git a/data/icons/22x22/status/xfpm-ac-adapter.png b/data/icons/22x22/status/xfpm-ac-adapter.png
new file mode 100644
index 0000000..0237729
Binary files /dev/null and b/data/icons/22x22/status/xfpm-ac-adapter.png differ
diff --git a/data/icons/22x22/status/xfpm-brightness-lcd-invalid.png b/data/icons/22x22/status/xfpm-brightness-lcd-invalid.png
new file mode 100644
index 0000000..c20a5e3
Binary files /dev/null and b/data/icons/22x22/status/xfpm-brightness-lcd-invalid.png differ
diff --git a/data/icons/22x22/status/xfpm-brightness-lcd.png b/data/icons/22x22/status/xfpm-brightness-lcd.png
new file mode 100644
index 0000000..a1ab0ce
Binary files /dev/null and b/data/icons/22x22/status/xfpm-brightness-lcd.png differ
diff --git a/data/icons/22x22/status/xfpm-keyboard-000.png b/data/icons/22x22/status/xfpm-keyboard-000.png
new file mode 100644
index 0000000..c945d86
Binary files /dev/null and b/data/icons/22x22/status/xfpm-keyboard-000.png differ
diff --git a/data/icons/22x22/status/xfpm-keyboard-030.png b/data/icons/22x22/status/xfpm-keyboard-030.png
new file mode 100644
index 0000000..5e3d33a
Binary files /dev/null and b/data/icons/22x22/status/xfpm-keyboard-030.png differ
diff --git a/data/icons/22x22/status/xfpm-keyboard-060.png b/data/icons/22x22/status/xfpm-keyboard-060.png
new file mode 100644
index 0000000..4cb3e46
Binary files /dev/null and b/data/icons/22x22/status/xfpm-keyboard-060.png differ
diff --git a/data/icons/22x22/status/xfpm-keyboard-100.png b/data/icons/22x22/status/xfpm-keyboard-100.png
new file mode 100644
index 0000000..9bb7dee
Binary files /dev/null and b/data/icons/22x22/status/xfpm-keyboard-100.png differ
diff --git a/data/icons/22x22/status/xfpm-mouse-000.png b/data/icons/22x22/status/xfpm-mouse-000.png
new file mode 100644
index 0000000..0d0e004
Binary files /dev/null and b/data/icons/22x22/status/xfpm-mouse-000.png differ
diff --git a/data/icons/22x22/status/xfpm-mouse-030.png b/data/icons/22x22/status/xfpm-mouse-030.png
new file mode 100644
index 0000000..65441dc
Binary files /dev/null and b/data/icons/22x22/status/xfpm-mouse-030.png differ
diff --git a/data/icons/22x22/status/xfpm-mouse-060.png b/data/icons/22x22/status/xfpm-mouse-060.png
new file mode 100644
index 0000000..fed127f
Binary files /dev/null and b/data/icons/22x22/status/xfpm-mouse-060.png differ
diff --git a/data/icons/22x22/status/xfpm-mouse-100.png b/data/icons/22x22/status/xfpm-mouse-100.png
new file mode 100644
index 0000000..d070c58
Binary files /dev/null and b/data/icons/22x22/status/xfpm-mouse-100.png differ
diff --git a/data/icons/22x22/status/xfpm-phone-000.png b/data/icons/22x22/status/xfpm-phone-000.png
new file mode 100644
index 0000000..3cce9f3
Binary files /dev/null and b/data/icons/22x22/status/xfpm-phone-000.png differ
diff --git a/data/icons/22x22/status/xfpm-phone-030.png b/data/icons/22x22/status/xfpm-phone-030.png
new file mode 100644
index 0000000..e03ffc7
Binary files /dev/null and b/data/icons/22x22/status/xfpm-phone-030.png differ
diff --git a/data/icons/22x22/status/xfpm-phone-060.png b/data/icons/22x22/status/xfpm-phone-060.png
new file mode 100644
index 0000000..0309939
Binary files /dev/null and b/data/icons/22x22/status/xfpm-phone-060.png differ
diff --git a/data/icons/22x22/status/xfpm-phone-100.png b/data/icons/22x22/status/xfpm-phone-100.png
new file mode 100644
index 0000000..5e1f60e
Binary files /dev/null and b/data/icons/22x22/status/xfpm-phone-100.png differ
diff --git a/data/icons/22x22/status/xfpm-primary-000-charging.png b/data/icons/22x22/status/xfpm-primary-000-charging.png
new file mode 100644
index 0000000..87fffff
Binary files /dev/null and b/data/icons/22x22/status/xfpm-primary-000-charging.png differ
diff --git a/data/icons/22x22/status/xfpm-primary-000.png b/data/icons/22x22/status/xfpm-primary-000.png
new file mode 100644
index 0000000..018f5e4
Binary files /dev/null and b/data/icons/22x22/status/xfpm-primary-000.png differ
diff --git a/data/icons/22x22/status/xfpm-primary-020-charging.png b/data/icons/22x22/status/xfpm-primary-020-charging.png
new file mode 100644
index 0000000..5851674
Binary files /dev/null and b/data/icons/22x22/status/xfpm-primary-020-charging.png differ
diff --git a/data/icons/22x22/status/xfpm-primary-020.png b/data/icons/22x22/status/xfpm-primary-020.png
new file mode 100644
index 0000000..52c6b54
Binary files /dev/null and b/data/icons/22x22/status/xfpm-primary-020.png differ
diff --git a/data/icons/22x22/status/xfpm-primary-040-charging.png b/data/icons/22x22/status/xfpm-primary-040-charging.png
new file mode 100644
index 0000000..3e1b442
Binary files /dev/null and b/data/icons/22x22/status/xfpm-primary-040-charging.png differ
diff --git a/data/icons/22x22/status/xfpm-primary-040.png b/data/icons/22x22/status/xfpm-primary-040.png
new file mode 100644
index 0000000..35924ad
Binary files /dev/null and b/data/icons/22x22/status/xfpm-primary-040.png differ
diff --git a/data/icons/22x22/status/xfpm-primary-060-charging.png b/data/icons/22x22/status/xfpm-primary-060-charging.png
new file mode 100644
index 0000000..d83d712
Binary files /dev/null and b/data/icons/22x22/status/xfpm-primary-060-charging.png differ
diff --git a/data/icons/22x22/status/xfpm-primary-060.png b/data/icons/22x22/status/xfpm-primary-060.png
new file mode 100644
index 0000000..d10e66e
Binary files /dev/null and b/data/icons/22x22/status/xfpm-primary-060.png differ
diff --git a/data/icons/22x22/status/xfpm-primary-080-charging.png b/data/icons/22x22/status/xfpm-primary-080-charging.png
new file mode 100644
index 0000000..6446619
Binary files /dev/null and b/data/icons/22x22/status/xfpm-primary-080-charging.png differ
diff --git a/data/icons/22x22/status/xfpm-primary-080.png b/data/icons/22x22/status/xfpm-primary-080.png
new file mode 100644
index 0000000..1bdd086
Binary files /dev/null and b/data/icons/22x22/status/xfpm-primary-080.png differ
diff --git a/data/icons/22x22/status/xfpm-primary-100-charging.png b/data/icons/22x22/status/xfpm-primary-100-charging.png
new file mode 100644
index 0000000..ef20ce7
Binary files /dev/null and b/data/icons/22x22/status/xfpm-primary-100-charging.png differ
diff --git a/data/icons/22x22/status/xfpm-primary-100.png b/data/icons/22x22/status/xfpm-primary-100.png
new file mode 100644
index 0000000..064cb30
Binary files /dev/null and b/data/icons/22x22/status/xfpm-primary-100.png differ
diff --git a/data/icons/22x22/status/xfpm-primary-charged.png b/data/icons/22x22/status/xfpm-primary-charged.png
new file mode 100644
index 0000000..f22c022
Binary files /dev/null and b/data/icons/22x22/status/xfpm-primary-charged.png differ
diff --git a/data/icons/22x22/status/xfpm-primary-missing.png b/data/icons/22x22/status/xfpm-primary-missing.png
new file mode 100644
index 0000000..77e1d82
Binary files /dev/null and b/data/icons/22x22/status/xfpm-primary-missing.png differ
diff --git a/data/icons/22x22/status/xfpm-ups-000-charging.png b/data/icons/22x22/status/xfpm-ups-000-charging.png
new file mode 100644
index 0000000..341cad3
Binary files /dev/null and b/data/icons/22x22/status/xfpm-ups-000-charging.png differ
diff --git a/data/icons/22x22/status/xfpm-ups-000.png b/data/icons/22x22/status/xfpm-ups-000.png
new file mode 100644
index 0000000..fbb3437
Binary files /dev/null and b/data/icons/22x22/status/xfpm-ups-000.png differ
diff --git a/data/icons/22x22/status/xfpm-ups-020-charging.png b/data/icons/22x22/status/xfpm-ups-020-charging.png
new file mode 100644
index 0000000..a2cb8a8
Binary files /dev/null and b/data/icons/22x22/status/xfpm-ups-020-charging.png differ
diff --git a/data/icons/22x22/status/xfpm-ups-020.png b/data/icons/22x22/status/xfpm-ups-020.png
new file mode 100644
index 0000000..335ad09
Binary files /dev/null and b/data/icons/22x22/status/xfpm-ups-020.png differ
diff --git a/data/icons/22x22/status/xfpm-ups-040-charging.png b/data/icons/22x22/status/xfpm-ups-040-charging.png
new file mode 100644
index 0000000..e4dcb8f
Binary files /dev/null and b/data/icons/22x22/status/xfpm-ups-040-charging.png differ
diff --git a/data/icons/22x22/status/xfpm-ups-040.png b/data/icons/22x22/status/xfpm-ups-040.png
new file mode 100644
index 0000000..f2545bb
Binary files /dev/null and b/data/icons/22x22/status/xfpm-ups-040.png differ
diff --git a/data/icons/22x22/status/xfpm-ups-060-charging.png b/data/icons/22x22/status/xfpm-ups-060-charging.png
new file mode 100644
index 0000000..14e2a19
Binary files /dev/null and b/data/icons/22x22/status/xfpm-ups-060-charging.png differ
diff --git a/data/icons/22x22/status/xfpm-ups-060.png b/data/icons/22x22/status/xfpm-ups-060.png
new file mode 100644
index 0000000..e2578af
Binary files /dev/null and b/data/icons/22x22/status/xfpm-ups-060.png differ
diff --git a/data/icons/22x22/status/xfpm-ups-080-charging.png b/data/icons/22x22/status/xfpm-ups-080-charging.png
new file mode 100644
index 0000000..ab940c8
Binary files /dev/null and b/data/icons/22x22/status/xfpm-ups-080-charging.png differ
diff --git a/data/icons/22x22/status/xfpm-ups-080.png b/data/icons/22x22/status/xfpm-ups-080.png
new file mode 100644
index 0000000..538d389
Binary files /dev/null and b/data/icons/22x22/status/xfpm-ups-080.png differ
diff --git a/data/icons/22x22/status/xfpm-ups-100-charging.png b/data/icons/22x22/status/xfpm-ups-100-charging.png
new file mode 100644
index 0000000..0ae5ba9
Binary files /dev/null and b/data/icons/22x22/status/xfpm-ups-100-charging.png differ
diff --git a/data/icons/22x22/status/xfpm-ups-100.png b/data/icons/22x22/status/xfpm-ups-100.png
new file mode 100644
index 0000000..0ae5ba9
Binary files /dev/null and b/data/icons/22x22/status/xfpm-ups-100.png differ
diff --git a/data/icons/22x22/status/xfpm-ups-charged.png b/data/icons/22x22/status/xfpm-ups-charged.png
new file mode 100644
index 0000000..0ae5ba9
Binary files /dev/null and b/data/icons/22x22/status/xfpm-ups-charged.png differ
diff --git a/data/icons/22x22/status/xfpm-ups-missing.png b/data/icons/22x22/status/xfpm-ups-missing.png
new file mode 100644
index 0000000..1cfe1cf
Binary files /dev/null and b/data/icons/22x22/status/xfpm-ups-missing.png differ
diff --git a/data/icons/scalable/Makefile.am b/data/icons/24x24/Makefile.am
similarity index 100%
copy from data/icons/scalable/Makefile.am
copy to data/icons/24x24/Makefile.am
diff --git a/data/icons/24x24/actions/Makefile.am b/data/icons/24x24/actions/Makefile.am
new file mode 100644
index 0000000..310b314
--- /dev/null
+++ b/data/icons/24x24/actions/Makefile.am
@@ -0,0 +1,8 @@
+EXTRA_DIST =				\
+	$(Data_DATA)
+
+Datadir = $(datadir)/icons/hicolor/24x24/actions
+
+Data_DATA =				\
+	xfpm-hibernate.png		\
+	xfpm-suspend.png		
diff --git a/data/icons/24x24/actions/xfpm-hibernate.png b/data/icons/24x24/actions/xfpm-hibernate.png
new file mode 100644
index 0000000..0e11863
Binary files /dev/null and b/data/icons/24x24/actions/xfpm-hibernate.png differ
diff --git a/data/icons/24x24/actions/xfpm-suspend.png b/data/icons/24x24/actions/xfpm-suspend.png
new file mode 100644
index 0000000..4624716
Binary files /dev/null and b/data/icons/24x24/actions/xfpm-suspend.png differ
diff --git a/data/icons/24x24/status/Makefile.am b/data/icons/24x24/status/Makefile.am
new file mode 100644
index 0000000..327187a
--- /dev/null
+++ b/data/icons/24x24/status/Makefile.am
@@ -0,0 +1,49 @@
+EXTRA_DIST =				\
+	$(Data_DATA)
+
+Datadir = $(datadir)/icons/hicolor/24x24/status
+
+Data_DATA =				\
+	xfpm-ac-adapter.png		\
+	xfpm-primary-000.png		\
+	xfpm-primary-020.png		\
+	xfpm-primary-040.png		\
+	xfpm-primary-060.png		\
+	xfpm-primary-080.png		\
+	xfpm-primary-100.png		\
+	xfpm-primary-000-charging.png	\
+	xfpm-primary-020-charging.png	\
+	xfpm-primary-040-charging.png	\
+	xfpm-primary-060-charging.png	\
+	xfpm-primary-080-charging.png	\
+	xfpm-primary-100-charging.png	\
+	xfpm-primary-charged.png		\
+	xfpm-primary-missing.png		\
+	xfpm-ups-000.png			\
+	xfpm-ups-020.png			\
+	xfpm-ups-040.png			\
+	xfpm-ups-060.png			\
+	xfpm-ups-080.png			\
+	xfpm-ups-100.png			\
+	xfpm-ups-000-charging.png	\
+	xfpm-ups-020-charging.png	\
+	xfpm-ups-040-charging.png	\
+	xfpm-ups-060-charging.png	\
+	xfpm-ups-080-charging.png	\
+	xfpm-ups-100-charging.png	\
+	xfpm-ups-charged.png		\
+	xfpm-ups-missing.png		\
+	xfpm-keyboard-000.png		\
+	xfpm-keyboard-030.png		\
+	xfpm-keyboard-060.png		\
+	xfpm-keyboard-100.png		\
+	xfpm-mouse-000.png		\
+	xfpm-mouse-030.png		\
+	xfpm-mouse-060.png		\
+	xfpm-mouse-100.png		\
+	xfpm-phone-000.png		\
+	xfpm-phone-030.png		\
+	xfpm-phone-060.png		\
+	xfpm-phone-100.png		\
+	xfpm-brightness-lcd-invalid.png	\
+	xfpm-brightness-lcd.png
diff --git a/data/icons/24x24/status/xfpm-ac-adapter.png b/data/icons/24x24/status/xfpm-ac-adapter.png
new file mode 100644
index 0000000..1ae4afe
Binary files /dev/null and b/data/icons/24x24/status/xfpm-ac-adapter.png differ
diff --git a/data/icons/24x24/status/xfpm-brightness-lcd-invalid.png b/data/icons/24x24/status/xfpm-brightness-lcd-invalid.png
new file mode 100644
index 0000000..ceb8b79
Binary files /dev/null and b/data/icons/24x24/status/xfpm-brightness-lcd-invalid.png differ
diff --git a/data/icons/24x24/status/xfpm-brightness-lcd.png b/data/icons/24x24/status/xfpm-brightness-lcd.png
new file mode 100644
index 0000000..8a52068
Binary files /dev/null and b/data/icons/24x24/status/xfpm-brightness-lcd.png differ
diff --git a/data/icons/24x24/status/xfpm-keyboard-000.png b/data/icons/24x24/status/xfpm-keyboard-000.png
new file mode 100644
index 0000000..f96bc7e
Binary files /dev/null and b/data/icons/24x24/status/xfpm-keyboard-000.png differ
diff --git a/data/icons/24x24/status/xfpm-keyboard-030.png b/data/icons/24x24/status/xfpm-keyboard-030.png
new file mode 100644
index 0000000..c725538
Binary files /dev/null and b/data/icons/24x24/status/xfpm-keyboard-030.png differ
diff --git a/data/icons/24x24/status/xfpm-keyboard-060.png b/data/icons/24x24/status/xfpm-keyboard-060.png
new file mode 100644
index 0000000..95e95f7
Binary files /dev/null and b/data/icons/24x24/status/xfpm-keyboard-060.png differ
diff --git a/data/icons/24x24/status/xfpm-keyboard-100.png b/data/icons/24x24/status/xfpm-keyboard-100.png
new file mode 100644
index 0000000..c0d73e6
Binary files /dev/null and b/data/icons/24x24/status/xfpm-keyboard-100.png differ
diff --git a/data/icons/24x24/status/xfpm-mouse-000.png b/data/icons/24x24/status/xfpm-mouse-000.png
new file mode 100644
index 0000000..a667f3f
Binary files /dev/null and b/data/icons/24x24/status/xfpm-mouse-000.png differ
diff --git a/data/icons/24x24/status/xfpm-mouse-030.png b/data/icons/24x24/status/xfpm-mouse-030.png
new file mode 100644
index 0000000..99001fb
Binary files /dev/null and b/data/icons/24x24/status/xfpm-mouse-030.png differ
diff --git a/data/icons/24x24/status/xfpm-mouse-060.png b/data/icons/24x24/status/xfpm-mouse-060.png
new file mode 100644
index 0000000..7c7e5d8
Binary files /dev/null and b/data/icons/24x24/status/xfpm-mouse-060.png differ
diff --git a/data/icons/24x24/status/xfpm-mouse-100.png b/data/icons/24x24/status/xfpm-mouse-100.png
new file mode 100644
index 0000000..3b3dde7
Binary files /dev/null and b/data/icons/24x24/status/xfpm-mouse-100.png differ
diff --git a/data/icons/24x24/status/xfpm-phone-000.png b/data/icons/24x24/status/xfpm-phone-000.png
new file mode 100644
index 0000000..e89001a
Binary files /dev/null and b/data/icons/24x24/status/xfpm-phone-000.png differ
diff --git a/data/icons/24x24/status/xfpm-phone-030.png b/data/icons/24x24/status/xfpm-phone-030.png
new file mode 100644
index 0000000..3f03b69
Binary files /dev/null and b/data/icons/24x24/status/xfpm-phone-030.png differ
diff --git a/data/icons/24x24/status/xfpm-phone-060.png b/data/icons/24x24/status/xfpm-phone-060.png
new file mode 100644
index 0000000..f573897
Binary files /dev/null and b/data/icons/24x24/status/xfpm-phone-060.png differ
diff --git a/data/icons/24x24/status/xfpm-phone-100.png b/data/icons/24x24/status/xfpm-phone-100.png
new file mode 100644
index 0000000..035ee28
Binary files /dev/null and b/data/icons/24x24/status/xfpm-phone-100.png differ
diff --git a/data/icons/24x24/status/xfpm-primary-000-charging.png b/data/icons/24x24/status/xfpm-primary-000-charging.png
new file mode 100644
index 0000000..9255e66
Binary files /dev/null and b/data/icons/24x24/status/xfpm-primary-000-charging.png differ
diff --git a/data/icons/24x24/status/xfpm-primary-000.png b/data/icons/24x24/status/xfpm-primary-000.png
new file mode 100644
index 0000000..2554a6a
Binary files /dev/null and b/data/icons/24x24/status/xfpm-primary-000.png differ
diff --git a/data/icons/24x24/status/xfpm-primary-020-charging.png b/data/icons/24x24/status/xfpm-primary-020-charging.png
new file mode 100644
index 0000000..aabd778
Binary files /dev/null and b/data/icons/24x24/status/xfpm-primary-020-charging.png differ
diff --git a/data/icons/24x24/status/xfpm-primary-020.png b/data/icons/24x24/status/xfpm-primary-020.png
new file mode 100644
index 0000000..83e7065
Binary files /dev/null and b/data/icons/24x24/status/xfpm-primary-020.png differ
diff --git a/data/icons/24x24/status/xfpm-primary-040-charging.png b/data/icons/24x24/status/xfpm-primary-040-charging.png
new file mode 100644
index 0000000..c016a28
Binary files /dev/null and b/data/icons/24x24/status/xfpm-primary-040-charging.png differ
diff --git a/data/icons/24x24/status/xfpm-primary-040.png b/data/icons/24x24/status/xfpm-primary-040.png
new file mode 100644
index 0000000..3245106
Binary files /dev/null and b/data/icons/24x24/status/xfpm-primary-040.png differ
diff --git a/data/icons/24x24/status/xfpm-primary-060-charging.png b/data/icons/24x24/status/xfpm-primary-060-charging.png
new file mode 100644
index 0000000..1667458
Binary files /dev/null and b/data/icons/24x24/status/xfpm-primary-060-charging.png differ
diff --git a/data/icons/24x24/status/xfpm-primary-060.png b/data/icons/24x24/status/xfpm-primary-060.png
new file mode 100644
index 0000000..aa25803
Binary files /dev/null and b/data/icons/24x24/status/xfpm-primary-060.png differ
diff --git a/data/icons/24x24/status/xfpm-primary-080-charging.png b/data/icons/24x24/status/xfpm-primary-080-charging.png
new file mode 100644
index 0000000..b9c6991
Binary files /dev/null and b/data/icons/24x24/status/xfpm-primary-080-charging.png differ
diff --git a/data/icons/24x24/status/xfpm-primary-080.png b/data/icons/24x24/status/xfpm-primary-080.png
new file mode 100644
index 0000000..e649be0
Binary files /dev/null and b/data/icons/24x24/status/xfpm-primary-080.png differ
diff --git a/data/icons/24x24/status/xfpm-primary-100-charging.png b/data/icons/24x24/status/xfpm-primary-100-charging.png
new file mode 100644
index 0000000..bae3a43
Binary files /dev/null and b/data/icons/24x24/status/xfpm-primary-100-charging.png differ
diff --git a/data/icons/24x24/status/xfpm-primary-100.png b/data/icons/24x24/status/xfpm-primary-100.png
new file mode 100644
index 0000000..fe4ba7f
Binary files /dev/null and b/data/icons/24x24/status/xfpm-primary-100.png differ
diff --git a/data/icons/24x24/status/xfpm-primary-charged.png b/data/icons/24x24/status/xfpm-primary-charged.png
new file mode 100644
index 0000000..1e61940
Binary files /dev/null and b/data/icons/24x24/status/xfpm-primary-charged.png differ
diff --git a/data/icons/24x24/status/xfpm-primary-missing.png b/data/icons/24x24/status/xfpm-primary-missing.png
new file mode 100644
index 0000000..4c1a538
Binary files /dev/null and b/data/icons/24x24/status/xfpm-primary-missing.png differ
diff --git a/data/icons/24x24/status/xfpm-ups-000-charging.png b/data/icons/24x24/status/xfpm-ups-000-charging.png
new file mode 100644
index 0000000..a41047d
Binary files /dev/null and b/data/icons/24x24/status/xfpm-ups-000-charging.png differ
diff --git a/data/icons/24x24/status/xfpm-ups-000.png b/data/icons/24x24/status/xfpm-ups-000.png
new file mode 100644
index 0000000..bce1925
Binary files /dev/null and b/data/icons/24x24/status/xfpm-ups-000.png differ
diff --git a/data/icons/24x24/status/xfpm-ups-020-charging.png b/data/icons/24x24/status/xfpm-ups-020-charging.png
new file mode 100644
index 0000000..126613e
Binary files /dev/null and b/data/icons/24x24/status/xfpm-ups-020-charging.png differ
diff --git a/data/icons/24x24/status/xfpm-ups-020.png b/data/icons/24x24/status/xfpm-ups-020.png
new file mode 100644
index 0000000..cc2c608
Binary files /dev/null and b/data/icons/24x24/status/xfpm-ups-020.png differ
diff --git a/data/icons/24x24/status/xfpm-ups-040-charging.png b/data/icons/24x24/status/xfpm-ups-040-charging.png
new file mode 100644
index 0000000..7abefee
Binary files /dev/null and b/data/icons/24x24/status/xfpm-ups-040-charging.png differ
diff --git a/data/icons/24x24/status/xfpm-ups-040.png b/data/icons/24x24/status/xfpm-ups-040.png
new file mode 100644
index 0000000..29d7557
Binary files /dev/null and b/data/icons/24x24/status/xfpm-ups-040.png differ
diff --git a/data/icons/24x24/status/xfpm-ups-060-charging.png b/data/icons/24x24/status/xfpm-ups-060-charging.png
new file mode 100644
index 0000000..5ec3918
Binary files /dev/null and b/data/icons/24x24/status/xfpm-ups-060-charging.png differ
diff --git a/data/icons/24x24/status/xfpm-ups-060.png b/data/icons/24x24/status/xfpm-ups-060.png
new file mode 100644
index 0000000..e15226f
Binary files /dev/null and b/data/icons/24x24/status/xfpm-ups-060.png differ
diff --git a/data/icons/24x24/status/xfpm-ups-080-charging.png b/data/icons/24x24/status/xfpm-ups-080-charging.png
new file mode 100644
index 0000000..f8832be
Binary files /dev/null and b/data/icons/24x24/status/xfpm-ups-080-charging.png differ
diff --git a/data/icons/24x24/status/xfpm-ups-080.png b/data/icons/24x24/status/xfpm-ups-080.png
new file mode 100644
index 0000000..afb2dd1
Binary files /dev/null and b/data/icons/24x24/status/xfpm-ups-080.png differ
diff --git a/data/icons/24x24/status/xfpm-ups-100-charging.png b/data/icons/24x24/status/xfpm-ups-100-charging.png
new file mode 100644
index 0000000..be45d0b
Binary files /dev/null and b/data/icons/24x24/status/xfpm-ups-100-charging.png differ
diff --git a/data/icons/24x24/status/xfpm-ups-100.png b/data/icons/24x24/status/xfpm-ups-100.png
new file mode 100644
index 0000000..be45d0b
Binary files /dev/null and b/data/icons/24x24/status/xfpm-ups-100.png differ
diff --git a/data/icons/24x24/status/xfpm-ups-charged.png b/data/icons/24x24/status/xfpm-ups-charged.png
new file mode 100644
index 0000000..be45d0b
Binary files /dev/null and b/data/icons/24x24/status/xfpm-ups-charged.png differ
diff --git a/data/icons/24x24/status/xfpm-ups-missing.png b/data/icons/24x24/status/xfpm-ups-missing.png
new file mode 100644
index 0000000..23367b5
Binary files /dev/null and b/data/icons/24x24/status/xfpm-ups-missing.png differ
diff --git a/data/icons/scalable/Makefile.am b/data/icons/48x48/Makefile.am
similarity index 100%
copy from data/icons/scalable/Makefile.am
copy to data/icons/48x48/Makefile.am
diff --git a/data/icons/48x48/actions/Makefile.am b/data/icons/48x48/actions/Makefile.am
new file mode 100644
index 0000000..04f4f38
--- /dev/null
+++ b/data/icons/48x48/actions/Makefile.am
@@ -0,0 +1,8 @@
+EXTRA_DIST =				\
+	$(Data_DATA)
+
+Datadir = $(datadir)/icons/hicolor/48x48/actions
+
+Data_DATA =				\
+	xfpm-hibernate.png		\
+	xfpm-suspend.png		
diff --git a/data/icons/48x48/actions/xfpm-hibernate.png b/data/icons/48x48/actions/xfpm-hibernate.png
new file mode 100644
index 0000000..b9815eb
Binary files /dev/null and b/data/icons/48x48/actions/xfpm-hibernate.png differ
diff --git a/data/icons/48x48/actions/xfpm-suspend.png b/data/icons/48x48/actions/xfpm-suspend.png
new file mode 100644
index 0000000..f933d82
Binary files /dev/null and b/data/icons/48x48/actions/xfpm-suspend.png differ
diff --git a/data/icons/48x48/status/Makefile.am b/data/icons/48x48/status/Makefile.am
new file mode 100644
index 0000000..f442fed
--- /dev/null
+++ b/data/icons/48x48/status/Makefile.am
@@ -0,0 +1,49 @@
+EXTRA_DIST =				\
+	$(Data_DATA)
+
+Datadir = $(datadir)/icons/hicolor/48x48/status
+
+Data_DATA =				\
+	xfpm-ac-adapter.png		\
+	xfpm-primary-000.png		\
+	xfpm-primary-020.png		\
+	xfpm-primary-040.png		\
+	xfpm-primary-060.png		\
+	xfpm-primary-080.png		\
+	xfpm-primary-100.png		\
+	xfpm-primary-000-charging.png	\
+	xfpm-primary-020-charging.png	\
+	xfpm-primary-040-charging.png	\
+	xfpm-primary-060-charging.png	\
+	xfpm-primary-080-charging.png	\
+	xfpm-primary-100-charging.png	\
+	xfpm-primary-charged.png		\
+	xfpm-primary-missing.png		\
+	xfpm-ups-000.png			\
+	xfpm-ups-020.png			\
+	xfpm-ups-040.png			\
+	xfpm-ups-060.png			\
+	xfpm-ups-080.png			\
+	xfpm-ups-100.png			\
+	xfpm-ups-000-charging.png	\
+	xfpm-ups-020-charging.png	\
+	xfpm-ups-040-charging.png	\
+	xfpm-ups-060-charging.png	\
+	xfpm-ups-080-charging.png	\
+	xfpm-ups-100-charging.png	\
+	xfpm-ups-charged.png		\
+	xfpm-ups-missing.png		\
+	xfpm-keyboard-000.png		\
+	xfpm-keyboard-030.png		\
+	xfpm-keyboard-060.png		\
+	xfpm-keyboard-100.png		\
+	xfpm-mouse-000.png		\
+	xfpm-mouse-030.png		\
+	xfpm-mouse-060.png		\
+	xfpm-mouse-100.png		\
+	xfpm-phone-000.png		\
+	xfpm-phone-030.png		\
+	xfpm-phone-060.png		\
+	xfpm-phone-100.png		\
+	xfpm-brightness-lcd-invalid.png	\
+	xfpm-brightness-lcd.png
diff --git a/data/icons/48x48/status/xfpm-ac-adapter.png b/data/icons/48x48/status/xfpm-ac-adapter.png
new file mode 100644
index 0000000..5b38115
Binary files /dev/null and b/data/icons/48x48/status/xfpm-ac-adapter.png differ
diff --git a/data/icons/48x48/status/xfpm-brightness-lcd-invalid.png b/data/icons/48x48/status/xfpm-brightness-lcd-invalid.png
new file mode 100644
index 0000000..916c427
Binary files /dev/null and b/data/icons/48x48/status/xfpm-brightness-lcd-invalid.png differ
diff --git a/data/icons/48x48/status/xfpm-brightness-lcd.png b/data/icons/48x48/status/xfpm-brightness-lcd.png
new file mode 100644
index 0000000..5cc2915
Binary files /dev/null and b/data/icons/48x48/status/xfpm-brightness-lcd.png differ
diff --git a/data/icons/48x48/status/xfpm-keyboard-000.png b/data/icons/48x48/status/xfpm-keyboard-000.png
new file mode 100644
index 0000000..8640103
Binary files /dev/null and b/data/icons/48x48/status/xfpm-keyboard-000.png differ
diff --git a/data/icons/48x48/status/xfpm-keyboard-030.png b/data/icons/48x48/status/xfpm-keyboard-030.png
new file mode 100644
index 0000000..19b2078
Binary files /dev/null and b/data/icons/48x48/status/xfpm-keyboard-030.png differ
diff --git a/data/icons/48x48/status/xfpm-keyboard-060.png b/data/icons/48x48/status/xfpm-keyboard-060.png
new file mode 100644
index 0000000..0304329
Binary files /dev/null and b/data/icons/48x48/status/xfpm-keyboard-060.png differ
diff --git a/data/icons/48x48/status/xfpm-keyboard-100.png b/data/icons/48x48/status/xfpm-keyboard-100.png
new file mode 100644
index 0000000..b00651a
Binary files /dev/null and b/data/icons/48x48/status/xfpm-keyboard-100.png differ
diff --git a/data/icons/48x48/status/xfpm-mouse-000.png b/data/icons/48x48/status/xfpm-mouse-000.png
new file mode 100644
index 0000000..a8a726e
Binary files /dev/null and b/data/icons/48x48/status/xfpm-mouse-000.png differ
diff --git a/data/icons/48x48/status/xfpm-mouse-030.png b/data/icons/48x48/status/xfpm-mouse-030.png
new file mode 100644
index 0000000..2eb705d
Binary files /dev/null and b/data/icons/48x48/status/xfpm-mouse-030.png differ
diff --git a/data/icons/48x48/status/xfpm-mouse-060.png b/data/icons/48x48/status/xfpm-mouse-060.png
new file mode 100644
index 0000000..cc1417f
Binary files /dev/null and b/data/icons/48x48/status/xfpm-mouse-060.png differ
diff --git a/data/icons/48x48/status/xfpm-mouse-100.png b/data/icons/48x48/status/xfpm-mouse-100.png
new file mode 100644
index 0000000..10e7344
Binary files /dev/null and b/data/icons/48x48/status/xfpm-mouse-100.png differ
diff --git a/data/icons/48x48/status/xfpm-phone-000.png b/data/icons/48x48/status/xfpm-phone-000.png
new file mode 100644
index 0000000..7ea9999
Binary files /dev/null and b/data/icons/48x48/status/xfpm-phone-000.png differ
diff --git a/data/icons/48x48/status/xfpm-phone-030.png b/data/icons/48x48/status/xfpm-phone-030.png
new file mode 100644
index 0000000..c0c3437
Binary files /dev/null and b/data/icons/48x48/status/xfpm-phone-030.png differ
diff --git a/data/icons/48x48/status/xfpm-phone-060.png b/data/icons/48x48/status/xfpm-phone-060.png
new file mode 100644
index 0000000..92c5d30
Binary files /dev/null and b/data/icons/48x48/status/xfpm-phone-060.png differ
diff --git a/data/icons/48x48/status/xfpm-phone-100.png b/data/icons/48x48/status/xfpm-phone-100.png
new file mode 100644
index 0000000..9b011ef
Binary files /dev/null and b/data/icons/48x48/status/xfpm-phone-100.png differ
diff --git a/data/icons/48x48/status/xfpm-primary-000-charging.png b/data/icons/48x48/status/xfpm-primary-000-charging.png
new file mode 100644
index 0000000..6e742d3
Binary files /dev/null and b/data/icons/48x48/status/xfpm-primary-000-charging.png differ
diff --git a/data/icons/48x48/status/xfpm-primary-000.png b/data/icons/48x48/status/xfpm-primary-000.png
new file mode 100644
index 0000000..7cf4ab0
Binary files /dev/null and b/data/icons/48x48/status/xfpm-primary-000.png differ
diff --git a/data/icons/48x48/status/xfpm-primary-020-charging.png b/data/icons/48x48/status/xfpm-primary-020-charging.png
new file mode 100644
index 0000000..e8d2a71
Binary files /dev/null and b/data/icons/48x48/status/xfpm-primary-020-charging.png differ
diff --git a/data/icons/48x48/status/xfpm-primary-020.png b/data/icons/48x48/status/xfpm-primary-020.png
new file mode 100644
index 0000000..c8ecb29
Binary files /dev/null and b/data/icons/48x48/status/xfpm-primary-020.png differ
diff --git a/data/icons/48x48/status/xfpm-primary-040-charging.png b/data/icons/48x48/status/xfpm-primary-040-charging.png
new file mode 100644
index 0000000..83e3b60
Binary files /dev/null and b/data/icons/48x48/status/xfpm-primary-040-charging.png differ
diff --git a/data/icons/48x48/status/xfpm-primary-040.png b/data/icons/48x48/status/xfpm-primary-040.png
new file mode 100644
index 0000000..2b5bc56
Binary files /dev/null and b/data/icons/48x48/status/xfpm-primary-040.png differ
diff --git a/data/icons/48x48/status/xfpm-primary-060-charging.png b/data/icons/48x48/status/xfpm-primary-060-charging.png
new file mode 100644
index 0000000..5e62c04
Binary files /dev/null and b/data/icons/48x48/status/xfpm-primary-060-charging.png differ
diff --git a/data/icons/48x48/status/xfpm-primary-060.png b/data/icons/48x48/status/xfpm-primary-060.png
new file mode 100644
index 0000000..279f4a6
Binary files /dev/null and b/data/icons/48x48/status/xfpm-primary-060.png differ
diff --git a/data/icons/48x48/status/xfpm-primary-080-charging.png b/data/icons/48x48/status/xfpm-primary-080-charging.png
new file mode 100644
index 0000000..e92565e
Binary files /dev/null and b/data/icons/48x48/status/xfpm-primary-080-charging.png differ
diff --git a/data/icons/48x48/status/xfpm-primary-080.png b/data/icons/48x48/status/xfpm-primary-080.png
new file mode 100644
index 0000000..e0f80ce
Binary files /dev/null and b/data/icons/48x48/status/xfpm-primary-080.png differ
diff --git a/data/icons/48x48/status/xfpm-primary-100-charging.png b/data/icons/48x48/status/xfpm-primary-100-charging.png
new file mode 100644
index 0000000..ddde285
Binary files /dev/null and b/data/icons/48x48/status/xfpm-primary-100-charging.png differ
diff --git a/data/icons/48x48/status/xfpm-primary-100.png b/data/icons/48x48/status/xfpm-primary-100.png
new file mode 100644
index 0000000..3531ba2
Binary files /dev/null and b/data/icons/48x48/status/xfpm-primary-100.png differ
diff --git a/data/icons/48x48/status/xfpm-primary-charged.png b/data/icons/48x48/status/xfpm-primary-charged.png
new file mode 100644
index 0000000..ea5c508
Binary files /dev/null and b/data/icons/48x48/status/xfpm-primary-charged.png differ
diff --git a/data/icons/48x48/status/xfpm-primary-missing.png b/data/icons/48x48/status/xfpm-primary-missing.png
new file mode 100644
index 0000000..05a23b0
Binary files /dev/null and b/data/icons/48x48/status/xfpm-primary-missing.png differ
diff --git a/data/icons/48x48/status/xfpm-ups-000-charging.png b/data/icons/48x48/status/xfpm-ups-000-charging.png
new file mode 100644
index 0000000..3fbab4e
Binary files /dev/null and b/data/icons/48x48/status/xfpm-ups-000-charging.png differ
diff --git a/data/icons/48x48/status/xfpm-ups-000.png b/data/icons/48x48/status/xfpm-ups-000.png
new file mode 100644
index 0000000..efac18c
Binary files /dev/null and b/data/icons/48x48/status/xfpm-ups-000.png differ
diff --git a/data/icons/48x48/status/xfpm-ups-020-charging.png b/data/icons/48x48/status/xfpm-ups-020-charging.png
new file mode 100644
index 0000000..b78ab99
Binary files /dev/null and b/data/icons/48x48/status/xfpm-ups-020-charging.png differ
diff --git a/data/icons/48x48/status/xfpm-ups-020.png b/data/icons/48x48/status/xfpm-ups-020.png
new file mode 100644
index 0000000..ebd2548
Binary files /dev/null and b/data/icons/48x48/status/xfpm-ups-020.png differ
diff --git a/data/icons/48x48/status/xfpm-ups-040-charging.png b/data/icons/48x48/status/xfpm-ups-040-charging.png
new file mode 100644
index 0000000..72be303
Binary files /dev/null and b/data/icons/48x48/status/xfpm-ups-040-charging.png differ
diff --git a/data/icons/48x48/status/xfpm-ups-040.png b/data/icons/48x48/status/xfpm-ups-040.png
new file mode 100644
index 0000000..cda0c46
Binary files /dev/null and b/data/icons/48x48/status/xfpm-ups-040.png differ
diff --git a/data/icons/48x48/status/xfpm-ups-060-charging.png b/data/icons/48x48/status/xfpm-ups-060-charging.png
new file mode 100644
index 0000000..03b9f59
Binary files /dev/null and b/data/icons/48x48/status/xfpm-ups-060-charging.png differ
diff --git a/data/icons/48x48/status/xfpm-ups-060.png b/data/icons/48x48/status/xfpm-ups-060.png
new file mode 100644
index 0000000..12adf48
Binary files /dev/null and b/data/icons/48x48/status/xfpm-ups-060.png differ
diff --git a/data/icons/48x48/status/xfpm-ups-080-charging.png b/data/icons/48x48/status/xfpm-ups-080-charging.png
new file mode 100644
index 0000000..910718d
Binary files /dev/null and b/data/icons/48x48/status/xfpm-ups-080-charging.png differ
diff --git a/data/icons/48x48/status/xfpm-ups-080.png b/data/icons/48x48/status/xfpm-ups-080.png
new file mode 100644
index 0000000..2a8d5c5
Binary files /dev/null and b/data/icons/48x48/status/xfpm-ups-080.png differ
diff --git a/data/icons/48x48/status/xfpm-ups-100-charging.png b/data/icons/48x48/status/xfpm-ups-100-charging.png
new file mode 100644
index 0000000..4c14902
Binary files /dev/null and b/data/icons/48x48/status/xfpm-ups-100-charging.png differ
diff --git a/data/icons/48x48/status/xfpm-ups-100.png b/data/icons/48x48/status/xfpm-ups-100.png
new file mode 100644
index 0000000..110d6a0
Binary files /dev/null and b/data/icons/48x48/status/xfpm-ups-100.png differ
diff --git a/data/icons/48x48/status/xfpm-ups-charged.png b/data/icons/48x48/status/xfpm-ups-charged.png
new file mode 100644
index 0000000..51ef756
Binary files /dev/null and b/data/icons/48x48/status/xfpm-ups-charged.png differ
diff --git a/data/icons/48x48/status/xfpm-ups-missing.png b/data/icons/48x48/status/xfpm-ups-missing.png
new file mode 100644
index 0000000..fefe77e
Binary files /dev/null and b/data/icons/48x48/status/xfpm-ups-missing.png differ
diff --git a/data/icons/Makefile.am b/data/icons/Makefile.am
index ce27290..f48fe86 100644
--- a/data/icons/Makefile.am
+++ b/data/icons/Makefile.am
@@ -1,7 +1,10 @@
-SUBDIRS =         \
-	scalable  
-        						
-	
+SUBDIRS =         	\
+	16x16		\
+	22x22		\
+	24x24		\
+	48x48		\
+	128x128		\
+	scalable
 
 gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
 
diff --git a/data/interfaces/Makefile.am b/data/interfaces/Makefile.am
index a098a3f..540ace0 100644
--- a/data/interfaces/Makefile.am
+++ b/data/interfaces/Makefile.am
@@ -1,5 +1,6 @@
 interfaces =					\
-	xfpm-settings.ui
+	xfpm-settings.ui			\
+	acme.ui
 
 interfaces_h =					\
 	$(interfaces:.ui=_ui.h)
@@ -10,6 +11,10 @@ BUILT_SOURCES = $(interfaces_h)
 
 xfpm-settings_ui.h: xfpm-settings.ui
 	exo-csource --static --strip-comments --strip-content --name=xfpm_settings_ui $< > $@
+
+acme_ui.h: acme.ui
+	exo-csource --static --strip-comments --strip-content --name=acme_ui $< > $@
+
 endif
 
 CLEANFILES =					\
diff --git a/data/interfaces/acme.ui b/data/interfaces/acme.ui
new file mode 100644
index 0000000..3222ecb
--- /dev/null
+++ b/data/interfaces/acme.ui
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<interface>
+  <!-- interface-requires gtk+ 2.6 -->
+  <!-- interface-naming-policy toplevel-contextual -->
+  <object class="GtkWindow" id="dialog">
+    <child>
+      <object class="GtkFrame" id="acme_frame">
+        <property name="visible">True</property>
+        <property name="label_xalign">0</property>
+        <property name="shadow_type">out</property>
+        <child>
+          <object class="GtkVBox" id="acme_vbox">
+            <property name="visible">True</property>
+            <property name="border_width">12</property>
+            <property name="spacing">6</property>
+            <child>
+              <object class="GtkImage" id="acme_image">
+                <property name="visible">True</property>
+                <property name="icon_name">audio-volume-high</property>
+                <property name="icon-size">6</property>
+              </object>
+              <packing>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkProgressBar" id="acme_volume_progressbar">
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/data/interfaces/xfpm-settings.ui b/data/interfaces/xfpm-settings.ui
index ca92655..0606260 100644
--- a/data/interfaces/xfpm-settings.ui
+++ b/data/interfaces/xfpm-settings.ui
@@ -53,7 +53,7 @@
   </object>
   <object class="GtkAdjustment" id="adjustment9">
     <property name="value">10</property>
-    <property name="lower">1</property>
+    <property name="lower">5</property>
     <property name="upper">20</property>
     <property name="step_increment">1</property>
   </object>
@@ -155,6 +155,8 @@
                     </child>
                   </object>
                   <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
                     <property name="position">0</property>
                   </packing>
                 </child>
@@ -463,6 +465,19 @@
                                             <property name="position">1</property>
                                           </packing>
                                         </child>
+                                        <child>
+                                          <object class="GtkCheckButton" id="spin-down-on-ac">
+                                            <property name="label" translatable="yes">Spin down hard disks</property>
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
+                                            <property name="receives_default">False</property>
+                                            <property name="draw_indicator">True</property>
+                                            <signal name="toggled" handler="on_ac_spin_changed"/>
+                                          </object>
+                                          <packing>
+                                            <property name="position">2</property>
+                                          </packing>
+                                        </child>
                                       </object>
                                     </child>
                                   </object>
@@ -788,20 +803,6 @@
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkCheckButton" id="power-save">
-                                            <property name="label" translatable="yes">Prefer power savings over performance</property>
-                                            <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <property name="receives_default">False</property>
-                                            <property name="draw_indicator">True</property>
-                                            <signal name="toggled" handler="power_save_toggled_cb"/>
-                                          </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                            <property name="position">1</property>
-                                          </packing>
-                                        </child>
-                                        <child>
                                           <object class="GtkVBox" id="vbox4">
                                             <property name="visible">True</property>
                                             <property name="orientation">vertical</property>
@@ -832,9 +833,36 @@
                                             </child>
                                           </object>
                                           <packing>
+                                            <property name="position">1</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkCheckButton" id="power-save">
+                                            <property name="label" translatable="yes">Prefer power savings over performance</property>
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
+                                            <property name="receives_default">False</property>
+                                            <property name="draw_indicator">True</property>
+                                            <signal name="toggled" handler="power_save_toggled_cb"/>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">False</property>
                                             <property name="position">2</property>
                                           </packing>
                                         </child>
+                                        <child>
+                                          <object class="GtkCheckButton" id="spin-down-on-battery">
+                                            <property name="label" translatable="yes">Spin down hard disks</property>
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
+                                            <property name="receives_default">False</property>
+                                            <property name="draw_indicator">True</property>
+                                            <signal name="toggled" handler="on_battery_spin_changed"/>
+                                          </object>
+                                          <packing>
+                                            <property name="position">3</property>
+                                          </packing>
+                                        </child>
                                       </object>
                                     </child>
                                   </object>
@@ -1229,20 +1257,6 @@
                                       </packing>
                                     </child>
                                     <child>
-                                      <object class="GtkCheckButton" id="cpu-freq">
-                                        <property name="label" translatable="yes">CPU frequency control</property>
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">True</property>
-                                        <property name="receives_default">False</property>
-                                        <property name="draw_indicator">True</property>
-                                        <signal name="toggled" handler="cpu_freq_control_changed_cb"/>
-                                      </object>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="position">1</property>
-                                      </packing>
-                                    </child>
-                                    <child>
                                       <object class="GtkCheckButton" id="lock-screen">
                                         <property name="label" translatable="yes">Lock screen when going for suspend/hibernate</property>
                                         <property name="visible">True</property>
@@ -1253,7 +1267,7 @@
                                       </object>
                                       <packing>
                                         <property name="expand">False</property>
-                                        <property name="position">2</property>
+                                        <property name="position">1</property>
                                       </packing>
                                     </child>
                                   </object>
diff --git a/libdbus/Makefile.am b/libdbus/Makefile.am
new file mode 100644
index 0000000..6a47cbb
--- /dev/null
+++ b/libdbus/Makefile.am
@@ -0,0 +1,43 @@
+noinst_LTLIBRARIES = 			\
+	libxfpmdbus.la
+
+libxfpmdbus_la_SOURCES =		\
+	xfpm-dbus.c			\
+	xfpm-dbus.h			\
+	xfpm-dbus-monitor.c		\
+	xfpm-dbus-monitor.h		\
+	xfpm-unique.c			\
+	xfpm-unique.h			\
+	xfpm-dbus-marshal.c		\
+	xfpm-dbus-marshal.h		\
+	org.xfce.unique.h
+	
+libxfpmdbus_la_CFLAGS =			\
+	$(GLIB_CFLAGS)			\
+	$(LIBXFCE4UTIL_CFLAGS)		\
+	$(DBUS_GLIB_CFLAGS)
+
+if MAINTAINER_MODE
+
+BUILT_SOURCES =				\
+	xfpm-dbus-marshal.c		\
+	xfpm-dbus-marshal.h		\
+	org.xfce.unique.h
+
+xfpm-dbus-marshal.c: xfpm-dbus-marshal.list
+	echo "#include \"xfpm-dbus-marshal.h\"" > $@ && \
+	glib-genmarshal $< --prefix=_xfpm_dbus_marshal --body >> $@
+
+xfpm-dbus-marshal.h: xfpm-dbus-marshal.list
+	glib-genmarshal $< --prefix=_xfpm_dbus_marshal --header > $@
+
+org.xfce.unique.h: org.xfce.unique.xml
+	dbus-binding-tool --mode=glib-server --prefix=xfce_unique $< >$@
+
+endif
+
+EXTRA_DIST =				\
+	xfpm-dbus-marshal.list
+
+DISTCLEANFILES =			\
+	$(BUILT_SOURCES)
\ No newline at end of file
diff --git a/libdbus/org.xfce.unique.xml b/libdbus/org.xfce.unique.xml
new file mode 100644
index 0000000..323e405
--- /dev/null
+++ b/libdbus/org.xfce.unique.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<node name="/">
+    <interface name="org.xfce.unique">
+    
+    <method name="Ping">
+    </method>
+	
+    </interface>
+</node>
diff --git a/libdbus/xfpm-dbus-marshal.list b/libdbus/xfpm-dbus-marshal.list
new file mode 100644
index 0000000..7803418
--- /dev/null
+++ b/libdbus/xfpm-dbus-marshal.list
@@ -0,0 +1,2 @@
+VOID:STRING,BOOLEAN
+VOID:STRING,BOOLEAN,BOOLEAN
diff --git a/libdbus/xfpm-dbus-monitor.c b/libdbus/xfpm-dbus-monitor.c
new file mode 100644
index 0000000..84e9f52
--- /dev/null
+++ b/libdbus/xfpm-dbus-monitor.c
@@ -0,0 +1,446 @@
+/* * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <glib.h>
+
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include <dbus/dbus-glib.h>
+
+#include <libxfce4util/libxfce4util.h>
+
+#include "xfpm-dbus.h"
+
+#include "xfpm-dbus-monitor.h"
+#include "xfpm-dbus-marshal.h"
+
+static void xfpm_dbus_monitor_finalize   (GObject *object);
+
+#define XFPM_DBUS_MONITOR_GET_PRIVATE(o) \
+(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_DBUS_MONITOR, XfpmDBusMonitorPrivate))
+
+struct XfpmDBusMonitorPrivate
+{
+    DBusGConnection *system_bus;
+    DBusGConnection *session_bus;
+
+    DBusGProxy      *system_proxy;
+    DBusGProxy      *session_proxy;
+    
+    GPtrArray       *names_array;
+    GPtrArray 	    *services_array;
+};
+
+typedef struct
+{
+    gchar 	*name;
+    DBusBusType  bus_type;
+    
+} XfpmWatchData;
+
+enum
+{
+    UNIQUE_NAME_LOST,
+    SERVICE_CONNECTION_CHANGED,
+    SYSTEM_BUS_CONNECTION_CHANGED,
+    LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (XfpmDBusMonitor, xfpm_dbus_monitor, G_TYPE_OBJECT)
+
+static void
+xfpm_dbus_monitor_free_watch_data (XfpmWatchData *data)
+{
+    g_free (data->name);
+    g_free (data);
+}
+
+static XfpmWatchData *
+xfpm_dbus_monitor_get_watch_data (GPtrArray *array, const gchar *name, DBusBusType bus_type)
+{
+    XfpmWatchData *data;
+    guint i;
+    
+    for ( i = 0; i < array->len; i++)
+    {
+	data = g_ptr_array_index (array, i);
+	if ( !g_strcmp0 (data->name, name) && data->bus_type == bus_type )
+	    return data;
+    }
+    return NULL;
+}
+
+static void
+xfpm_dbus_monitor_unique_connection_name_lost (XfpmDBusMonitor *monitor, DBusBusType bus_type, const gchar *name)
+{
+    XfpmWatchData *watch;
+    guint i = 0;
+    
+    for ( i = 0; i < monitor->priv->names_array->len; i++ )
+    {
+	watch = g_ptr_array_index (monitor->priv->names_array, i);
+	
+	if ( !g_strcmp0 (watch->name, name) && bus_type == watch->bus_type )
+	{
+	    g_signal_emit (G_OBJECT(monitor), signals [UNIQUE_NAME_LOST], 0, 
+			   watch->name, bus_type == DBUS_BUS_SESSION ? TRUE : FALSE);
+	    g_ptr_array_remove (monitor->priv->names_array, watch);
+	    xfpm_dbus_monitor_free_watch_data (watch);
+	}
+    }
+}
+
+static void
+xfpm_dbus_monitor_service_connection_changed (XfpmDBusMonitor *monitor, DBusBusType bus_type, 
+					      const gchar *name, gboolean connected)
+{
+    XfpmWatchData *watch;
+    guint i;
+    
+    for ( i = 0; i < monitor->priv->services_array->len; i++)
+    {
+	watch = g_ptr_array_index (monitor->priv->services_array, i);
+	
+	if ( !g_strcmp0 (watch->name, name) && watch->bus_type == bus_type)
+	{
+	    g_signal_emit (G_OBJECT (monitor), signals [SERVICE_CONNECTION_CHANGED], 0,
+			   name, connected, bus_type == DBUS_BUS_SESSION ? TRUE : FALSE);
+	}
+    }
+}
+
+static void
+xfpm_dbus_monitor_name_owner_changed (XfpmDBusMonitor *monitor, const gchar *name,
+				      const gchar *prev, const gchar *new, DBusBusType bus_type)
+{
+    if ( strlen (prev) != 0 )
+    {
+	xfpm_dbus_monitor_unique_connection_name_lost (monitor, bus_type, prev);
+	
+	/* Connection has name */
+	if ( strlen (name) != 0 )
+	    xfpm_dbus_monitor_service_connection_changed (monitor, bus_type, name, FALSE);
+    }
+    else if ( strlen (name) != 0 && strlen (new) != 0)
+    {
+	xfpm_dbus_monitor_service_connection_changed (monitor, bus_type, name, TRUE);
+    }
+}
+
+static void
+xfpm_dbus_monitor_session_name_owner_changed_cb (DBusGProxy *proxy, const gchar *name,
+						 const gchar *prev, const gchar *new,
+						 XfpmDBusMonitor *monitor)
+{
+    xfpm_dbus_monitor_name_owner_changed (monitor, name, prev, new, DBUS_BUS_SESSION);
+}
+
+static void
+xfpm_dbus_monitor_system_name_owner_changed_cb  (DBusGProxy *proxy, const gchar *name,
+						 const gchar *prev, const gchar *new,
+						 XfpmDBusMonitor *monitor)
+{
+    xfpm_dbus_monitor_name_owner_changed (monitor, name, prev, new, DBUS_BUS_SYSTEM);
+}
+
+static gboolean
+xfpm_dbus_monitor_query_system_bus_idle (gpointer data)
+{
+    XfpmDBusMonitor *monitor;
+    DBusGConnection *bus;
+    GError *error = NULL;
+
+    bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+    
+    if ( error )
+    {
+	TRACE ("System bus is not connected  %s:", error->message);
+	g_error_free (error);
+	return TRUE;
+    }
+    
+    monitor = XFPM_DBUS_MONITOR (data);
+    g_signal_emit (G_OBJECT (monitor), signals [SYSTEM_BUS_CONNECTION_CHANGED], 0, TRUE);
+    
+    return FALSE;
+}
+
+static void
+xfpm_dbus_monitor_setup_system_watch (XfpmDBusMonitor *monitor)
+{
+    g_timeout_add_seconds (2, (GSourceFunc) xfpm_dbus_monitor_query_system_bus_idle, monitor);
+}
+
+static DBusHandlerResult
+xfpm_dbus_monitor_system_bus_filter (DBusConnection *bus, DBusMessage *message, void *data)
+{
+    XfpmDBusMonitor *monitor;
+    
+    if ( dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected") )
+    {
+	TRACE ("System bus is disconnected");
+	monitor = XFPM_DBUS_MONITOR (data);
+	g_signal_emit (G_OBJECT (monitor), signals [SYSTEM_BUS_CONNECTION_CHANGED], 0, FALSE);
+	
+	xfpm_dbus_monitor_setup_system_watch (monitor);
+	
+	return DBUS_HANDLER_RESULT_HANDLED;
+    }
+    
+    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+static void
+xfpm_dbus_monitor_session (XfpmDBusMonitor *monitor)
+{
+    monitor->priv->session_proxy = dbus_g_proxy_new_for_name_owner (monitor->priv->session_bus,
+								    "org.freedesktop.DBus",
+								    "/org/freedesktop/DBus",
+								    "org.freedesktop.DBus",
+								    NULL);
+    if ( !monitor->priv->session_proxy )
+    {
+	g_critical ("Unable to create proxy on /org/freedesktop/DBus");
+	return;
+    }
+    
+    dbus_g_proxy_add_signal (monitor->priv->session_proxy, "NameOwnerChanged", 
+			     G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+			     
+    dbus_g_proxy_connect_signal (monitor->priv->session_proxy, "NameOwnerChanged",
+				 G_CALLBACK (xfpm_dbus_monitor_session_name_owner_changed_cb), monitor, NULL);
+}
+
+static void
+xfpm_dbus_monitor_system (XfpmDBusMonitor *monitor)
+{
+    monitor->priv->system_proxy = dbus_g_proxy_new_for_name_owner (monitor->priv->system_bus,
+								   "org.freedesktop.DBus",
+								   "/org/freedesktop/DBus",
+								   "org.freedesktop.DBus",
+								   NULL);
+    if ( !monitor->priv->system_proxy )
+    {
+	g_critical ("Unable to create proxy on /org/freedesktop/DBus");
+	return;
+    }
+    
+    dbus_g_proxy_add_signal (monitor->priv->system_proxy, "NameOwnerChanged", 
+			     G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+			     
+    dbus_g_proxy_connect_signal (monitor->priv->system_proxy, "NameOwnerChanged",
+				 G_CALLBACK (xfpm_dbus_monitor_system_name_owner_changed_cb), monitor, NULL);
+}
+
+static void
+xfpm_dbus_monitor_class_init (XfpmDBusMonitorClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    signals [UNIQUE_NAME_LOST] =
+    	g_signal_new ("unique-name-lost",
+		      XFPM_TYPE_DBUS_MONITOR,
+		      G_SIGNAL_RUN_LAST,
+		      G_STRUCT_OFFSET (XfpmDBusMonitorClass, unique_name_lost),
+		      NULL, NULL,
+		      _xfpm_dbus_marshal_VOID__STRING_BOOLEAN,
+		      G_TYPE_NONE, 2, 
+		      G_TYPE_STRING, G_TYPE_BOOLEAN);
+		     
+    signals [SERVICE_CONNECTION_CHANGED] =
+    	g_signal_new ("service-connection-changed",
+		      XFPM_TYPE_DBUS_MONITOR,
+		      G_SIGNAL_RUN_LAST,
+		      G_STRUCT_OFFSET (XfpmDBusMonitorClass, service_connection_changed),
+		      NULL, NULL,
+		      _xfpm_dbus_marshal_VOID__STRING_BOOLEAN_BOOLEAN,
+		      G_TYPE_NONE, 3, G_TYPE_STRING,
+		      G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
+		      
+    signals [SYSTEM_BUS_CONNECTION_CHANGED] =
+    	g_signal_new ("system-bus-connection-changed",
+		      XFPM_TYPE_DBUS_MONITOR,
+		      G_SIGNAL_RUN_LAST,
+		      G_STRUCT_OFFSET (XfpmDBusMonitorClass, system_bus_connection_changed),
+		      NULL, NULL,
+		      g_cclosure_marshal_VOID__BOOLEAN,
+		      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+		     
+    object_class->finalize = xfpm_dbus_monitor_finalize;
+
+    g_type_class_add_private (klass, sizeof (XfpmDBusMonitorPrivate));
+}
+
+static void
+xfpm_dbus_monitor_init (XfpmDBusMonitor *monitor)
+{
+    monitor->priv = XFPM_DBUS_MONITOR_GET_PRIVATE (monitor);
+    
+    monitor->priv->session_proxy = NULL;
+    monitor->priv->system_proxy  = NULL;
+    
+    monitor->priv->names_array = g_ptr_array_new ();
+    monitor->priv->services_array = g_ptr_array_new ();
+         
+    monitor->priv->session_bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+    monitor->priv->system_bus  = dbus_g_bus_get (DBUS_BUS_SYSTEM,  NULL);
+    
+    xfpm_dbus_monitor_session (monitor);
+    xfpm_dbus_monitor_system  (monitor);
+    
+    dbus_connection_set_exit_on_disconnect (dbus_g_connection_get_connection (monitor->priv->system_bus), 
+					    FALSE);
+    
+    dbus_connection_add_filter (dbus_g_connection_get_connection (monitor->priv->system_bus),
+			        xfpm_dbus_monitor_system_bus_filter,
+				monitor, 
+				NULL);
+}
+
+static void
+xfpm_dbus_monitor_finalize (GObject *object)
+{
+    XfpmDBusMonitor *monitor;
+
+    monitor = XFPM_DBUS_MONITOR (object);
+    
+    if ( monitor->priv->session_proxy )
+    {
+	dbus_g_proxy_disconnect_signal (monitor->priv->session_proxy, "NameOwnerChanged",
+					G_CALLBACK (xfpm_dbus_monitor_session_name_owner_changed_cb), monitor);
+	g_object_unref (monitor->priv->session_proxy);
+    }
+
+    if ( monitor->priv->system_proxy )
+    {
+	dbus_g_proxy_disconnect_signal (monitor->priv->system_proxy, "NameOwnerChanged",
+				        G_CALLBACK (xfpm_dbus_monitor_system_name_owner_changed_cb), monitor);
+	g_object_unref (monitor->priv->system_proxy);
+    }
+
+    dbus_connection_remove_filter (dbus_g_connection_get_connection (monitor->priv->system_bus),
+				   xfpm_dbus_monitor_system_bus_filter,
+				   monitor);
+
+    dbus_g_connection_unref (monitor->priv->system_bus);
+    dbus_g_connection_unref (monitor->priv->session_bus);
+
+    g_ptr_array_foreach (monitor->priv->names_array, (GFunc) xfpm_dbus_monitor_free_watch_data, NULL);
+    g_ptr_array_foreach (monitor->priv->services_array, (GFunc) xfpm_dbus_monitor_free_watch_data, NULL);
+
+    g_ptr_array_free (monitor->priv->names_array, TRUE);
+    g_ptr_array_free (monitor->priv->services_array, TRUE);
+
+    G_OBJECT_CLASS (xfpm_dbus_monitor_parent_class)->finalize (object);
+}
+
+XfpmDBusMonitor *
+xfpm_dbus_monitor_new (void)
+{
+    static gpointer xfpm_dbus_monitor_object = NULL;
+    
+    if ( G_LIKELY (xfpm_dbus_monitor_object != NULL) )
+    {
+	g_object_ref (xfpm_dbus_monitor_object);
+    }
+    else
+    {
+	xfpm_dbus_monitor_object = g_object_new (XFPM_TYPE_DBUS_MONITOR, NULL);
+	g_object_add_weak_pointer (xfpm_dbus_monitor_object, &xfpm_dbus_monitor_object);
+    }
+    
+    return XFPM_DBUS_MONITOR (xfpm_dbus_monitor_object);
+}
+
+gboolean xfpm_dbus_monitor_add_unique_name (XfpmDBusMonitor *monitor, DBusBusType bus_type, const gchar *unique_name)
+{
+    XfpmWatchData *watch;
+    
+    g_return_val_if_fail (XFPM_IS_DBUS_MONITOR (monitor), FALSE);
+    g_return_val_if_fail (unique_name != NULL, FALSE);
+    
+    /* We have it already */
+    if ( xfpm_dbus_monitor_get_watch_data (monitor->priv->names_array, unique_name, bus_type) )
+	return FALSE;
+	
+    watch = g_new0 (XfpmWatchData , 1);
+    watch->name = g_strdup (unique_name);
+    watch->bus_type = bus_type;
+    
+    g_ptr_array_add (monitor->priv->names_array, watch);
+    return TRUE;
+}
+
+void xfpm_dbus_monitor_remove_unique_name (XfpmDBusMonitor *monitor, DBusBusType bus_type, const gchar *unique_name)
+{
+    XfpmWatchData *watch;
+    
+    g_return_if_fail (XFPM_IS_DBUS_MONITOR (monitor));
+
+    watch = xfpm_dbus_monitor_get_watch_data (monitor->priv->names_array, unique_name, bus_type);
+    
+    if ( watch )
+    {
+	g_ptr_array_remove (monitor->priv->names_array, watch);
+	xfpm_dbus_monitor_free_watch_data (watch);
+    }
+}
+
+gboolean xfpm_dbus_monitor_add_service (XfpmDBusMonitor *monitor, DBusBusType bus_type, const gchar *service_name)
+{
+    XfpmWatchData *watch;
+    
+    g_return_val_if_fail (XFPM_IS_DBUS_MONITOR (monitor), FALSE);
+    
+    if ( xfpm_dbus_monitor_get_watch_data (monitor->priv->services_array, service_name, bus_type ) )
+	return FALSE;
+	
+    watch = g_new0 (XfpmWatchData , 1);
+    watch->name = g_strdup (service_name);
+    watch->bus_type = bus_type;
+    
+    g_ptr_array_add (monitor->priv->services_array, watch);
+    
+    return TRUE;
+}
+
+void xfpm_dbus_monitor_remove_service (XfpmDBusMonitor *monitor, DBusBusType bus_type, const gchar *service_name)
+{
+    XfpmWatchData *watch;
+    
+    g_return_if_fail (XFPM_IS_DBUS_MONITOR (monitor));
+    
+    watch = xfpm_dbus_monitor_get_watch_data (monitor->priv->services_array, service_name, bus_type);
+    
+    if ( watch )
+    {
+	g_ptr_array_remove (monitor->priv->services_array, watch);
+	xfpm_dbus_monitor_free_watch_data (watch);
+    }
+}
diff --git a/libdbus/xfpm-dbus-monitor.h b/libdbus/xfpm-dbus-monitor.h
new file mode 100644
index 0000000..374e625
--- /dev/null
+++ b/libdbus/xfpm-dbus-monitor.h
@@ -0,0 +1,92 @@
+/* * 
+ *  Copyright (C) 2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __XFPM_DBUS_MONITOR_H
+#define __XFPM_DBUS_MONITOR_H
+
+#include <glib-object.h>
+#include <dbus/dbus.h>
+
+G_BEGIN_DECLS
+
+#define XFPM_TYPE_DBUS_MONITOR        (xfpm_dbus_monitor_get_type () )
+#define XFPM_DBUS_MONITOR(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_DBUS_MONITOR, XfpmDBusMonitor))
+#define XFPM_IS_DBUS_MONITOR(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_DBUS_MONITOR))
+
+typedef struct XfpmDBusMonitorPrivate XfpmDBusMonitorPrivate;
+
+typedef struct
+{
+    GObject        	 	parent;
+    XfpmDBusMonitorPrivate     *priv;
+    
+} XfpmDBusMonitor;
+
+typedef struct
+{
+    GObjectClass 	parent_class;
+    
+    /*
+     * Unique name connection lost.
+     */
+    void                (*unique_name_lost)			(XfpmDBusMonitor *monitor,
+								 gchar *unique_name,
+								 gboolean on_session);
+								 
+    /*
+     * A Service connection changed.
+     */
+    void                (*service_connection_changed)		(XfpmDBusMonitor *monitor,
+								 gchar *service_name,
+							         gboolean connected,
+								 gboolean on_session);
+								 
+    /*
+     * DBus: system bus disconnected
+     */
+    void		(*system_bus_connection_changed)  	(XfpmDBusMonitor *monitor,
+								 gboolean connected);
+    
+} XfpmDBusMonitorClass;
+
+GType        		xfpm_dbus_monitor_get_type        	(void) G_GNUC_CONST;
+
+XfpmDBusMonitor        *xfpm_dbus_monitor_new             	(void);
+
+void			xfpm_dbus_monitor_watch_system_bus	(XfpmDBusMonitor *monitor);
+
+gboolean                xfpm_dbus_monitor_add_unique_name     	(XfpmDBusMonitor *monitor,
+								 DBusBusType bus_type,
+								 const gchar *unique_name);
+								   
+void                    xfpm_dbus_monitor_remove_unique_name    (XfpmDBusMonitor *monitor,
+								 DBusBusType bus_type,
+								 const gchar *unique_name);
+
+gboolean		xfpm_dbus_monitor_add_service	  	(XfpmDBusMonitor *monitor,
+								 DBusBusType bus_type,
+								 const gchar *service_name);
+
+void			xfpm_dbus_monitor_remove_service  	(XfpmDBusMonitor *monitor,
+								 DBusBusType bus_type,
+								 const gchar *service_name);
+G_END_DECLS
+
+#endif /* __XFPM_DBUS_MONITOR_H */
diff --git a/libxfpm/xfpm-dbus.c b/libdbus/xfpm-dbus.c
similarity index 100%
rename from libxfpm/xfpm-dbus.c
rename to libdbus/xfpm-dbus.c
diff --git a/libdbus/xfpm-dbus.h b/libdbus/xfpm-dbus.h
new file mode 100644
index 0000000..dff2ef1
--- /dev/null
+++ b/libdbus/xfpm-dbus.h
@@ -0,0 +1,36 @@
+/*
+ * * Copyright (C) 2008 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __XFPM_DBUS_H
+#define __XFPM_DBUS_H
+
+#include <glib.h>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
+
+gboolean	xfpm_dbus_name_has_owner 	   (DBusConnection *bus,
+						    const gchar *name);
+					  
+gboolean        xfpm_dbus_register_name  	   (DBusConnection *bus,
+						    const gchar *name);
+					  
+gboolean        xfpm_dbus_release_name   	   (DBusConnection *bus,
+						    const gchar *name);
+#endif /* __XFPM_DBUS_H */
diff --git a/libdbus/xfpm-unique.c b/libdbus/xfpm-unique.c
new file mode 100644
index 0000000..9addfb7
--- /dev/null
+++ b/libdbus/xfpm-unique.c
@@ -0,0 +1,243 @@
+/*
+ * * Copyright (C) 2010 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "xfpm-unique.h"
+#include "xfpm-dbus.h"
+
+#include <dbus/dbus-glib-lowlevel.h>
+
+static void xfpm_unique_dbus_class_init 	(XfpmUniqueClass *klass);
+static void xfpm_unique_dbus_init		(XfpmUnique *unique);
+
+static void xfpm_unique_finalize   		(GObject *object);
+
+#define XFPM_UNIQUE_GET_PRIVATE(o) \
+(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_UNIQUE, XfpmUniquePrivate))
+
+struct XfpmUniquePrivate
+{
+    DBusGConnection *bus;
+    
+    gchar *name;
+};
+
+enum
+{
+    PROP_0,
+    PROP_NAME
+};
+
+enum
+{
+    PING_RECEIVED,
+    LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (XfpmUnique, xfpm_unique, G_TYPE_OBJECT)
+
+static void xfpm_unique_get_property (GObject *object,
+				      guint prop_id,
+                                      GValue *value,
+                                      GParamSpec *pspec)
+{
+    XfpmUnique *unique;
+    unique = XFPM_UNIQUE (object);
+    
+    switch (prop_id)
+    {
+	case PROP_NAME:
+	    g_value_set_string (value, unique->priv->name);
+	    break;
+	default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+
+}
+
+static void xfpm_unique_set_property (GObject *object,
+				      guint prop_id,
+                                      const GValue *value,
+                                      GParamSpec *pspec)
+{
+    
+    XfpmUnique *unique;
+    unique = XFPM_UNIQUE (object);
+    
+    switch (prop_id)
+    {
+	case PROP_NAME:
+	    unique->priv->name = g_value_dup_string (value);
+	    break;
+	default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+xfpm_unique_class_init (XfpmUniqueClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    object_class->finalize = xfpm_unique_finalize;
+    
+    object_class->set_property = xfpm_unique_set_property;
+    object_class->get_property = xfpm_unique_get_property;
+
+    signals [PING_RECEIVED] = 
+        g_signal_new ("ping-received",
+                      XFPM_TYPE_UNIQUE,
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET (XfpmUniqueClass, ping_received),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE, 0, G_TYPE_NONE);
+
+    g_object_class_install_property (object_class,
+                                     PROP_NAME,
+                                     g_param_spec_string  ("name",
+                                                           NULL, NULL,
+                                                           NULL,
+                                                           G_PARAM_READWRITE|
+							   G_PARAM_CONSTRUCT_ONLY));
+
+    g_type_class_add_private (klass, sizeof (XfpmUniquePrivate));
+    
+    xfpm_unique_dbus_class_init (klass);
+}
+
+static void
+xfpm_unique_init (XfpmUnique *unique)
+{
+    GError *error = NULL;
+    
+    unique->priv = XFPM_UNIQUE_GET_PRIVATE (unique);
+    
+    unique->priv->name = NULL;
+    
+    unique->priv->bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+    
+    if ( error )
+	g_error ("Failed to connect to the session bus : %s", error->message);
+	
+    xfpm_unique_dbus_init (unique);
+}
+
+static void
+xfpm_unique_finalize (GObject *object)
+{
+    XfpmUnique *unique;
+
+    unique = XFPM_UNIQUE (object);
+    
+    xfpm_dbus_release_name (dbus_g_connection_get_connection (unique->priv->bus),
+			    unique->priv->name);
+    
+    dbus_g_connection_unref (unique->priv->bus);
+    g_free (unique->priv->name);
+
+    G_OBJECT_CLASS (xfpm_unique_parent_class)->finalize (object);
+}
+
+XfpmUnique *
+xfpm_unique_new (const gchar *name)
+{
+    XfpmUnique *unique = NULL;
+    
+    unique = g_object_new (XFPM_TYPE_UNIQUE, "name", name, NULL);
+    
+    return unique;
+}
+
+gboolean xfpm_unique_app_is_running (XfpmUnique *unique)
+{
+    g_return_val_if_fail (XFPM_IS_UNIQUE (unique), FALSE);
+    
+    if (xfpm_dbus_name_has_owner (dbus_g_connection_get_connection (unique->priv->bus),
+				  unique->priv->name))
+    {
+	DBusGProxy *proxy;
+	GError *error = NULL;
+	
+	proxy = dbus_g_proxy_new_for_name (unique->priv->bus,
+					   unique->priv->name,
+					   "/org/xfce/unique",
+					   "org.xfce.unique");
+	
+	/*Shoudln't happen, but check anyway*/
+	if ( !proxy )
+	{
+	    g_critical ("Unable to create proxy for %s", unique->priv->name);
+	    return FALSE;
+	}
+	
+	dbus_g_proxy_call (proxy, "Ping", &error,
+			   G_TYPE_INVALID,
+			   G_TYPE_INVALID);
+			   
+	if ( error )
+	{
+	    g_warning ("Failed to 'Ping' %s", unique->priv->name);
+	    
+	}
+	
+	g_object_unref (proxy);
+	return TRUE;
+    }
+    
+    xfpm_dbus_register_name (dbus_g_connection_get_connection (unique->priv->bus),
+			     unique->priv->name);
+    
+    return FALSE;
+}
+
+static gboolean xfce_unique_ping (XfpmUnique *unique,
+				  GError *error);	
+
+#include "org.xfce.unique.h"
+
+static void xfpm_unique_dbus_class_init (XfpmUniqueClass *klass)
+{
+    dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass),
+                                     &dbus_glib_xfce_unique_object_info);
+}
+
+static void xfpm_unique_dbus_init (XfpmUnique *unique)
+{
+    dbus_g_connection_register_g_object (unique->priv->bus,
+                                         "/org/xfce/unique",
+                                         G_OBJECT (unique));
+}
+
+static gboolean xfce_unique_ping (XfpmUnique *unique,
+				  GError *error)
+{
+    g_signal_emit (unique, signals[PING_RECEIVED], 0);
+    return TRUE;
+}
diff --git a/libdbus/xfpm-unique.h b/libdbus/xfpm-unique.h
new file mode 100644
index 0000000..147b414
--- /dev/null
+++ b/libdbus/xfpm-unique.h
@@ -0,0 +1,57 @@
+/*
+ * * Copyright (C) 2010 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __XFPM_UNIQUE_H
+#define __XFPM_UNIQUE_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define XFPM_TYPE_UNIQUE        (xfpm_unique_get_type () )
+#define XFPM_UNIQUE(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_UNIQUE, XfpmUnique))
+#define XFPM_IS_UNIQUE(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_UNIQUE))
+
+typedef struct XfpmUniquePrivate XfpmUniquePrivate;
+
+typedef struct
+{
+    GObject         	   parent;
+    XfpmUniquePrivate     *priv;
+    
+} XfpmUnique;
+
+typedef struct
+{
+    GObjectClass	   parent_class;
+    
+    void		  (*ping_received)	       (XfpmUnique *unique);
+    
+} XfpmUniqueClass;
+
+GType        		   xfpm_unique_get_type        (void) G_GNUC_CONST;
+
+XfpmUnique                *xfpm_unique_new             (const gchar *name);
+
+gboolean		   xfpm_unique_app_is_running  (XfpmUnique *unique);
+
+G_END_DECLS
+
+#endif /* __XFPM_UNIQUE_H */
diff --git a/libhal/Makefile.am b/libhal/Makefile.am
new file mode 100644
index 0000000..d6e6853
--- /dev/null
+++ b/libhal/Makefile.am
@@ -0,0 +1,40 @@
+noinst_LTLIBRARIES = 			\
+	libxfpmhal.la
+
+libxfpmhal_la_SOURCES =			\
+	hal-manager.c			\
+	hal-manager.h			\
+	hal-device.c			\
+	hal-device.h			\
+	hal-marshal.c			\
+	hal-marshal.h
+
+libxfpmhal_la_CFLAGS =			\
+	-I$(top_srcdir) 	        \
+	-I$(top_srcdir)/libdbus         \
+	$(GLIB_CFLAGS)			\
+	$(DBUS_GLIB_CFLAGS)
+
+libxfpmhal_la_LIBADD =			\
+	$(top_builddir)/libdbus/libxfpmdbus.la
+
+if MAINTAINER_MODE
+
+BUILT_SOURCES =				\
+	hal-marshal.c			\
+	hal-marshal.h
+
+hal-marshal.c: hal-marshal.list
+	echo "#include \"hal-marshal.h\"" > $@ && \
+	glib-genmarshal $< --prefix=_hal_marshal --body >> $@
+
+hal-marshal.h: hal-marshal.list
+	glib-genmarshal $< --prefix=_hal_marshal --header > $@
+
+endif
+
+EXTRA_DIST =				\
+	hal-marshal.list
+
+DISTCLEANFILES =			\
+	$(BUILT_SOURCES)
\ No newline at end of file
diff --git a/libxfpm/hal-device.c b/libhal/hal-device.c
similarity index 100%
rename from libxfpm/hal-device.c
rename to libhal/hal-device.c
diff --git a/libxfpm/hal-device.h b/libhal/hal-device.h
similarity index 100%
rename from libxfpm/hal-device.h
rename to libhal/hal-device.h
diff --git a/libhal/hal-manager.c b/libhal/hal-manager.c
new file mode 100644
index 0000000..7ec8a61
--- /dev/null
+++ b/libhal/hal-manager.c
@@ -0,0 +1,282 @@
+/*
+ * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include <glib.h>
+
+#include "hal-manager.h"
+#include "hal-device.h"
+
+#include "libdbus/xfpm-dbus-monitor.h"
+#include "libdbus/xfpm-dbus.h"
+
+static void hal_manager_finalize   (GObject *object);
+
+#define HAL_MANAGER_GET_PRIVATE(o) \
+(G_TYPE_INSTANCE_GET_PRIVATE((o), HAL_TYPE_MANAGER, HalManagerPrivate))
+
+struct HalManagerPrivate
+{
+    XfpmDBusMonitor *monitor;
+    DBusGConnection *bus;
+    DBusGProxy      *proxy;
+    gboolean 	     connected;
+    gboolean         is_laptop;
+    
+    gulong	     sig_hal;
+};
+
+enum
+{
+    DEVICE_ADDED,
+    DEVICE_REMOVED,
+    CONNECTION_CHANGED,
+    LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (HalManager, hal_manager, G_TYPE_OBJECT)
+
+static void
+hal_manager_device_added_cb (DBusGProxy *proxy, const gchar *udi, HalManager *manager)
+{
+    g_signal_emit (G_OBJECT(manager), signals[DEVICE_ADDED], 0, udi);
+}
+
+static void
+hal_manager_device_removed_cb (DBusGProxy *proxy, const gchar *udi, HalManager *manager)
+{
+    g_signal_emit (G_OBJECT(manager), signals[DEVICE_REMOVED], 0, udi);
+}
+
+static void
+hal_manager_connect (HalManager *manager)
+{
+    GError *error = NULL;
+    
+    manager->priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+    
+    if ( error )
+    {
+	g_critical ("Failed to get bus system %s\n", error->message);
+	g_error_free (error);
+	goto out;
+    }
+    
+    manager->priv->connected = xfpm_dbus_name_has_owner (dbus_g_connection_get_connection (manager->priv->bus),
+							 "org.freedesktop.Hal");
+    
+    if ( !manager->priv->connected )
+	goto out;
+    
+    manager->priv->proxy = dbus_g_proxy_new_for_name (manager->priv->bus,
+		  				      "org.freedesktop.Hal",
+						      "/org/freedesktop/Hal/Manager",
+						      "org.freedesktop.Hal.Manager");
+    
+    if ( !manager->priv->proxy )
+    {
+	g_critical ("Unable to get proxy for \n");
+	goto out;
+    }
+    
+    dbus_g_proxy_add_signal (manager->priv->proxy, "DeviceAdded",
+			     G_TYPE_STRING, G_TYPE_INVALID);
+			     
+    dbus_g_proxy_connect_signal (manager->priv->proxy, "DeviceAdded",
+				 G_CALLBACK (hal_manager_device_added_cb), manager, NULL);
+
+    dbus_g_proxy_add_signal (manager->priv->proxy, "DeviceRemoved",
+			     G_TYPE_STRING, G_TYPE_INVALID);
+	
+    dbus_g_proxy_connect_signal (manager->priv->proxy, "DeviceRemoved",
+				 G_CALLBACK (hal_manager_device_removed_cb), manager, NULL);
+out:
+	;
+}
+
+static void
+hal_manager_service_connection_changed_cb (XfpmDBusMonitor *monitor, 
+					   gchar *service_name, 
+					   gboolean is_connected,
+					   gboolean on_session, 
+					   HalManager *manager)
+{
+    if ( !on_session)
+    {
+	if (!g_strcmp0 (service_name, "org.freedesktop.Hal") )
+	{
+	    if ( manager->priv->connected != is_connected )
+	    {
+		manager->priv->connected = is_connected;
+		g_signal_emit (G_OBJECT (manager), signals [CONNECTION_CHANGED], 0, is_connected);
+	    }
+	}
+    }
+}
+
+static void
+hal_manager_class_init (HalManagerClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS(klass);
+    
+    signals[DEVICE_ADDED] =
+    	g_signal_new("device-added",
+		     HAL_TYPE_MANAGER,
+		     G_SIGNAL_RUN_LAST,
+		     G_STRUCT_OFFSET(HalManagerClass, device_added),
+		     NULL, NULL,
+		     g_cclosure_marshal_VOID__STRING,
+		     G_TYPE_NONE, 1, G_TYPE_STRING);
+		     
+    signals[DEVICE_REMOVED] =
+    	g_signal_new("device-removed",
+		     HAL_TYPE_MANAGER,
+		     G_SIGNAL_RUN_LAST,
+		     G_STRUCT_OFFSET(HalManagerClass, device_removed),
+		     NULL, NULL,
+		     g_cclosure_marshal_VOID__STRING,
+		     G_TYPE_NONE, 1, G_TYPE_STRING);
+    
+    signals[CONNECTION_CHANGED] =
+    	g_signal_new("connection-changed",
+		     HAL_TYPE_MANAGER,
+		     G_SIGNAL_RUN_LAST,
+		     G_STRUCT_OFFSET(HalManagerClass, connection_changed),
+		     NULL, NULL,
+		     g_cclosure_marshal_VOID__VOID,
+		     G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+    
+    object_class->finalize = hal_manager_finalize;
+
+    g_type_class_add_private (klass,sizeof(HalManagerPrivate));
+}
+
+static void
+hal_manager_init (HalManager *manager)
+{
+    manager->priv = HAL_MANAGER_GET_PRIVATE (manager);
+    
+    manager->priv->bus 	     = NULL;
+    manager->priv->proxy     = NULL;
+    manager->priv->connected = FALSE;
+    manager->priv->monitor   = xfpm_dbus_monitor_new ();
+    
+    hal_manager_connect (manager);
+    
+    xfpm_dbus_monitor_add_service (manager->priv->monitor, DBUS_BUS_SYSTEM, "org.freedesktop.Hal");
+    
+    manager->priv->sig_hal = 
+    g_signal_connect (manager->priv->monitor, "service-connection-changed",
+		      G_CALLBACK (hal_manager_service_connection_changed_cb), manager);
+}
+
+static void
+hal_manager_finalize (GObject *object)
+{
+    HalManager *manager;
+
+    manager = HAL_MANAGER(object);
+
+    if ( g_signal_handler_is_connected (manager->priv->monitor, manager->priv->sig_hal) )
+	g_signal_handler_disconnect (manager->priv->monitor, manager->priv->sig_hal);
+    
+    if ( manager->priv->proxy )
+	g_object_unref (manager->priv->proxy);
+	
+    if ( manager->priv->bus )
+	dbus_g_connection_unref (manager->priv->bus);
+
+    xfpm_dbus_monitor_remove_service (manager->priv->monitor, DBUS_BUS_SYSTEM, "org.freedesktop.Hal");
+
+    g_object_unref (manager->priv->monitor);
+
+    G_OBJECT_CLASS(hal_manager_parent_class)->finalize(object);
+}
+
+HalManager *
+hal_manager_new (void)
+{
+    static gpointer hal_manager_object = NULL;
+    
+    if ( hal_manager_object != NULL )
+    {
+	g_object_ref (hal_manager_object);
+    }
+    else
+    {
+	hal_manager_object = g_object_new (HAL_TYPE_MANAGER, NULL);
+	g_object_add_weak_pointer (hal_manager_object, &hal_manager_object);
+    }
+    
+    return HAL_MANAGER (hal_manager_object);
+}
+
+gchar **hal_manager_find_device_by_capability (HalManager *manager, const gchar *capability)
+{
+    GError *error = NULL;
+    gchar  **udi = NULL;
+    
+    g_return_val_if_fail (HAL_IS_MANAGER(manager), NULL);
+    g_return_val_if_fail (manager->priv->connected, NULL);
+    
+    dbus_g_proxy_call (manager->priv->proxy, "FindDeviceByCapability", &error, 
+		       G_TYPE_STRING, capability, 
+		       G_TYPE_INVALID,
+		       G_TYPE_STRV, &udi,
+		       G_TYPE_INVALID);
+    if ( error )
+    {
+	g_critical ("Error finding devices by capability %s\n", error->message);
+	g_error_free (error);
+    }
+    
+    return udi;
+}
+
+void hal_manager_free_string_array (gchar **array)
+{
+    gint i;
+
+    if (array == NULL)	
+	    return;
+    
+    for (i=0; array[i]; i++) 
+	g_free (array[i]);
+    
+    g_free (array);
+}
+
+gboolean hal_manager_get_is_connected (HalManager *manager)
+{
+    g_return_val_if_fail (HAL_IS_MANAGER (manager), FALSE);
+    
+    return manager->priv->connected;
+}
diff --git a/libhal/hal-manager.h b/libhal/hal-manager.h
new file mode 100644
index 0000000..76e94be
--- /dev/null
+++ b/libhal/hal-manager.h
@@ -0,0 +1,69 @@
+/*
+ * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __HAL_MANAGER_H
+#define __HAL_MANAGER_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define HAL_TYPE_MANAGER        (hal_manager_get_type () )
+#define HAL_MANAGER(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), HAL_TYPE_MANAGER, HalManager))
+#define HAL_IS_MANAGER(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), HAL_TYPE_MANAGER))
+
+typedef struct HalManagerPrivate HalManagerPrivate;
+
+typedef struct
+{
+    GObject		  	parent;
+    HalManagerPrivate	       *priv;
+    
+} HalManager;
+
+typedef struct
+{
+    GObjectClass 		parent_class;
+    
+    void		        (*device_added)				(HalManager *manager,
+									 const gchar *udi);
+    void                        (*device_removed)			(HalManager *manager,
+									 const gchar *udi);
+    
+    void			(*connection_changed)			(HalManager *manager,
+									 gboolean connected);
+    
+} HalManagerClass;
+
+GType        	  		hal_manager_get_type        		(void) G_GNUC_CONST;
+HalManager       	       *hal_manager_new            		(void);
+
+gchar 			      **hal_manager_find_device_by_capability 	(HalManager *manager,
+									 const gchar *capability);
+
+gboolean                        hal_manager_get_is_laptop               (HalManager *manager) G_GNUC_PURE;
+						 
+void                            hal_manager_free_string_array           (gchar **array);
+
+gboolean			hal_manager_get_is_connected		(HalManager *manager);
+
+G_END_DECLS
+
+#endif /* __HAL_MANAGER_H */
diff --git a/libxfpm/hal-marshal.list b/libhal/hal-marshal.list
similarity index 100%
rename from libxfpm/hal-marshal.list
rename to libhal/hal-marshal.list
diff --git a/libxfpm/Makefile.am b/libxfpm/Makefile.am
deleted file mode 100644
index ecdc403..0000000
--- a/libxfpm/Makefile.am
+++ /dev/null
@@ -1,69 +0,0 @@
-noinst_LTLIBRARIES = 			\
-	libxfpmhal.la			\
-	libxfpmhalpower.la		\
-	libxfpmcommon.la
-
-libxfpmhal_la_SOURCES =			\
-	hal-manager.c			\
-	hal-manager.h			\
-	hal-device.c			\
-	hal-device.h			\
-	hal-marshal.c			\
-	hal-marshal.h
-
-libxfpmhal_la_CFLAGS =			\
-	$(GLIB_CFLAGS)			\
-	$(DBUS_GLIB_CFLAGS)
-
-libxfpmhalpower_la_SOURCES =		\
-	hal-power.c			\
-	hal-power.h			\
-	hal-battery.c			\
-	hal-battery.h			\
-	hal-enum.h
-
-libxfpmhalpower_la_CFLAGS  =		\
-	$(GLIB_CFLAGS)			\
-	$(DBUS_GLIB_CFLAGS)
-
-libxfpmcommon_la_SOURCES =      	\
-        xfpm-string.c           	\
-        xfpm-string.h           	\
-        xfpm-dbus.c             	\
-        xfpm-dbus.h             	\
-        xfpm-popups.c           	\
-        xfpm-popups.h           	\
-        xfpm-common.c           	\
-        xfpm-common.h			\
-	xfpm-notify.c			\
-	xfpm-notify.h			\
-	xfpm-icons.h
-
-libxfpmcommon_la_CFLAGS =       	\
-        $(GTK_CFLAGS)           	\
-        $(GLIB_CFLAGS)          	\
-        $(DBUS_CFLAGS)			\
-	$(LIBXFCE4UTIL_CFLAGS)		\
-	$(LIBXFCEGUI4_CFLAGS)		\
-	$(LIBNOTIFY_CFLAGS)
-
-if MAINTAINER_MODE
-
-BUILT_SOURCES =				\
-	hal-marshal.c			\
-	hal-marshal.h
-
-hal-marshal.c: hal-marshal.list
-	echo "#include \"hal-marshal.h\"" > $@ && \
-	glib-genmarshal $< --prefix=_hal_marshal --body >> $@
-
-hal-marshal.h: hal-marshal.list
-	glib-genmarshal $< --prefix=_hal_marshal --header > $@
-
-endif
-
-EXTRA_DIST =				\
-	hal-marshal.list
-
-DISTCLEANFILES =			\
-	$(BUILT_SOURCES)
\ No newline at end of file
diff --git a/libxfpm/hal-battery.c b/libxfpm/hal-battery.c
deleted file mode 100644
index 5a3734b..0000000
--- a/libxfpm/hal-battery.c
+++ /dev/null
@@ -1,554 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <glib.h>
-#include <glib/gi18n.h>
-
-#include "hal-battery.h"
-#include "hal-manager.h"
-#include "hal-enum.h"
-
-static void hal_battery_finalize   (GObject *object);
-
-static void hal_battery_get_property(GObject *object,
-				    guint prop_id,
-				    GValue *value,
-				    GParamSpec *pspec);
-
-#define HAL_BATTERY_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), HAL_TYPE_BATTERY, HalBatteryPrivate))
-
-#define FREE_STR_PROP(str)            		    \
-    if ( str )                                      \
-        g_free (str);                               \
-    str = NULL;
-
-struct HalBatteryPrivate
-{
-    /* Properties read-only */
-    HalDeviceType type;
-    
-    gboolean  is_present;
-    gboolean  is_charging;
-    gboolean  is_discharging;
-    
-    guint     percentage;
-
-    guint32   current_charge;
-    guint32   last_full;
-    
-    guint32   reporting_design;
-    guint32   reporting_last_full;
-    
-    guint      time;
-    
-};
-
-enum
-{
-    PROP_0,
-    PROP_TYPE,
-    PROP_IS_PRESENT,
-    PROP_IS_CHARGING,
-    PROP_IS_DISCHARGING,
-    PROP_CURRENT_CHARGE,
-    PROP_PERCENTAGE,
-    PROP_REPORTING_DESIGN,
-    PROP_LAST_FULL,
-    PROP_REPORTING_LAST_FULL,
-    PROP_TIME,
-    PROP_TECHNOLOGY,
-    PROP_VENDOR,
-    PROP_MODEL,
-    PROP_UNIT
-};
-
-enum
-{
-    BATTERY_CHANGED,
-    LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(HalBattery, hal_battery, HAL_TYPE_DEVICE)
-
-static gchar *
-hal_battery_get_info_string (HalBattery *battery, const gchar *key)
-{
-    gchar *val = NULL;
-    
-    if ( hal_device_has_key (HAL_DEVICE (battery), key) )
-    {
-	val = hal_device_get_property_string (HAL_DEVICE(battery), key);
-    }
-    
-    return val;
-}
-
-static void
-hal_battery_class_init(HalBatteryClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-    object_class->get_property = hal_battery_get_property;
-    object_class->finalize = hal_battery_finalize;
-
-    signals[BATTERY_CHANGED] =
-    	g_signal_new("battery-changed",
-		     HAL_TYPE_BATTERY,
-		     G_SIGNAL_RUN_LAST,
-		     G_STRUCT_OFFSET(HalBatteryClass, battery_changed),
-		     NULL, NULL,
-		     g_cclosure_marshal_VOID__VOID,
-		     G_TYPE_NONE, 0, G_TYPE_NONE);
-    
-    g_object_class_install_property(object_class,
-				    PROP_IS_PRESENT,
-				    g_param_spec_boolean("is-present",
-				    			 NULL, NULL,
-							 FALSE,
-							 G_PARAM_READABLE));
-
-    g_object_class_install_property(object_class,
-				    PROP_IS_CHARGING,
-				    g_param_spec_boolean("is-charging",
-							 NULL, NULL,
-							 FALSE,
-							 G_PARAM_READABLE));
-							 
-    g_object_class_install_property(object_class,
-				    PROP_IS_DISCHARGING,
-				    g_param_spec_boolean("is-discharging",
-							 NULL, NULL,
-							 FALSE,
-							 G_PARAM_READABLE));
-    g_object_class_install_property(object_class,
-				    PROP_CURRENT_CHARGE,
-				    g_param_spec_uint("current-charge",
-						      NULL, NULL,
-						      0,
-						      G_MAXUINT32,
-						      0,
-						      G_PARAM_READABLE));
-						      
-    g_object_class_install_property(object_class,
-				    PROP_LAST_FULL,
-				    g_param_spec_uint("last-full",
-						      NULL, NULL,
-						      0,
-						      G_MAXUINT32,
-						      0,
-						      G_PARAM_READABLE));
-						      
-     g_object_class_install_property(object_class,
-				    PROP_REPORTING_DESIGN,
-				    g_param_spec_uint("reporting-design",
-						      NULL, NULL,
-						      0,
-						      G_MAXUINT32,
-						      0,
-						      G_PARAM_READABLE));
-    g_object_class_install_property(object_class,
-				    PROP_REPORTING_LAST_FULL,
-				    g_param_spec_uint("reporting-last-full",
-						      NULL, NULL,
-						      0,
-						      G_MAXUINT32,
-						      0,
-						      G_PARAM_READABLE));
-    g_object_class_install_property(object_class,
-				    PROP_TIME,
-				    g_param_spec_uint("time",
-						      NULL, NULL,
-						      0,
-						      G_MAXINT,
-						      0,
-						      G_PARAM_READABLE));
-    g_object_class_install_property(object_class,
-				    PROP_TYPE,
-				    g_param_spec_uint("type",
-						      NULL, NULL,
-						      0,
-						      HAL_DEVICE_TYPE_UNKNOWN,
-						      HAL_DEVICE_TYPE_UNKNOWN,
-						      G_PARAM_READABLE));
-    g_object_class_install_property(object_class,
-				    PROP_PERCENTAGE,
-				    g_param_spec_uint("percentage",
-						      NULL, NULL,
-						      0,
-						      G_MAXINT,
-						      0,
-						      G_PARAM_READABLE));
-						      
-    g_object_class_install_property(object_class,
-				    PROP_TECHNOLOGY,
-				    g_param_spec_string("technology",
-							NULL, NULL,
-						        NULL,
-						        G_PARAM_READABLE));
-     g_object_class_install_property(object_class,
-				    PROP_VENDOR,
-				    g_param_spec_string("vendor",
-							NULL, NULL,
-						        NULL,
-						        G_PARAM_READABLE));
-    g_object_class_install_property(object_class,
-				    PROP_MODEL,
-				    g_param_spec_string("model",
-							NULL, NULL,
-						        NULL,
-						        G_PARAM_READABLE));
-    g_object_class_install_property(object_class,
-				    PROP_UNIT,
-				    g_param_spec_string("unit",
-							 NULL, NULL,
-							 NULL,
-							 G_PARAM_READABLE));
-							 
-    g_type_class_add_private(klass,sizeof(HalBatteryPrivate));
-}
-
-static void
-hal_battery_init (HalBattery *battery)
-{
-
-    battery->priv = HAL_BATTERY_GET_PRIVATE(battery);
-    
-    battery->priv->is_present      = FALSE;
-    battery->priv->is_charging     = FALSE;
-    battery->priv->is_discharging  = FALSE;
-
-    battery->priv->type            = HAL_DEVICE_TYPE_UNKNOWN;
-    
-    battery->priv->percentage      = 0;
-    battery->priv->current_charge  = 0;
-    battery->priv->last_full       = 0;
-    battery->priv->time            = 0;
-    battery->priv->reporting_design = 0;
-    battery->priv->reporting_last_full = 0;
-}
-
-static const gchar * G_GNUC_PURE
-_translate_technology (const gchar *tech)
-{
-    if ( !g_strcmp0 (tech, "lithium-ion") )
-    {
-	return _("Lithium ion");
-    }
-    else if ( !g_strcmp0 (tech, "lead-acid") )
-    {
-	return _("Lead acid");
-    }
-    else if ( !g_strcmp0 (tech, "lithium-polymer") )
-    {
-	return _("Lithium polymer");
-    }
-    else if ( !g_strcmp0 (tech, "nickel-metal-hydride") )
-    {
-	return _("Nickel metal hydride");
-    }
-    
-    return _("Unknown");
-}
-
-static const gchar * G_GNUC_PURE
-_translate_unit (const gchar *unit)
-{
-    if ( !g_strcmp0 (unit, "mWh") )
-    {
-	return _("mWh");
-    }
-    else if ( !g_strcmp0 (unit, "mAh") )
-    {
-	return _("mAh");
-    }
-    
-    return _("Unknown unit");
-}
-
-static void hal_battery_get_property(GObject *object,
-				    guint prop_id,
-				    GValue *value,
-				    GParamSpec *pspec)
-{
-    HalBattery *battery;
-    battery = HAL_BATTERY(object);
-
-    switch (prop_id)
-    {
-	case PROP_TYPE:
-		g_value_set_uint (value, battery->priv->type);
-		break;
-	case PROP_IS_PRESENT:
-		g_value_set_boolean (value, battery->priv->is_present);
-		break;
-	case PROP_IS_CHARGING:
-		g_value_set_boolean (value, battery->priv->is_charging);
-		break;
-	case PROP_IS_DISCHARGING:
-		g_value_set_boolean (value, battery->priv->is_discharging);
-		break;
-		
-	case PROP_UNIT:
-	{
-		gchar *unit = NULL;
-		gchar *val;
-		val = hal_battery_get_info_string (battery, "battery.reporting.unit");
-		if ( val )
-		{
-		    unit = g_strdup(_translate_unit (val));
-		    g_free (val);
-		}
-		g_value_set_string (value, unit);
-		break;
-	}
-	case PROP_TECHNOLOGY:
-	{
-		gchar *val;
-		gchar *technology = NULL;
-		val = hal_battery_get_info_string (battery, "battery.technology");
-		if ( val )
-		{
-		    technology = g_strdup (_translate_technology (val));
-		    g_free (val);
-		}
-		
-		g_value_set_string (value, technology);
-		g_free (technology);
-		break;
-	}
-	case PROP_VENDOR:
-	{
-		gchar *vendor = NULL;
-		vendor = hal_battery_get_info_string (battery, "battery.vendor");
-		g_value_set_string (value, vendor);
-		g_free (vendor);
-		break;
-	}
-	case PROP_MODEL:
-	{
-		gchar *model = NULL;
-		model = hal_battery_get_info_string (battery, "battery.model");
-		g_value_set_string (value, model);
-		g_free (model);
-		break;
-	}
-	case PROP_PERCENTAGE:
-		g_value_set_uint (value, battery->priv->percentage);
-		break;
-	case PROP_CURRENT_CHARGE:
-		g_value_set_uint (value, battery->priv->current_charge);
-		break;
-	case PROP_LAST_FULL:
-		g_value_set_uint (value, battery->priv->last_full);
-		break;
-	case PROP_REPORTING_DESIGN:
-		g_value_set_uint (value, battery->priv->reporting_design);
-		break;
-	case PROP_REPORTING_LAST_FULL:
-		g_value_set_uint (value, battery->priv->reporting_last_full);
-		break;	
-	case PROP_TIME:
-		g_value_set_uint (value, battery->priv->time);
-		break;
-	default:
-            G_OBJECT_WARN_INVALID_PROPERTY_ID(object,prop_id,pspec);
-            break;
-    }
-}
-
-static void
-hal_battery_finalize(GObject *object)
-{
-    HalBattery *battery;
-
-    battery = HAL_BATTERY(object);
-    
-    G_OBJECT_CLASS(hal_battery_parent_class)->finalize(object);
-}
-
-static HalDeviceType G_GNUC_PURE
-hal_battery_type_enum_from_string(const gchar *string)
-{
-    if ( !g_strcmp0 (string, "primary") )
-    {
-	return HAL_DEVICE_TYPE_PRIMARY;
-    }
-    else if ( !g_strcmp0 (string, "ups") )
-    {
-	return HAL_DEVICE_TYPE_UPS;
-    }
-    else if ( !g_strcmp0 (string, "mouse") )
-    {
-	return HAL_DEVICE_TYPE_MOUSE;
-    }
-    else if ( !g_strcmp0 (string, "keyboard") )
-    {
-	return HAL_DEVICE_TYPE_KEYBOARD;
-    }
-    else if ( !g_strcmp0 (string, "camera") )
-    {
-	return HAL_DEVICE_TYPE_CAMERA;
-    }
-    else if ( !g_strcmp0 (string, "keyboard_mouse") )
-    {
-	return HAL_DEVICE_TYPE_KEYBOARD_MOUSE;
-    }
-    
-    return HAL_DEVICE_TYPE_UNKNOWN;
-}
-
-static HalDeviceType
-hal_battery_get_device_type (HalBattery *battery)
-{
-    const gchar *udi;
-    gchar *type = NULL;
-    
-    HalDeviceType type_enum = HAL_DEVICE_TYPE_UNKNOWN;
-    
-    udi = hal_device_get_udi (HAL_DEVICE(battery));
-    
-    g_return_val_if_fail (udi != NULL, HAL_DEVICE_TYPE_UNKNOWN);
-    
-    type = hal_device_get_property_string (HAL_DEVICE(battery), "battery.type");
-    
-    if ( type )
-    {
-	type_enum  = hal_battery_type_enum_from_string(type);
-	g_free(type);
-    }
-    return type_enum;
-}
-
-static guint G_GNUC_CONST
-_get_battery_percentage (guint32 last_full, guint32 current)
-{
-    guint val = 100;
-    float f;
-    
-    if ( G_UNLIKELY (last_full <= current) ) return val;
-    
-    /*
-     * Special case when we get 0 as last full
-     * this happens for me once i had the battery
-     * totally empty on my aspire one.
-     */
-    if ( G_UNLIKELY (last_full == 0 ) )
-	return 0;
-	
-    f = (float)current/last_full *100;
-	
-	val = (guint)f;
-	
-    return val;   
-}
-
-static void
-hal_battery_refresh_all (HalBattery *battery)
-{
-    
-    battery->priv->is_present = 
-    	hal_device_get_property_bool(HAL_DEVICE(battery), "battery.present");
-	
-    battery->priv->is_charging = 
-    	hal_device_get_property_bool(HAL_DEVICE(battery), "battery.rechargeable.is_charging");
-    
-    battery->priv->is_discharging = 
-    	hal_device_get_property_bool(HAL_DEVICE(battery), "battery.rechargeable.is_discharging");
-    
-    battery->priv->current_charge = 
-    	hal_device_get_property_int(HAL_DEVICE(battery), "battery.charge_level.current");
-	
-    battery->priv->last_full = 
-    	hal_device_get_property_int(HAL_DEVICE(battery), "battery.charge_level.last_full");
-    
-    if ( hal_device_has_key (HAL_DEVICE(battery), "battery.remaining_time") )
-    	battery->priv->time = 
-    		hal_device_get_property_int(HAL_DEVICE(battery), "battery.remaining_time");
-    else
-    	battery->priv->time = 0;
-    
-    if ( hal_device_has_key(HAL_DEVICE(battery), "battery.charge_level.percentage") )
-     	battery->priv->percentage = 
-    		hal_device_get_property_int(HAL_DEVICE(battery), "battery.charge_level.percentage");
-    else battery->priv->percentage = _get_battery_percentage(battery->priv->last_full, battery->priv->current_charge);
-    
-    if ( hal_device_has_key(HAL_DEVICE(battery), "battery.reporting.last_full") )
-     	battery->priv->reporting_last_full = 
-    		hal_device_get_property_int(HAL_DEVICE(battery), "battery.reporting.last_full");
-
-    battery->priv->reporting_design = hal_device_get_property_int (HAL_DEVICE(battery), 
-								   "battery.reporting.design");
-}
-
-static void
-hal_battery_battery_changed_cb (HalBattery *battery, const gchar *key)
-{
-    if ( !g_strcmp0 (key, "battery.present") ||
-    	 !g_strcmp0 (key, "battery.rechargeable.is_charging") ||
-	 !g_strcmp0 (key, "battery.rechargeable.is_discharging") ||
-	 !g_strcmp0 (key, "battery.charge_level.current")    ||
-	 !g_strcmp0 (key, "battery.remaining_time") ||
-	 !g_strcmp0 (key, "battery.charge_level.percentage") )
-    {
-	hal_battery_refresh_all (battery);
-    	g_signal_emit (G_OBJECT (battery), signals[BATTERY_CHANGED], 0);
-    }
-}
-
-static void
-hal_battery_property_modified_cb(HalBattery *battery, 
-			         const gchar *udi,
-				 const gchar *key, 
-			         gboolean is_removed,
-			         gboolean is_added,
-				 gpointer data)
-{
-    hal_battery_battery_changed_cb (battery, key);
-}
-
-HalBattery *
-hal_battery_new (const gchar *udi)
-{
-    HalBattery *battery = NULL;
-    
-    battery = g_object_new (HAL_TYPE_BATTERY, NULL);
-    hal_device_set_udi (HAL_DEVICE(battery), udi);
-    
-    battery->priv->type = hal_battery_get_device_type (battery);
-   
-    hal_battery_refresh_all (battery);
-	
-    hal_device_watch (HAL_DEVICE(battery));
-    
-    g_signal_connect (G_OBJECT(battery), "device-changed",
-		      G_CALLBACK(hal_battery_property_modified_cb), battery);
-    return battery;
-}
diff --git a/libxfpm/hal-battery.h b/libxfpm/hal-battery.h
deleted file mode 100644
index c751fca..0000000
--- a/libxfpm/hal-battery.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __HAL_BATTERY_H
-#define __HAL_BATTERY_H
-
-#include <glib-object.h>
-
-#include "hal-device.h"
-#include "hal-enum.h"
-
-G_BEGIN_DECLS
-
-#define HAL_TYPE_BATTERY        (hal_battery_get_type () )
-#define HAL_BATTERY(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), HAL_TYPE_BATTERY, HalBattery))
-#define HAL_IS_BATTERY(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), HAL_TYPE_BATTERY))
-
-typedef struct HalBatteryPrivate HalBatteryPrivate;
-
-typedef struct
-{
-    HalDevice		   parent;
-    HalBatteryPrivate	  *priv;
-    
-} HalBattery;
-
-typedef struct
-{
-    HalDeviceClass         parent_class;
-    
-    void                  (*battery_changed) (HalBattery *device);
-    
-} HalBatteryClass;
-
-GType        	  hal_battery_get_type        (void) G_GNUC_CONST;
-HalBattery       *hal_battery_new             (const gchar *udi);
-
-G_END_DECLS
-
-#endif /* __HAL_BATTERY_H */
diff --git a/libxfpm/hal-enum.h b/libxfpm/hal-enum.h
deleted file mode 100644
index ddb8b20..0000000
--- a/libxfpm/hal-enum.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __HAL_ENUM_H
-#define __HAL_ENUM_H
-
-typedef enum
-{
-    HAL_DEVICE_TYPE_PRIMARY,
-    HAL_DEVICE_TYPE_UPS,
-    HAL_DEVICE_TYPE_MOUSE,
-    HAL_DEVICE_TYPE_KEYBOARD,
-    HAL_DEVICE_TYPE_KEYBOARD_MOUSE,
-    HAL_DEVICE_TYPE_CAMERA,
-    HAL_DEVICE_TYPE_PDA,
-    HAL_DEVICE_TYPE_UNKNOWN
-    
-} HalDeviceType;
-
-#endif /*__HAL_ENUM_H */
diff --git a/libxfpm/hal-manager.c b/libxfpm/hal-manager.c
deleted file mode 100644
index 97ea4f4..0000000
--- a/libxfpm/hal-manager.c
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <dbus/dbus-glib.h>
-#include <glib.h>
-
-#include "hal-manager.h"
-#include "hal-device.h"
-
-static void hal_manager_finalize   (GObject *object);
-
-#define HAL_MANAGER_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), HAL_TYPE_MANAGER, HalManagerPrivate))
-
-struct HalManagerPrivate
-{
-    DBusGConnection *bus;
-    DBusGProxy      *proxy;
-    gboolean 	     connected;
-    gboolean         is_laptop;
-};
-
-enum
-{
-    DEVICE_ADDED,
-    DEVICE_REMOVED,
-    LAST_SIGNAL
-};
-
-static gpointer hal_manager_object = NULL;
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE (HalManager, hal_manager, G_TYPE_OBJECT)
-
-static void
-hal_manager_device_added_cb (DBusGProxy *proxy, const gchar *udi, HalManager *manager)
-{
-    g_signal_emit (G_OBJECT(manager), signals[DEVICE_ADDED], 0, udi);
-}
-
-static void
-hal_manager_device_removed_cb (DBusGProxy *proxy, const gchar *udi, HalManager *manager)
-{
-    g_signal_emit (G_OBJECT(manager), signals[DEVICE_REMOVED], 0, udi);
-}
-
-static void
-hal_manager_connect (HalManager *manager)
-{
-    GError *error = NULL;
-    
-    manager->priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
-    
-    if ( error )
-    {
-	g_critical ("Failed to get bus system %s\n", error->message);
-	g_error_free (error);
-	goto out;
-    }
-    manager->priv->connected = TRUE;
-    
-    manager->priv->proxy = dbus_g_proxy_new_for_name (manager->priv->bus,
-		  				      "org.freedesktop.Hal",
-						      "/org/freedesktop/Hal/Manager",
-						      "org.freedesktop.Hal.Manager");
-    
-    if ( !manager->priv->proxy )
-    {
-	g_critical ("Unable to get proxy for \n");
-	goto out;
-    }
-    
-    dbus_g_proxy_add_signal (manager->priv->proxy, "DeviceAdded",
-			     G_TYPE_STRING, G_TYPE_INVALID);
-			     
-    dbus_g_proxy_connect_signal (manager->priv->proxy, "DeviceAdded",
-				 G_CALLBACK (hal_manager_device_added_cb), manager, NULL);
-
-    dbus_g_proxy_add_signal (manager->priv->proxy, "DeviceRemoved",
-			     G_TYPE_STRING, G_TYPE_INVALID);
-	
-    dbus_g_proxy_connect_signal (manager->priv->proxy, "DeviceRemoved",
-				 G_CALLBACK (hal_manager_device_removed_cb), manager, NULL);
-out:
-	;
-}
-
-static void
-hal_manager_get_is_laptop_internal (HalManager *manager)
-{
-    HalDevice *device;
-    gchar *form_factor;
-    
-    device = hal_device_new ();
-    
-    hal_device_set_udi (device, "/org/freedesktop/Hal/devices/computer");
-
-    form_factor = hal_device_get_property_string (device, "system.formfactor");
-
-    if ( g_strcmp0 (form_factor, "laptop") == 0)
-	manager->priv->is_laptop = TRUE;
-    else
-	manager->priv->is_laptop = FALSE;
-    
-    if (form_factor)
-	g_free (form_factor);
-
-    g_object_unref (device);
-}
-
-static void
-hal_manager_class_init(HalManagerClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-    
-    signals[DEVICE_ADDED] =
-    	g_signal_new("device-added",
-		     HAL_TYPE_MANAGER,
-		     G_SIGNAL_RUN_LAST,
-		     G_STRUCT_OFFSET(HalManagerClass, device_added),
-		     NULL, NULL,
-		     g_cclosure_marshal_VOID__STRING,
-		     G_TYPE_NONE, 1, G_TYPE_STRING);
-		     
-    signals[DEVICE_REMOVED] =
-    	g_signal_new("device-removed",
-		     HAL_TYPE_MANAGER,
-		     G_SIGNAL_RUN_LAST,
-		     G_STRUCT_OFFSET(HalManagerClass, device_removed),
-		     NULL, NULL,
-		     g_cclosure_marshal_VOID__STRING,
-		     G_TYPE_NONE, 1, G_TYPE_STRING);
-    
-    object_class->finalize = hal_manager_finalize;
-
-    g_type_class_add_private (klass,sizeof(HalManagerPrivate));
-}
-
-static void
-hal_manager_init (HalManager *manager)
-{
-    manager->priv = HAL_MANAGER_GET_PRIVATE (manager);
-    
-    manager->priv->bus 	     = NULL;
-    manager->priv->proxy     = NULL;
-    manager->priv->connected = FALSE;
-    
-    hal_manager_connect (manager);
-    hal_manager_get_is_laptop_internal (manager);
-}
-
-static void
-hal_manager_finalize(GObject *object)
-{
-    HalManager *manager;
-
-    manager = HAL_MANAGER(object);
-    
-    if ( manager->priv->proxy )
-	g_object_unref (manager->priv->proxy);
-	
-    if ( manager->priv->bus )
-	dbus_g_connection_unref (manager->priv->bus);
-
-    G_OBJECT_CLASS(hal_manager_parent_class)->finalize(object);
-}
-
-HalManager *
-hal_manager_new (void)
-{
-    if ( hal_manager_object != NULL )
-    {
-	g_object_ref (hal_manager_object);
-    }
-    else
-    {
-	hal_manager_object = g_object_new (HAL_TYPE_MANAGER, NULL);
-	g_object_add_weak_pointer (hal_manager_object, &hal_manager_object);
-    }
-    
-    return HAL_MANAGER (hal_manager_object);
-}
-
-gchar **hal_manager_find_device_by_capability (HalManager *manager, const gchar *capability)
-{
-    GError *error = NULL;
-    gchar  **udi = NULL;
-    
-    g_return_val_if_fail (HAL_IS_MANAGER(manager), NULL);
-    g_return_val_if_fail (manager->priv->connected, NULL);
-    
-    dbus_g_proxy_call (manager->priv->proxy, "FindDeviceByCapability", &error, 
-		       G_TYPE_STRING, capability, 
-		       G_TYPE_INVALID,
-		       G_TYPE_STRV, &udi,
-		       G_TYPE_INVALID);
-    if ( error )
-    {
-	g_critical ("Error finding devices by capability %s\n", error->message);
-	g_error_free (error);
-    }
-    
-    return udi;
-}
-
-gboolean hal_manager_get_is_laptop (HalManager *manager)
-{
-    g_return_val_if_fail (HAL_IS_MANAGER (manager), FALSE);
-    
-    return manager->priv->is_laptop;
-}
-
-void hal_manager_free_string_array (gchar **array)
-{
-    gint i;
-
-    if (array == NULL)	
-	    return;
-    
-    for (i=0; array[i]; i++) 
-	g_free (array[i]);
-    
-    g_free (array);
-}
diff --git a/libxfpm/hal-manager.h b/libxfpm/hal-manager.h
deleted file mode 100644
index 982c90c..0000000
--- a/libxfpm/hal-manager.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __HAL_MANAGER_H
-#define __HAL_MANAGER_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define HAL_TYPE_MANAGER        (hal_manager_get_type () )
-#define HAL_MANAGER(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), HAL_TYPE_MANAGER, HalManager))
-#define HAL_IS_MANAGER(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), HAL_TYPE_MANAGER))
-
-typedef struct HalManagerPrivate HalManagerPrivate;
-
-typedef struct
-{
-    GObject		  	parent;
-    HalManagerPrivate	       *priv;
-    
-} HalManager;
-
-typedef struct
-{
-    GObjectClass 		parent_class;
-    
-    void		        (*device_added)				(HalManager *manager,
-									 const gchar *udi);
-    void                        (*device_removed)			(HalManager *manager,
-									 const gchar *udi);
-    
-} HalManagerClass;
-
-GType        	  		hal_manager_get_type        		(void) G_GNUC_CONST;
-HalManager       	       *hal_manager_new            		(void);
-
-gchar 			      **hal_manager_find_device_by_capability 	(HalManager *manager,
-									 const gchar *capability);
-
-gboolean                        hal_manager_get_is_laptop               (HalManager *manager) G_GNUC_PURE;
-						 
-void                            hal_manager_free_string_array           (gchar **array);
-
-G_END_DECLS
-
-#endif /* __HAL_MANAGER_H */
diff --git a/libxfpm/hal-power.c b/libxfpm/hal-power.c
deleted file mode 100644
index d561694..0000000
--- a/libxfpm/hal-power.c
+++ /dev/null
@@ -1,386 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <glib.h>
-#include <dbus/dbus-glib.h>
-
-#include "hal-manager.h"
-#include "hal-power.h"
-
-static void hal_power_finalize   (GObject *object);
-
-#define HAL_POWER_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), HAL_TYPE_POWER, HalPowerPrivate))
-
-struct HalPowerPrivate
-{
-    GHashTable *hash  	;
-    HalManager *manager ;
-    
-    gulong      sig_1;
-    gulong      sig_2;
-};
-
-enum
-{
-    BATTERY_ADDED,
-    BATTERY_REMOVED,
-    LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(HalPower, hal_power, G_TYPE_OBJECT)
-
-/*
- * Sanity check of the keys present of a battery device
- */
-static gboolean
-hal_power_check_battery (HalPower *power, HalDevice *device)
-{
-    if ( hal_device_has_key(device, "battery.present") &&
-	 hal_device_has_key(device, "battery.rechargeable.is_charging") &&
-         hal_device_has_key(device, "battery.rechargeable.is_discharging") &&
-         hal_device_has_key(device, "battery.charge_level.current") &&
-	 hal_device_has_key(device, "battery.charge_level.last_full") )
-		 return TRUE;
-    
-    return FALSE;
-}
-
-/*
- * Check if the device added is actually a new non-moniotred device
- * Hald duplicates udi when running udevadm trigger
- */
-static gboolean
-hal_power_is_battery_new (HalPower *power, HalDevice *device)
-{
-    GList *list = NULL;
-    gboolean new_device = TRUE;
-    guint is_new = 0;
-    HalDevice *hash_device;
-    guint i;
-    
-    list = g_hash_table_get_values (power->priv->hash);
-    if ( !list )
-	return new_device;
-	
-    if ( g_list_length(list) == 0 )
-	return new_device;
-	
-    for ( i = 0; i < g_list_length(list); i++ )
-    {
-	hash_device = (HalDevice *) g_list_nth_data (list, i);
-	
-	if ( hal_device_get_property_int (hash_device, "battery.charge_level.current") !=
-	     hal_device_get_property_int (device, "battery.charge_level.current") && 
-	     hal_device_get_property_int (hash_device, "battery.charge_level.last_full") !=
-	     hal_device_get_property_int (device, "battery.charge_level.last_full") )
-	    is_new++;
-    }
-
-    /* Device doesn't match to any one in the hash*/
-    if ( is_new == g_list_length (list) )
-	new_device = TRUE;
-    else
-	new_device = FALSE;
-	
-    g_list_free (list);
-    return new_device;
-}
-
-static HalBattery *
-hal_power_add_battery (HalPower *power, const gchar *udi)
-{
-    HalBattery *battery;
-    battery  = hal_battery_new (udi);
-    
-    g_hash_table_insert (power->priv->hash, g_strdup(udi), battery );
-    
-    return battery ;
-}
-
-static void
-hal_power_remove_battery (HalPower *power, HalBattery *battery, const gchar *udi)
-{
-    g_signal_emit (power, signals[BATTERY_REMOVED], 0, battery);
-    
-    if (!g_hash_table_remove(power->priv->hash, udi))
-    	g_warning ("Unable to removed object from hash\n");
-}
-
-static HalBattery *
-hal_power_get_battery_from_hash (HalPower *power, const gchar *udi)
-{
-    HalBattery *battery = NULL;
-    
-    battery = g_hash_table_lookup(power->priv->hash, udi);
-    
-    return battery;
-}
-
-static void
-hal_power_device_added_cb (HalManager *manager, const gchar *udi, HalPower *power)
-{
-    HalDevice *device = hal_device_new ();
-    HalBattery *battery;
-    hal_device_set_udi (device, udi);
-    
-    if ( hal_device_has_capability (device, "battery") )
-    {
-	if ( !hal_power_check_battery (power, device) )
-	    goto out;
-	    
-	if ( !hal_power_is_battery_new (power, device) )
-	    goto out;
-	    
-	battery = hal_power_add_battery (power, udi);
-        g_signal_emit (G_OBJECT(power), signals[BATTERY_ADDED], 0, battery);
-    }
-out:
-    g_object_unref (device);
-}
-
-static void
-hal_power_device_removed_cb (HalManager *manager, const gchar *udi, HalPower *power)
-{
-    HalBattery *battery  = hal_power_get_battery_from_hash (power, udi);
-    
-    if (battery)
-    {
-	hal_power_remove_battery (power, battery , udi);
-    }
-}
-
-static void
-hal_power_class_init(HalPowerClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-    signals[BATTERY_ADDED] =
-    	g_signal_new("battery-added",
-		     HAL_TYPE_POWER,
-		     G_SIGNAL_RUN_LAST,
-		     G_STRUCT_OFFSET(HalPowerClass, battery_added),
-		     NULL, NULL,
-		     g_cclosure_marshal_VOID__POINTER,
-		     G_TYPE_NONE, 1, G_TYPE_POINTER);
-		     
-    signals[BATTERY_REMOVED] =
-    	g_signal_new("battery-removed",
-		     HAL_TYPE_POWER,
-		     G_SIGNAL_RUN_LAST,
-		     G_STRUCT_OFFSET(HalPowerClass, battery_removed),
-		     NULL, NULL,
-		     g_cclosure_marshal_VOID__POINTER,
-		     G_TYPE_NONE, 1, G_TYPE_POINTER);
-		     
-    object_class->finalize = hal_power_finalize;
-
-    g_type_class_add_private(klass,sizeof(HalPowerPrivate));
-}
-
-static void
-hal_power_get_batteries_internal (HalPower *power)
-{
-    HalDevice *device = hal_device_new ();
-    gchar **batteries = NULL;
-    gint i;
-    
-    batteries = hal_manager_find_device_by_capability (power->priv->manager, "battery");
-    
-    if ( !batteries ) 
-    	goto out;
-    
-    for ( i = 0; batteries[i]; i++ )
-    {
-	hal_device_set_udi (device, batteries[i]);
-	
-	if (!hal_power_check_battery(power, device))
-	    continue;
-		
-	if ( !hal_power_is_battery_new (power, device) )
-	    continue;
-	    
-    	hal_power_add_battery (power, batteries[i]);
-    }
-    hal_manager_free_string_array (batteries);
-
-out:
-    g_object_unref (device);
-}
-
-static gboolean
-hal_power_is_power_save_set (void)
-{
-    HalDevice *device;
-    gboolean   val;
-    
-    device = hal_device_new ();
-
-    hal_device_set_udi (device, "/org/freedesktop/Hal/devices/computer");
-    
-    val = hal_device_get_property_bool (device, "power_management.is_powersave_set");
-    
-    g_object_unref (device);
-    
-    return val;
-}
-
-static gboolean 
-hal_power_set_power_save_internal (HalPower *power, gboolean set)
-{
-    DBusGConnection *bus;
-    DBusGProxy      *proxy;
-    GError          *error = NULL;
-    gint             ret = 0;
-    
-    if ( hal_power_is_power_save_set () == set )
-	return TRUE;
-    
-    bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
-    
-    proxy = dbus_g_proxy_new_for_name (bus, 
-				       "org.freedesktop.Hal",
-				       "/org/freedesktop/Hal/devices/computer",
-				       "org.freedesktop.Hal.Device.SystemPowerManagement");
-				       
-    if ( !proxy )
-    {
-	g_warning ("Unable to get proxy for /org/freedesktop/Hal/devices/computer");
-	dbus_g_connection_unref (bus);
-	return FALSE;
-    }
-    
-    dbus_g_proxy_call (proxy, "SetPowerSave", &error,
-		       G_TYPE_BOOLEAN, set,
-		       G_TYPE_INVALID,
-		       G_TYPE_INT, &ret,
-		       G_TYPE_INVALID);
-    
-    dbus_g_connection_unref (bus);
-    g_object_unref (proxy);
-    
-    if ( error )
-    {
-	g_warning ("%s: ", error->message);
-	g_error_free (error);
-	return FALSE;
-    }
-    return ret == 0 ? TRUE : FALSE;
-}
-
-static void
-hal_power_init(HalPower *power)
-{
-    power->priv = HAL_POWER_GET_PRIVATE(power);
-    
-    power->priv->manager = hal_manager_new ();
-    power->priv->hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
-    
-    power->priv->sig_1 = g_signal_connect (power->priv->manager, "device-added", 
-					   G_CALLBACK(hal_power_device_added_cb), power);
-    
-    power->priv->sig_2 = g_signal_connect (power->priv->manager, "device-removed",
-					    G_CALLBACK(hal_power_device_removed_cb), power);
-   
-    hal_power_get_batteries_internal (power);
-}
-
-static void
-hal_power_finalize(GObject *object)
-{
-    HalPower *power;
-    
-    power = HAL_POWER(object);
-    
-    if ( g_signal_handler_is_connected (power->priv->manager, power->priv->sig_1 ) )
-	g_signal_handler_disconnect (power->priv->manager, power->priv->sig_1 );
-	
-    if ( g_signal_handler_is_connected (power->priv->manager, power->priv->sig_2 ) )
-	g_signal_handler_disconnect (power->priv->manager, power->priv->sig_2 );
-    
-    g_hash_table_destroy (power->priv->hash);
-    
-    g_object_unref (power->priv->manager);
-	
-    G_OBJECT_CLASS(hal_power_parent_class)->finalize(object);
-}
-
-HalPower *
-hal_power_new(void)
-{
-    HalPower *power = NULL;
-    power = g_object_new (HAL_TYPE_POWER,NULL);
-    return power;
-}
-
-/*
- * Return an array of power devices, the array should be freed by the caller
- */
-GPtrArray *
-hal_power_get_batteries (HalPower *power)
-{
-    guint i;
-    GPtrArray *array;
-    HalBattery *battery;
-    GList *list = NULL;
-    
-    g_return_val_if_fail (HAL_IS_POWER (power), NULL);
-    
-    array = g_ptr_array_new ();
-   
-    list = g_hash_table_get_values (power->priv->hash);
-   
-    if (!list)
-   	goto out;
-	
-    for ( i=0; i < g_list_length (list); i++)
-    {
-       battery = g_list_nth_data (list, i);
-       g_ptr_array_add (array, battery);
-    }
-   
-    g_list_free (list);
-out:
-   return array;
-}
-
-gboolean hal_power_set_power_save  (HalPower *power)
-{
-    g_return_val_if_fail (HAL_IS_POWER (power), FALSE);
-
-    return hal_power_set_power_save_internal (power, TRUE);
-}
-
-gboolean hal_power_unset_power_save (HalPower *power)
-{
-    g_return_val_if_fail (HAL_IS_POWER (power), FALSE);
-
-    return hal_power_set_power_save_internal (power, FALSE);
-}
diff --git a/libxfpm/hal-power.h b/libxfpm/hal-power.h
deleted file mode 100644
index a5f3590..0000000
--- a/libxfpm/hal-power.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __HAL_POWER_H
-#define __HAL_POWER_H
-
-#include <glib-object.h>
-
-#include "hal-device.h"
-#include "hal-battery.h"
-
-G_BEGIN_DECLS
-
-#define HAL_TYPE_POWER        (hal_power_get_type () )
-#define HAL_POWER(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), HAL_TYPE_POWER, HalPower))
-#define HAL_IS_POWER(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), HAL_TYPE_POWER))
-
-typedef struct HalPowerPrivate HalPowerPrivate;
-
-typedef struct
-{
-    GObject		parent;
-    HalPowerPrivate    *priv;
-    
-} HalPower;
-
-typedef struct
-{
-    GObjectClass 	parent_class;
-    
-    void 		(*battery_added)	  (HalPower *power,
-						   const HalBattery *battery);
-					   
-    void        	(*battery_removed)        (HalPower *power,
-						   const HalBattery *battery);
-					   
-} HalPowerClass;
-
-GType        		hal_power_get_type        (void) G_GNUC_CONST;
-HalPower       	       *hal_power_new             (void);
-
-GPtrArray      	       *hal_power_get_batteries   (HalPower *power);
-
-gboolean                hal_power_set_power_save  (HalPower *power);
-
-gboolean                hal_power_unset_power_save(HalPower *power);
-
-G_END_DECLS
-
-#endif /* __HAL_POWER_H */
diff --git a/libxfpm/xfpm-common.c b/libxfpm/xfpm-common.c
deleted file mode 100644
index 77da56a..0000000
--- a/libxfpm/xfpm-common.c
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <glib.h>
-
-#include <libxfce4util/libxfce4util.h>
-
-#include "xfpm-common.h"
-#include "xfpm-string.h"
-
-GtkBuilder *xfpm_builder_new_from_string (const gchar *ui, GError **error)
-{
-    GtkBuilder *builder;
-
-    builder = gtk_builder_new ();
-    
-    gtk_builder_add_from_string (GTK_BUILDER (builder),
-                                 ui,
-                                 -1,
-                                 error);
-    
-    return builder;
-}
-
-static void
-xfpm_link_browser (GtkAboutDialog *about, const gchar *link, gpointer data)
-{
-    gchar *cmd;
-    
-    cmd = g_strdup_printf ("%s %s","xdg-open", link);
-    
-    if ( !g_spawn_command_line_async (cmd, NULL) )
-    {
-	g_free (cmd);
-	cmd = g_strdup_printf ("%s %s","xfbrowser4", link);
-	g_spawn_command_line_async (cmd, NULL);
-    }
-    g_free (cmd);
-	
-}
-
-static void
-xfpm_link_mailto (GtkAboutDialog *about, const gchar *link, gpointer data)
-{
-    gchar *cmd = g_strdup_printf( "%s %s", "xdg-email", link);
-
-    g_spawn_command_line_async (cmd, NULL);
-    
-    g_free (cmd);
-}
-	
-void       
-xfpm_lock_screen (void)
-{
-    gboolean ret = g_spawn_command_line_async ("xflock4", NULL);
-    
-    if ( !ret )
-    {
-        g_spawn_command_line_async ("gnome-screensaver-command -l", NULL);
-    }
-    
-    if ( !ret )
-    {
-        /* this should be the default*/
-        ret = g_spawn_command_line_async ("xdg-screensaver lock", NULL);
-    }
-    
-    if ( !ret )
-    {
-        ret = g_spawn_command_line_async ("xscreensaver-command -lock", NULL);
-    }
-    
-    if ( !ret )
-    {
-        g_critical ("Connot lock screen\n");
-    }
-}
-
-void       
-xfpm_preferences (void) 
-{
-    g_spawn_command_line_async ("xfce4-power-manager-settings", NULL);
-}
-
-void       
-xfpm_help (void)
-{
-    g_spawn_command_line_async ("xfhelp4 xfce4-power-manager.html", NULL);
-}
-
-void
-xfpm_quit (void)
-{
-    g_spawn_command_line_async ("xfce4-power-manager -q", NULL);
-}
-
-void       
-xfpm_about (GtkWidget *widget, gpointer data)
-{
-    gchar *package = (gchar *)data;
-    
-    const gchar* authors[3] = 
-    {
-	"Ali Abdallah <aliov at xfce.org>", 
-	 NULL
-    };
-							    
-    static const gchar *documenters[] =
-    {
-	"Ali Abdallah <aliov at xfce.org>",
-	NULL,
-    };
-    
-
-    gtk_about_dialog_set_url_hook (xfpm_link_browser, NULL, NULL);
-    gtk_about_dialog_set_email_hook (xfpm_link_mailto, NULL, NULL);
-    
-    gtk_show_about_dialog (NULL,
-		     "authors", authors,
-		     "copyright", "Copyright \302\251 2008-2009 Ali Abdallah",
-		     "destroy-with-parent", TRUE,
-		     "documenters", documenters,
-		     "license", XFCE_LICENSE_GPL,
-		     "name", package,
-		     "translator-credits", _("translator-credits"),
-		     "version", PACKAGE_VERSION,
-		     "website", "http://goodies.xfce.org",
-		     NULL);
-						 
-}
-
-gboolean xfpm_is_multihead_connected (void)
-{
-    GdkDisplay *dpy;
-    GdkScreen *screen;
-    gint nscreen;
-    gint nmonitor;
-    
-    dpy = gdk_display_get_default ();
-    
-    nscreen = gdk_display_get_n_screens (dpy);
-    
-    if ( nscreen == 1 )
-    {
-	screen = gdk_display_get_screen (dpy, 0);
-	if ( screen )
-	{
-	    nmonitor = gdk_screen_get_n_monitors (screen);
-	    if ( nmonitor > 1 )
-	    {
-		g_debug ("Multiple monitor connected");
-		return TRUE; 
-	    }
-	    else
-		return FALSE;
-	}
-    }
-    else if ( nscreen > 1 )
-    {
-	g_debug ("Multiple screen connected");
-	return TRUE;
-    }
-    
-    return FALSE;
-}
diff --git a/libxfpm/xfpm-common.h b/libxfpm/xfpm-common.h
deleted file mode 100644
index dfd9faf..0000000
--- a/libxfpm/xfpm-common.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef __XFPM_COMMON_H
-#define __XFPM_COMMON_H
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib.h>
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-GtkBuilder     *xfpm_builder_new_from_string   	(const gchar *file,
-						 GError **error);
-
-void       	xfpm_lock_screen  		(void);
-
-void       	xfpm_preferences		(void);
-
-void       	xfpm_help			(void);
-
-void            xfpm_quit                       (void);
-
-void       	xfpm_about			(GtkWidget *widget, 
-						 gpointer data);
-
-gboolean	xfpm_is_multihead_connected	(void);
-
-G_END_DECLS
-
-#endif /* XFPM_COMMON_H */
diff --git a/libxfpm/xfpm-dbus.h b/libxfpm/xfpm-dbus.h
deleted file mode 100644
index 11ca372..0000000
--- a/libxfpm/xfpm-dbus.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * * Copyright (C) 2008 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __XFPM_DBUS_H
-#define __XFPM_DBUS_H
-
-#include <glib.h>
-#include <dbus/dbus.h>
-
-gboolean	xfpm_dbus_name_has_owner (DBusConnection *bus,
-					  const gchar *name);
-gboolean        xfpm_dbus_register_name  (DBusConnection *bus,
-					  const gchar *name);
-gboolean        xfpm_dbus_release_name   (DBusConnection *bus,
-					  const gchar *name);
-
-#endif /* __XFPM_DBUS_H */
diff --git a/libxfpm/xfpm-icons.h b/libxfpm/xfpm-icons.h
deleted file mode 100644
index 3bc8f67..0000000
--- a/libxfpm/xfpm-icons.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * * Copyright (C) 2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef __XFPM_ICONS_H
-#define __XFPM_ICONS_H
-
-G_BEGIN_DECLS
-
-#define XFPM_AC_ADAPTER_ICON			"xfpm-ac-adapter"
-#define XFPM_BATTERY_ICON			"battery"
-
-#define XFPM_PRIMARY_ICON_PREFIX		"xfpm-primary-"
-#define XFPM_UPS_ICON_PREFIX			"xfpm-ups-"
-#define XFPM_MOUSE_ICON_PREFIX			"xfpm-mouse-"
-#define XFPM_KBD_ICON_PREFIX			"xfpm-keyboard-"
-#define XFPM_CAMERA_ICON_PREFIX			"xfpm-camera-"
-#define XFPM_PDA_ICON_PREFIX			"xfpm-pda-"
-#define XFPM_KBD_MOUSE_ICON_PREFIX		"xfpm-keyboard-mouse-"
-
-#define XFPM_DISPLAY_BRIGHTNESS_ICON	        "xfpm-brightness-lcd"
-#define XFPM_DISPLAY_BRIGHTNESS_INVALID_ICON	"xfpm-brightness-lcd-invalid" /* When no hw found */
-#define XFPM_HIBERNATE_ICON			"xfpm-hibernate"
-#define XFPM_SUSPEND_ICON			"xfpm-suspend"
-
-G_END_DECLS
-
-#endif
diff --git a/libxfpm/xfpm-notify.c b/libxfpm/xfpm-notify.c
deleted file mode 100644
index e983087..0000000
--- a/libxfpm/xfpm-notify.c
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-
-#include <gtk/gtk.h>
-
-#include <libxfce4util/libxfce4util.h>
-#include <libxfcegui4/libxfcegui4.h>
-
-#include <libnotify/notify.h>
-
-#include "xfpm-common.h"
-#include "xfpm-notify.h"
-
-static void xfpm_notify_finalize   (GObject *object);
-
-static NotifyNotification * xfpm_notify_new_notification_internal (const gchar *title, 
-								   const gchar *message, 
-								   const gchar *icon_name, 
-								   guint timeout, 
-								   XfpmNotifyUrgency urgency, 
-								   GtkStatusIcon *icon) G_GNUC_MALLOC;
-
-#define XFPM_NOTIFY_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_NOTIFY, XfpmNotifyPrivate))
-
-struct XfpmNotifyPrivate
-{
-    NotifyNotification *notification;
-    NotifyNotification *critical;
-};
-
-static gpointer xfpm_notify_object = NULL;
-
-G_DEFINE_TYPE(XfpmNotify, xfpm_notify, G_TYPE_OBJECT)
-
-static void
-xfpm_notify_class_init(XfpmNotifyClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-    object_class->finalize = xfpm_notify_finalize;
-
-
-    g_type_class_add_private(klass,sizeof(XfpmNotifyPrivate));
-}
-
-static void
-xfpm_notify_init(XfpmNotify *notify)
-{
-    notify->priv = XFPM_NOTIFY_GET_PRIVATE(notify);
-    
-    notify->priv->notification = NULL;
-    notify->priv->critical = NULL;
-}
-
-static void
-xfpm_notify_finalize(GObject *object)
-{
-    XfpmNotify *notify;
-
-    notify = XFPM_NOTIFY(object);
-    
-    xfpm_notify_close_normal (notify);
-    xfpm_notify_close_critical (notify);
-    
-    G_OBJECT_CLASS(xfpm_notify_parent_class)->finalize(object);
-}
-
-static void
-xfpm_notify_set_notification_icon (NotifyNotification *n, const gchar *icon_name )
-{
-    GdkPixbuf *pix = xfce_themed_icon_load (icon_name, 48);
-    
-    if ( pix )
-    {
-	notify_notification_set_icon_from_pixbuf (n,
-						  pix);
-	g_object_unref ( G_OBJECT(pix));
-    }
-    
-}
-
-static NotifyNotification *
-xfpm_notify_new_notification_internal (const gchar *title, const gchar *message,
-				       const gchar *icon_name, guint timeout,
-				       XfpmNotifyUrgency urgency, GtkStatusIcon *icon)
-{
-    NotifyNotification *n;
-    
-    n = notify_notification_new (title, message, NULL, NULL);
-    
-    if ( icon_name )
-    	xfpm_notify_set_notification_icon (n, icon_name);
-	
-    if ( icon )
-    	notify_notification_attach_to_status_icon (n, icon);
-	
-    notify_notification_set_urgency (n, (NotifyUrgency)urgency);
-    notify_notification_set_timeout (n, timeout);
-    
-    return n;
-}
-
-static void
-xfpm_notify_closed_cb (NotifyNotification *n, XfpmNotify *notify)
-{
-    notify->priv->notification = NULL;
-    g_object_unref (G_OBJECT (n));
-}
-
-static void
-xfpm_notify_close_critical_cb (NotifyNotification *n, XfpmNotify *notify)
-{
-    notify->priv->critical = NULL;
-    g_object_unref (G_OBJECT (n));
-}
-
-static gboolean
-xfpm_notify_show (NotifyNotification *n)
-{
-    notify_notification_show (n, NULL);
-    return FALSE;
-}
-
-static void
-xfpm_notify_close_notification (XfpmNotify *notify )
-{
-    if ( notify->priv->notification )
-    {
-    	if (!notify_notification_close (notify->priv->notification, NULL))
-	    g_warning ("Failed to close notification\n");
-	
-	g_object_unref (G_OBJECT(notify->priv->notification) );
-	notify->priv->notification  = NULL;
-    }
-}
-
-XfpmNotify *
-xfpm_notify_new (void)
-{
-    if ( xfpm_notify_object != NULL )
-    {
-	g_object_ref (xfpm_notify_object);
-    }
-    else
-    {
-	xfpm_notify_object = g_object_new (XFPM_TYPE_NOTIFY, NULL);
-	g_object_add_weak_pointer (xfpm_notify_object, &xfpm_notify_object);
-    }
-    return XFPM_NOTIFY (xfpm_notify_object);
-}
-
-void xfpm_notify_show_notification (XfpmNotify *notify, const gchar *title,
-				    const gchar *text,  const gchar *icon_name,
-				    gint timeout, gboolean simple,
-				    XfpmNotifyUrgency urgency, GtkStatusIcon *icon)
-{
-    NotifyNotification *n;
-    
-    if ( !simple )
-        xfpm_notify_close_notification (notify);
-    
-    n = xfpm_notify_new_notification_internal (title, 
-				               text, icon_name, 
-					       timeout, urgency, 
-					       icon);
-					       
-    xfpm_notify_present_notification (notify, n, simple);
-}
-
-NotifyNotification *xfpm_notify_new_notification (XfpmNotify *notify,
-						  const gchar *title,
-						  const gchar *text,
-						  const gchar *icon_name,
-						  guint timeout,
-						  XfpmNotifyUrgency urgency,
-						  GtkStatusIcon *icon)
-{
-    NotifyNotification *n = xfpm_notify_new_notification_internal (title, 
-							           text, icon_name, 
-								   timeout, urgency, 
-								   icon);
-    return n;
-}
-
-void xfpm_notify_add_action_to_notification (XfpmNotify *notify, NotifyNotification *n,
-					    const gchar *id, const gchar *action_label,
-					    NotifyActionCallback callback, gpointer data)
-{
-    g_return_if_fail (XFPM_IS_NOTIFY(notify));
-    
-    notify_notification_add_action (n, id, action_label,
-				   (NotifyActionCallback)callback,
-				    data, NULL);
-    
-}
-
-void xfpm_notify_present_notification (XfpmNotify *notify, NotifyNotification *n, gboolean simple)
-{
-    g_return_if_fail (XFPM_IS_NOTIFY(notify));
-    
-    if ( !simple )
-        xfpm_notify_close_notification (notify);
-    
-    if ( !simple )
-    {
-	g_signal_connect (G_OBJECT(n),"closed",
-			G_CALLBACK(xfpm_notify_closed_cb), notify);
-	notify->priv->notification = n;
-    }
-    
-    g_idle_add ((GSourceFunc) xfpm_notify_show, n);
-}
-
-void xfpm_notify_critical (XfpmNotify *notify, NotifyNotification *n)
-{
-    g_return_if_fail (XFPM_IS_NOTIFY (notify));
-
-    xfpm_notify_close_critical (notify);
-    
-    notify->priv->critical = n;
-    
-    g_signal_connect (G_OBJECT (n), "closed", 
-		      G_CALLBACK (xfpm_notify_close_critical_cb), notify);
-		      
-    g_idle_add ((GSourceFunc) xfpm_notify_show, n);
-}
-
-void xfpm_notify_close_critical (XfpmNotify *notify)
-{
-    g_return_if_fail (XFPM_IS_NOTIFY (notify));
-    
-    if ( notify->priv->critical )
-    {
-    	if (!notify_notification_close (notify->priv->critical, NULL))
-	    g_warning ("Failed to close notification\n");
-	
-	g_object_unref (G_OBJECT(notify->priv->critical) );
-	notify->priv->critical  = NULL;
-    }
-}
-
-void xfpm_notify_close_normal  (XfpmNotify *notify)
-{
-    g_return_if_fail (XFPM_IS_NOTIFY (notify));
-    
-    xfpm_notify_close_notification (notify);
-}
diff --git a/libxfpm/xfpm-popups.c b/libxfpm/xfpm-popups.c
deleted file mode 100644
index d05463e..0000000
--- a/libxfpm/xfpm-popups.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <gtk/gtk.h>
-#include <glib.h>
-
-#include "xfpm-popups.h"
-
-static GtkWidget *
-xfpm_message_dialog (const gchar *title, const gchar *message, GtkMessageType message_type)
-{
-    GtkWidget *dialog;
-    
-    dialog = gtk_message_dialog_new_with_markup(NULL,
-                                                GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                message_type,
-                                                GTK_BUTTONS_CLOSE,
-                                                "<span size='larger'><b>%s</b></span>",
-                                                title);
-                                                
-    gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog), "%s", message);
-    
-    return dialog;
-}
-
-void xfpm_popup_message(const gchar *title,
-                        const gchar *message,
-                        GtkMessageType message_type)
-{
-    
-    GtkWidget *dialog;
-    
-    dialog = xfpm_message_dialog (title, message, message_type);
-    
-    g_signal_connect(dialog,
-                     "response",
-                     G_CALLBACK(gtk_widget_destroy),
-                     NULL);
-                     
-    gtk_widget_show(dialog);                         
-}                 
-
-void xfpm_info (const gchar *title, const gchar *message )
-{
-    GtkWidget *dialog;
-    
-    dialog = xfpm_message_dialog (title, message, GTK_MESSAGE_INFO);
-    
-    gtk_dialog_run (GTK_DIALOG(dialog));
-    gtk_widget_destroy (dialog);
-}
-
-void    xfpm_error              (const gchar *title,
-				 const gchar *message)
-{
-    GtkWidget *dialog;
-    
-    dialog = xfpm_message_dialog (title, message, GTK_MESSAGE_ERROR);
-    
-    gtk_dialog_run (GTK_DIALOG(dialog));
-    gtk_widget_destroy (dialog);
-}
diff --git a/libxfpm/xfpm-popups.h b/libxfpm/xfpm-popups.h
deleted file mode 100644
index 6ab95db..0000000
--- a/libxfpm/xfpm-popups.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef __XFPM_POPUPS_H
-#define __XFPM_POPUPS_H
-
-void 	xfpm_popup_message	(const gchar *title,
-				 const gchar *message,
-				 GtkMessageType message_type);
-
-
-void 	xfpm_info 		(const gchar *title, 
-				 const gchar *message);
-				 
-void    xfpm_error              (const gchar *title,
-				 const gchar *message);
-
-#endif /* __XFPM_POPUPS_H */
diff --git a/libxfpm/xfpm-string.c b/libxfpm/xfpm-string.c
deleted file mode 100644
index 5919251..0000000
--- a/libxfpm/xfpm-string.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib.h>
-
-#include "xfpm-string.h"
-
-gboolean xfpm_strequal (const gchar *str1, const gchar *str2)
-{
-    if ( g_strcmp0 (str1, str2) == 0 ) return TRUE;
-    return FALSE;
-}
-
-const gchar *xfpm_bool_to_string (gboolean value)
-{
-    if ( value == TRUE ) return "TRUE";
-    else 		 return "FALSE";
-}
-
-gboolean xfpm_string_to_bool (const gchar *string)
-{
-    if ( xfpm_strequal(string, "TRUE") ) return TRUE;
-    else if ( xfpm_strequal(string, "FALSE")) return FALSE;
-    
-    return FALSE;
-}
diff --git a/libxfpm/xfpm-string.h b/libxfpm/xfpm-string.h
deleted file mode 100644
index 2a7bd20..0000000
--- a/libxfpm/xfpm-string.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __XFPM_STRING_H
-#define __XFPM_STRING_H
-
-#include <glib.h>
-#include <string.h>
-
-gboolean        xfpm_strequal		(const gchar *str1,
-					 const gchar *str2);
-
-const gchar    *xfpm_bool_to_string     (gboolean value) G_GNUC_PURE;
-
-gboolean        xfpm_string_to_bool     (const gchar *string) G_GNUC_PURE;
-
-
-#endif /* XFPM_STRING_H */
diff --git a/panel-plugins/brightness/Makefile.am b/panel-plugins/brightness/Makefile.am
index 2fa44af..4832205 100644
--- a/panel-plugins/brightness/Makefile.am
+++ b/panel-plugins/brightness/Makefile.am
@@ -4,9 +4,7 @@ plugin_PROGRAMS = xfce4-brightness-plugin
 xfce4_brightness_plugin_SOURCES =		\
 	brightness-plugin.c			\
 	brightness-button.c			\
-	brightness-button.h			\
-	brightness-proxy.c			\
-	brightness-proxy.h
+	brightness-button.h
 
 xfce4_brightness_plugin_CFLAGS =		\
 	-I$(top_srcdir)				\
@@ -16,19 +14,26 @@ xfce4_brightness_plugin_CFLAGS =		\
 	$(LIBXFCE4UTIL_CFLAGS)        		\
 	$(LIBXFCE4GUI_CFLAGS)			\
 	$(GTK_CFLAGS)			      	\
-	$(GLIB_CFLAGS)				\
-	$(DBUS_GLIB_CFLAGS)
+	$(GLIB_CFLAGS)
 
 xfce4_brightness_plugin_LDADD =			\
-	$(top_builddir)/libxfpm/libxfpmhal.la	\
-	$(top_builddir)/libxfpm/libxfpmcommon.la\
+	$(top_builddir)/common/libxfpmcommon.la \
 	$(LIBXFCE4PANEL_LIBS)   		\
 	$(LIBXFCE4GUI_LIBS)			\
 	$(LIBXFCE4UTIL_LIBS)			\
 	$(GTK_LIBS)   				\
-	$(GLIB_LIBS)				\
+	$(GLIB_LIBS)
+
+if ENABLE_HAL
+
+xfce4_brightness_plugin_CFLAGS += 		\
+	$(DBUS_GLIB_CFLAGS)
+
+xfce4_brightness_plugin_LDADD += 		\
 	$(DBUS_GLIB_LIBS)
 
+endif
+
 #
 # Desktop file
 #
diff --git a/panel-plugins/brightness/brightness-button.c b/panel-plugins/brightness/brightness-button.c
index cf9577f..b6e1893 100644
--- a/panel-plugins/brightness/brightness-button.c
+++ b/panel-plugins/brightness/brightness-button.c
@@ -30,11 +30,11 @@
 #include <libxfce4util/libxfce4util.h>
 #include <libxfcegui4/libxfcegui4.h>
 
-#include "libxfpm/xfpm-common.h"
-#include "libxfpm/xfpm-icons.h"
+#include "common/xfpm-common.h"
+#include "common/xfpm-icons.h"
+#include "common/xfpm-brightness.h"
 
 #include "brightness-button.h"
-#include "brightness-proxy.h"
 
 static void brightness_button_finalize   (GObject *object);
 
@@ -44,7 +44,8 @@ static void brightness_button_finalize   (GObject *object);
 struct BrightnessButtonPrivate
 {
     XfcePanelPlugin *plugin;
-    BrightnessProxy *brightness;
+    
+    XfpmBrightness  *brightness;
     
     GtkWidget       *popup;
     GtkWidget       *range;
@@ -173,7 +174,7 @@ brightness_button_set_tooltip (BrightnessButton *button)
 {
     gboolean has_hw;
     
-    has_hw = brightness_proxy_has_hw (button->priv->brightness);
+    has_hw = xfpm_brightness_has_hw (button->priv->brightness);
     
     if ( has_hw )
 	gtk_widget_set_tooltip_text (GTK_WIDGET (button), _("Control your LCD brightness"));
@@ -185,7 +186,7 @@ static gboolean
 brightness_button_popup_win (GtkWidget *widget, GdkEvent *ev, guint32 ev_time)
 {
     gint x, y, orientation;
-    gint current_level;
+    gint current_level = 0;
     GdkDisplay *display;
     GdkScreen *screen;
     BrightnessButton *button;
@@ -194,7 +195,7 @@ brightness_button_popup_win (GtkWidget *widget, GdkEvent *ev, guint32 ev_time)
     
     button = BRIGHTNESS_BUTTON (widget);
     
-    has_hw = brightness_proxy_has_hw (button->priv->brightness);
+    has_hw = xfpm_brightness_has_hw (button->priv->brightness);
     
     if ( !has_hw ) 
 	return FALSE;
@@ -303,7 +304,7 @@ brightness_button_popup_win (GtkWidget *widget, GdkEvent *ev, guint32 ev_time)
    
     gtk_window_move (GTK_WINDOW(button->priv->popup), x, y);
     TRACE("Displaying window on x=%d y=%d", x, y);
-    current_level = brightness_proxy_get_level (button->priv->brightness);
+    xfpm_brightness_get_level (button->priv->brightness, &current_level);
     
     gtk_range_set_value (GTK_RANGE(button->priv->range), current_level);
     button->priv->popup_open = TRUE;
@@ -319,10 +320,10 @@ brightness_button_press_event (GtkWidget *widget, GdkEventButton *ev)
 static void
 minus_clicked (GtkWidget *widget, BrightnessButton *button)
 {
-    guint level, max_level;
+    gint level, max_level;
     
-    max_level = brightness_proxy_get_max_level (button->priv->brightness);
-    level = (guint ) gtk_range_get_value (GTK_RANGE (button->priv->range));
+    max_level = xfpm_brightness_get_max_level (button->priv->brightness);
+    level = (gint ) gtk_range_get_value (GTK_RANGE (button->priv->range));
     
     if ( level != 0 )
 	gtk_range_set_value (GTK_RANGE (button->priv->range), level - 1);
@@ -331,10 +332,10 @@ minus_clicked (GtkWidget *widget, BrightnessButton *button)
 static void
 plus_clicked (GtkWidget *widget, BrightnessButton *button)
 {
-    guint level, max_level;
+    gint level, max_level;
     
-    max_level = brightness_proxy_get_max_level (button->priv->brightness);
-    level = (guint ) gtk_range_get_value (GTK_RANGE (button->priv->range));
+    max_level = xfpm_brightness_get_max_level (button->priv->brightness);
+    level = (gint ) gtk_range_get_value (GTK_RANGE (button->priv->range));
     
     if ( level != max_level )
 	gtk_range_set_value (GTK_RANGE (button->priv->range), level + 1);
@@ -343,15 +344,15 @@ plus_clicked (GtkWidget *widget, BrightnessButton *button)
 static void
 range_value_changed (GtkWidget *widget, BrightnessButton *button)
 {
-    guint range_level, hw_level;
+    gint range_level, hw_level;
     
-    range_level = (guint) gtk_range_get_value (GTK_RANGE (button->priv->range));
+    range_level = (gint) gtk_range_get_value (GTK_RANGE (button->priv->range));
     
-    hw_level = brightness_proxy_get_level (button->priv->brightness);
+    xfpm_brightness_get_level (button->priv->brightness, &hw_level);
     
     if ( hw_level != range_level )
     {
-	brightness_proxy_set_level (button->priv->brightness, range_level);
+	xfpm_brightness_set_level (button->priv->brightness, range_level);
     }
 }
 
@@ -360,14 +361,15 @@ brightness_button_create_popup (BrightnessButton *button)
 {
     GtkWidget *box;
     GtkOrientation orientation;
-    guint max_level;
+    gint max_level;
     gboolean has_hw;
     
-    has_hw = brightness_proxy_has_hw (button->priv->brightness);
+    has_hw = xfpm_brightness_has_hw (button->priv->brightness);
+    
     if ( !has_hw )
 	return;
 	
-    max_level = brightness_proxy_get_max_level (button->priv->brightness);
+    max_level = xfpm_brightness_get_max_level (button->priv->brightness);
      
     button->priv->popup = gtk_window_new (GTK_WINDOW_POPUP);
     gtk_window_set_decorated (GTK_WINDOW(button->priv->popup), FALSE);
@@ -428,11 +430,11 @@ brightness_button_create_popup (BrightnessButton *button)
 static void
 brightness_button_up (BrightnessButton *button)
 {
-    guint level;
-    guint max_level;
+    gint level;
+    gint max_level;
     
-    level = brightness_proxy_get_level (button->priv->brightness);
-    max_level = brightness_proxy_get_max_level (button->priv->brightness);
+    xfpm_brightness_get_level (button->priv->brightness, &level);
+    max_level = xfpm_brightness_get_max_level (button->priv->brightness);
     
     if ( level != max_level )
     {
@@ -443,8 +445,8 @@ brightness_button_up (BrightnessButton *button)
 static void
 brightness_button_down (BrightnessButton *button)
 {
-    guint level;
-    level = brightness_proxy_get_level (button->priv->brightness);
+    gint level;
+    xfpm_brightness_get_level (button->priv->brightness, &level);
     
     if ( level != 0 )
     {
@@ -460,7 +462,7 @@ brightness_button_scroll_event (GtkWidget *widget, GdkEventScroll *ev)
     
     button = BRIGHTNESS_BUTTON (widget);
     
-    hw_found = brightness_proxy_has_hw (button->priv->brightness);
+    hw_found = xfpm_brightness_has_hw (button->priv->brightness);
     
     if ( !hw_found )
 	return FALSE;
@@ -507,7 +509,8 @@ brightness_button_init (BrightnessButton *button)
 {
     button->priv = BRIGHTNESS_BUTTON_GET_PRIVATE (button);
     
-    button->priv->brightness = brightness_proxy_new ();
+    button->priv->brightness = xfpm_brightness_new ();
+    xfpm_brightness_setup (button->priv->brightness);
     
     gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
 }
@@ -556,7 +559,7 @@ brightness_button_set_icon (BrightnessButton *button, gint width)
     GdkPixbuf *pixbuf;
     const gchar *icon_name;
     
-    hw_found = brightness_proxy_has_hw (button->priv->brightness);
+    hw_found = xfpm_brightness_has_hw (button->priv->brightness);
     
     icon_name = hw_found ? XFPM_DISPLAY_BRIGHTNESS_ICON : XFPM_DISPLAY_BRIGHTNESS_INVALID_ICON;
     
@@ -586,8 +589,8 @@ reload_activated (GtkWidget *widget, BrightnessButton *button)
 {
     gint size;
     
-    brightness_proxy_reload (button->priv->brightness);
     destroy_popup (button);
+    xfpm_brightness_setup (button->priv->brightness);
     brightness_button_create_popup (button);
     brightness_button_set_tooltip (button);
     
diff --git a/panel-plugins/brightness/brightness-plugin.c b/panel-plugins/brightness/brightness-plugin.c
index e71afda..d0ffccd 100644
--- a/panel-plugins/brightness/brightness-plugin.c
+++ b/panel-plugins/brightness/brightness-plugin.c
@@ -31,8 +31,6 @@
 
 #include <libxfce4panel/xfce-panel-plugin.h>
 
-#include <dbus/dbus-glib.h>
-
 #include "brightness-button.h"
 
 static void
diff --git a/panel-plugins/brightness/brightness-proxy.c b/panel-plugins/brightness/brightness-proxy.c
deleted file mode 100644
index 3bc4993..0000000
--- a/panel-plugins/brightness/brightness-proxy.c
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * * Copyright (C) 2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <glib.h>
-
-#include <dbus/dbus-glib.h>
-
-#include <libxfce4util/libxfce4util.h>
-
-#include "libxfpm/hal-manager.h"
-#include "libxfpm/hal-device.h"
-
-#include "brightness-proxy.h"
-
-static void brightness_proxy_finalize   (GObject *object);
-
-#define BRIGHTNESS_PROXY_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE ((o), BRIGHTNESS_TYPE_PROXY, BrightnessProxyPrivate))
-
-struct BrightnessProxyPrivate
-{
-    DBusGConnection *bus;
-    DBusGConnection *session;
-    DBusGProxy      *proxy;
-    guint            max_level;
-    gboolean         has_hw;
-};
-
-G_DEFINE_TYPE (BrightnessProxy, brightness_proxy, G_TYPE_OBJECT)
-
-static void
-brightness_proxy_get_device (BrightnessProxy *brightness)
-{
-    HalManager *manager;
-    HalDevice *device;
-    gchar **udis = NULL;
-    
-    manager = hal_manager_new ();
-    
-    udis = hal_manager_find_device_by_capability (manager, "laptop_panel");
-    
-    if (!udis || !udis[0] )
-    {
-	TRACE ("No laptop panel found on the system");
-	brightness->priv->has_hw = FALSE;
-	brightness->priv->proxy = NULL;
-	goto out;
-    }
-    
-    device = hal_device_new ();
-    hal_device_set_udi (device, udis[0]);
-    
-    brightness->priv->max_level =
-	hal_device_get_property_int (device, "laptop_panel.num_levels") -1;
-	
-    TRACE("Laptop panel %s with max level %d", udis[0], brightness->priv->max_level);
-    
-    brightness->priv->proxy = dbus_g_proxy_new_for_name (brightness->priv->bus,
-		   			                 "org.freedesktop.Hal",
-						         udis[0],
-						         "org.freedesktop.Hal.Device.LaptopPanel");
-    brightness->priv->has_hw = TRUE;
-    
-    g_object_unref (device);
-out:
-    g_object_unref (manager);
-}
-
-static void
-brightness_proxy_class_init (BrightnessProxyClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-    object_class->finalize = brightness_proxy_finalize;
-
-    g_type_class_add_private (klass, sizeof (BrightnessProxyPrivate));
-}
-
-static void
-brightness_proxy_init (BrightnessProxy *brightness_proxy)
-{
-    brightness_proxy->priv = BRIGHTNESS_PROXY_GET_PRIVATE (brightness_proxy);
-    
-    brightness_proxy->priv->max_level = 0;
-    
-    // FIXME, Don't connect blindly
-    brightness_proxy->priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
-    brightness_proxy->priv->session = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
-    
-    brightness_proxy_get_device (brightness_proxy);
-}
-
-static void
-brightness_proxy_finalize (GObject *object)
-{
-    BrightnessProxy *brightness_proxy;
-
-    brightness_proxy = BRIGHTNESS_PROXY (object);
-    
-    dbus_g_connection_unref (brightness_proxy->priv->bus);
-    dbus_g_connection_unref (brightness_proxy->priv->session);
-    
-    if ( brightness_proxy->priv->proxy )
-	g_object_unref (brightness_proxy->priv->proxy);
-
-    G_OBJECT_CLASS (brightness_proxy_parent_class)->finalize (object);
-}
-
-static void
-brightness_proxy_update_xfpm_brightness_level (BrightnessProxy *brightness, guint level)
-{
-    DBusGProxy *proxy;
-    
-    proxy = dbus_g_proxy_new_for_name (brightness->priv->session,
-				       "org.freedesktop.PowerManagement",
-				       "/org/freedesktop/PowerManagement/Backlight",
-				       "org.freedesktop.PowerManagement.Backlight");
-					       
-    if ( !proxy )
-    {
-	g_warning ("Failed to create proxy to Xfpm");
-	return;
-    }
-
-    dbus_g_proxy_call_no_reply (proxy, "UpdateBrightness",
-			        G_TYPE_UINT, level,
-				G_TYPE_INVALID,
-				G_TYPE_INVALID);
-				
-    g_object_unref ( proxy );
-}
-
-BrightnessProxy *
-brightness_proxy_new (void)
-{
-    BrightnessProxy *brightness_proxy = NULL;
-    brightness_proxy = g_object_new (BRIGHTNESS_TYPE_PROXY, NULL);
-    return brightness_proxy;
-}
-
-gboolean
-brightness_proxy_set_level (BrightnessProxy *brightness, guint level)
-{
-    GError *error = NULL;
-    gboolean ret;
-    gint dummy;
-    
-    g_return_val_if_fail (BRIGHTNESS_IS_PROXY (brightness), FALSE);
-    
-    ret = dbus_g_proxy_call (brightness->priv->proxy, "SetBrightness", &error,
-			     G_TYPE_INT, level,
-			     G_TYPE_INVALID,
-			     G_TYPE_INT, &dummy,
-			     G_TYPE_INVALID );
-    if ( error )
-    {
-	g_critical ("Error setting brightness level: %s\n", error->message);
-	g_error_free (error);
-	return FALSE;
-    }
-	
-    brightness_proxy_update_xfpm_brightness_level (brightness, level);
-    
-    return ret;
-}
-
-guint
-brightness_proxy_get_level (BrightnessProxy *brightness)
-{
-    GError *error = NULL;
-    gint level = 0;
-    gboolean ret;
-    
-    g_return_val_if_fail (BRIGHTNESS_IS_PROXY (brightness), 0);
-    
-    ret = dbus_g_proxy_call (brightness->priv->proxy, "GetBrightness", &error,
-	 		     G_TYPE_INVALID,
-			     G_TYPE_INT, &level,
-			     G_TYPE_INVALID);
-
-    if ( error )
-    {
-	g_critical ("Error getting brightness level: %s\n", error->message);
-	g_error_free (error);
-    }
-    return level;
-}
-
-guint brightness_proxy_get_max_level (BrightnessProxy *brightness)
-{
-    g_return_val_if_fail (BRIGHTNESS_IS_PROXY (brightness), 0);
-    
-    return brightness->priv->max_level;
-}
-
-gboolean brightness_proxy_has_hw (BrightnessProxy *brightness)
-{
-    g_return_val_if_fail (BRIGHTNESS_IS_PROXY (brightness), FALSE);
-    
-    return brightness->priv->has_hw;
-}
-
-
-void brightness_proxy_reload (BrightnessProxy *brightness)
-{
-    g_return_if_fail (BRIGHTNESS_IS_PROXY (brightness));
-    
-    if ( brightness->priv->proxy )
-	g_object_unref (brightness->priv->proxy);
-	
-    brightness_proxy_get_device (brightness);
-}
diff --git a/panel-plugins/brightness/brightness-proxy.h b/panel-plugins/brightness/brightness-proxy.h
deleted file mode 100644
index 5c96035..0000000
--- a/panel-plugins/brightness/brightness-proxy.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * * Copyright (C) 2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __BRIGHTNESS_PROXY_H
-#define __BRIGHTNESS_PROXY_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define BRIGHTNESS_TYPE_PROXY        (brightness_proxy_get_type () )
-#define BRIGHTNESS_PROXY(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), BRIGHTNESS_TYPE_PROXY, BrightnessProxy))
-#define BRIGHTNESS_IS_PROXY(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), BRIGHTNESS_TYPE_PROXY))
-
-typedef struct BrightnessProxyPrivate BrightnessProxyPrivate;
-
-typedef struct
-{
-    GObject         		parent;
-    BrightnessProxyPrivate     *priv;
-    
-} BrightnessProxy;
-
-typedef struct
-{
-    GObjectClass 		parent_class;
-} BrightnessProxyClass;
-
-GType        			brightness_proxy_get_type        (void) G_GNUC_CONST;
-BrightnessProxy       	       *brightness_proxy_new             (void);
-
-gboolean                        brightness_proxy_set_level       (BrightnessProxy *brightness,
-								  guint level);
-
-guint                           brightness_proxy_get_level       (BrightnessProxy *brightness);
-
-guint                           brightness_proxy_get_max_level   (BrightnessProxy *brightness) G_GNUC_PURE;
-
-gboolean                        brightness_proxy_has_hw          (BrightnessProxy *brightness) G_GNUC_PURE;
-
-void                            brightness_proxy_reload          (BrightnessProxy *brightness);
-
-G_END_DECLS
-
-#endif /* __BRIGHTNESS_PROXY_H */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 90297bd..ccb3559 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,33 +3,16 @@
 settings/xfpm-settings.c
 settings/xfpm-settings-main.c
 settings/xfce4-power-manager-settings.desktop.in
+common/xfpm-common.c
+src/xfpm-power.c
+src/xfpm-power-common.c
 src/xfpm-battery.c
-src/xfpm-battery-info.c
-src/xfpm-button-xf86.c
-src/xfpm-brightness-hal.c
 src/xfpm-battery.c
 src/xfpm-main.c
-src/xfpm-cpu.c
-src/xfpm-supply.c
 src/xfpm-network-manager.c
 src/xfpm-dpms.c
-src/xfpm-tray-icon.c
-src/xfpm-engine.c
-src/xfpm-adapter.c
-src/xfpm-manager.c
 src/xfpm-inhibit.c
-src/xfpm-screen-saver.c
-src/xfpm-shutdown.c
+src/xfpm-power-info.c
 src/xfce4-power-manager.desktop.in
-libxfpm/hal-battery.c
-libxfpm/hal-device.c
-libxfpm/hal-manager.c
-libxfpm/hal-power.c
-libxfpm/hal-battery.c
-libxfpm/xfpm-common.c
-libxfpm/xfpm-string.c
-libxfpm/xfpm-dbus.c
-libxfpm/xfpm-popups.c
-libxfpm/xfpm-notify.c
 panel-plugins/brightness/brightness-button.c
 panel-plugins/brightness/xfce4-brightness-plugin.desktop.in.in
diff --git a/settings/Makefile.am b/settings/Makefile.am
index dafbd3c..7d80680 100644
--- a/settings/Makefile.am
+++ b/settings/Makefile.am
@@ -11,8 +11,10 @@ xfce4_power_manager_settings_SOURCES = 				\
 
 xfce4_power_manager_settings_CFLAGS =				\
 	-I$(top_srcdir)						\
+	-I$(top_srcdir)/common					\
 	-I$(top_srcdir)/src					\
 	-I$(top_srcdir)/data					\
+	-I$(top_srcdir)/libdbus                 		\
 	-DLOCALEDIR=\"$(localedir)\"				\
 	-DG_LOG_DOMAIN=\"xfce4-power-manager-settings\" 	\
 	-export-dynamic						\
@@ -23,21 +25,22 @@ xfce4_power_manager_settings_CFLAGS =				\
 	$(GMODULE_CFLAGS)					\
 	$(DBUS_CFLAGS)						\
 	$(DBUS_GLIB_CFLAGS)					\
-	$(LIBXFCE4GUI_CFLAGS)					\
+	$(LIBXFCE4UI_CFLAGS)					\
 	$(LIBXFCE4UTIL_CFLAGS)					\
 	$(XFCONF_CFLAGS)
 
 xfce4_power_manager_settings_LDADD   =				\
+	$(top_builddir)/libdbus/libxfpmdbus.la  		\
+	$(top_builddir)/common/libxfpmcommon.la			\
 	$(GTK_LIBS)						\
 	$(GLIB_LIBS)						\
 	$(GTHREAD_LIBS)						\
 	$(GMODULE_LIBS)						\
 	$(DBUS_LIBS)						\
 	$(DBUS_GLIB_LIBS)					\
-	$(LIBXFCE4GUI_LIBS)					\
+	$(LIBXFCE4UI_LIBS)					\
 	$(LIBXFCE4UTIL_LIBS)					\
-	$(XFCONF_LIBS)						\
-	$(top_builddir)/libxfpm/libxfpmcommon.la
+	$(XFCONF_LIBS)
 
 
 manpagedir = $(mandir)/man1
diff --git a/settings/xfpm-settings-main.c b/settings/xfpm-settings-main.c
index f0ecedf..49d31da 100644
--- a/settings/xfpm-settings-main.c
+++ b/settings/xfpm-settings-main.c
@@ -30,36 +30,42 @@
 #include <glib.h>
 
 #include <libxfce4util/libxfce4util.h>
-#include <libxfcegui4/libxfcegui4.h>
+#include <libxfce4ui/libxfce4ui.h>
 
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
 
 #include <xfconf/xfconf.h>
 
-#include "libxfpm/xfpm-popups.h"
-#include "libxfpm/xfpm-string.h"
-#include "libxfpm/xfpm-common.h"
-#include "libxfpm/xfpm-dbus.h"
+#include "common/xfpm-common.h"
 
 #include "xfce-power-manager-dbus-client.h"
 #include "xfpm-settings.h"
 #include "xfpm-config.h"
+#include "xfpm-dbus.h"
 
-int main(int argc, char **argv)
+#include "xfpm-unique.h"
+
+int main (int argc, char **argv)
 {
+    
     GError *error = NULL;
     DBusGConnection *bus;
     GHashTable *config_hash;
     
-    gboolean system_laptop;
-    gboolean user_privilege;
+    gboolean has_battery;
+    gboolean auth_suspend;
+    gboolean auth_hibernate;
     gboolean can_suspend;
     gboolean can_hibernate;
+    gboolean can_shutdown;
     gboolean has_lcd_brightness;
     gboolean has_sleep_button;
     gboolean has_hibernate_button;
     gboolean has_power_button;
+    gboolean has_lid;
+    gboolean can_spin_down;
+    gboolean devkit_disk;
     gboolean start_xfpm_if_not_running;
     
     GdkNativeWindow socket_id = 0;
@@ -98,73 +104,84 @@ int main(int argc, char **argv)
 	g_error ("%s\n",error->message);
     }
 
-    if ( xfpm_dbus_name_has_owner(dbus_g_connection_get_connection(bus), "org.xfce.PowerManager") ) 
+    if ( xfpm_dbus_name_has_owner (dbus_g_connection_get_connection(bus), "org.xfce.PowerManager") ) 
     {
+	GtkWidget *dialog;
+	XfpmUnique *unique;
 	TRACE("Xfce power manager is running\n");
 	
-	if ( xfpm_dbus_name_has_owner(dbus_g_connection_get_connection(bus), "org.xfce.PowerManager.Config") )
-	{
-	    TRACE("Settings dialog already open\n");
-	    dbus_g_connection_unref(bus);
-	    return EXIT_SUCCESS;
-	}
-	
-	xfpm_dbus_register_name(dbus_g_connection_get_connection(bus), "org.xfce.PowerManager.Config");
+	unique = xfpm_unique_new ("org.xfce.PowerManager.Config");
 	
-	if ( !xfconf_init(&error) )
-    	{
-	    g_critical("xfconf init failed: %s using default settings\n", error->message);
+	if ( !xfpm_unique_app_is_running (unique) )
+	{
+	    if ( !xfconf_init(&error) )
+	    {
+		g_critical("xfconf init failed: %s using default settings\n", error->message);
+		xfce_dialog_show_warning (NULL, 
+					  _("Xfce Power Manager"), 
+					  "%s",
+					  _("Failed to load power manager configuration, using defaults"));
+		g_error_free (error);
+		error = NULL;
+		return EXIT_FAILURE;
+	    }
 	    
-	    xfpm_popup_message(_("Xfce Power Manager"),_("Failed to load power manager configuration, "\
-	    			"using defaults"), GTK_MESSAGE_WARNING);
-	    g_error_free(error);
-	    error = NULL;
-	    return EXIT_FAILURE;
-    	}
-	
-	if ( !g_thread_supported () )
-	    g_thread_init (NULL);
+	    if ( !g_thread_supported () )
+		g_thread_init (NULL);
+		
+	    dbus_g_thread_init ();
 	    
-	dbus_g_thread_init ();
-	
-	channel = xfconf_channel_new(XFPM_CHANNEL_CFG);
-	
-   	proxy = dbus_g_proxy_new_for_name(bus,
-				           "org.xfce.PowerManager",
-				           "/org/xfce/PowerManager",
-				           "org.xfce.Power.Manager");
-	
-	xfpm_manager_dbus_client_get_config (proxy, 
-					     &config_hash,
-					     &error);
-					     
-	if ( error )
-	{
-	    g_critical ("Unable to get configuration information from xfce power manager: %s", error->message);
-	    xfpm_error (_("Xfce Power Manager Settings"),
-		       _("Unable to connect to Xfce Power Manager") );
-	    g_error_free (error);
-	    return EXIT_FAILURE;
+	    channel = xfconf_channel_new(XFPM_CHANNEL_CFG);
+	    
+	    proxy = dbus_g_proxy_new_for_name(bus,
+					       "org.xfce.PowerManager",
+					       "/org/xfce/PowerManager",
+					       "org.xfce.Power.Manager");
+	    
+	    xfpm_manager_dbus_client_get_config (proxy, 
+						 &config_hash,
+						 &error);
+						 
+	    if ( error )
+	    {
+		g_critical ("Unable to get configuration information from xfce power manager: %s", error->message);
+		xfce_dialog_show_error (NULL, error, "%s", _("Unable to connect to Xfce Power Manager"));
+		g_error_free (error);
+		return EXIT_FAILURE;
+	    }
+	    
+	    has_battery = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "has-battery"));
+	    has_lid = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "has-lid"));
+	    can_suspend = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "can-suspend"));
+	    can_hibernate = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "can-hibernate"));
+	    auth_suspend = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "auth-suspend"));
+	    auth_hibernate = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "auth-hibernate"));
+	    has_lcd_brightness = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "has-brightness"));
+	    has_sleep_button = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "sleep-button"));
+	    has_power_button = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "power-button"));
+	    has_hibernate_button = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "hibernate-button"));
+	    can_shutdown = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "can-shutdown"));
+	    can_spin_down = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "can-spin"));
+	    devkit_disk = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "devkit-disk"));
+	    
+	    g_hash_table_destroy (config_hash);
+	    
+	    dialog = xfpm_settings_dialog_new (channel, has_battery, auth_hibernate, auth_suspend,
+					       can_shutdown, can_suspend, can_hibernate, has_lcd_brightness,
+					       has_lid, has_sleep_button, has_hibernate_button, has_power_button,
+					       devkit_disk, can_spin_down, socket_id);
+	    
+	    g_signal_connect_swapped (unique, "ping-received",
+				      G_CALLBACK (gtk_window_present), dialog);
+					       
+	    gtk_main();
+	    
+	    xfpm_dbus_release_name(dbus_g_connection_get_connection(bus), "org.xfce.PowerManager.Config");
+	    dbus_g_connection_unref (bus);
+	    g_object_unref (proxy);
 	}
 	
-	system_laptop = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "system-laptop"));
-	can_suspend = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "can-suspend"));
-	can_hibernate = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "can-hibernate"));
-	user_privilege = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "caller-privilege"));
-	has_lcd_brightness = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "has-brightness"));
-	has_sleep_button = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "sleep-button"));
-	has_power_button = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "power-button"));
-	has_hibernate_button = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "hibernate-button"));
-	
-	xfpm_settings_dialog_new (channel, system_laptop, user_privilege,
-				  can_suspend, can_hibernate, has_lcd_brightness,
-				  system_laptop, has_sleep_button, has_hibernate_button, has_power_button,
-				  socket_id);
-					   
-	gtk_main();
-	
-	xfpm_dbus_release_name(dbus_g_connection_get_connection(bus), "org.xfce.PowerManager.Config");
-	dbus_g_connection_unref(bus);
+	g_object_unref (unique);
 	
 	return EXIT_SUCCESS;
     }
@@ -173,9 +190,12 @@ int main(int argc, char **argv)
 	g_print(_("Xfce power manager is not running"));
 	g_print("\n");
 	start_xfpm_if_not_running =
-	    xfce_confirm(_("Xfce4 Power Manager is not running, do you want to launch it now?"),
-			GTK_STOCK_YES,
-			_("Run"));
+	    xfce_dialog_confirm (NULL, 
+				 GTK_STOCK_YES, 
+				 _("Run"), 
+				 _("Xfce4 Power Manager is not running, do you want to launch it now?"),
+				 NULL);
+	
 	if ( start_xfpm_if_not_running ) 
 	{
 	    g_spawn_command_line_async("xfce4-power-manager",NULL);
diff --git a/settings/xfpm-settings.c b/settings/xfpm-settings.c
index f519d75..c15dbfb 100644
--- a/settings/xfpm-settings.c
+++ b/settings/xfpm-settings.c
@@ -32,11 +32,11 @@
 #include <xfconf/xfconf.h>
 
 #include <libxfce4util/libxfce4util.h>
-#include <libxfcegui4/libxfcegui4.h>
+#include <libxfce4ui/libxfce4ui.h>
 
-#include "libxfpm/xfpm-common.h"
-#include "libxfpm/xfpm-string.h"
-#include "libxfpm/xfpm-icons.h"
+#include "xfpm-common.h"
+#include "xfpm-icons.h"
+#include "xfpm-debug.h"
 
 #include "interfaces/xfpm-settings_ui.h"
 
@@ -149,7 +149,10 @@ void        critical_level_value_changed_cb        (GtkSpinButton *w,
 void        lock_screen_toggled_cb                 (GtkWidget *w, 
 						    XfconfChannel *channel);
 
-void        cpu_freq_control_changed_cb            (GtkWidget *w, 
+void        on_battery_spin_changed		   (GtkWidget *w,
+						    XfconfChannel *channel);
+
+void        on_ac_spin_changed		   	   (GtkWidget *w,
 						    XfconfChannel *channel);
 
 void        _cursor_changed_cb 			   (GtkTreeView *view, 
@@ -702,23 +705,33 @@ lock_screen_toggled_cb (GtkWidget *w, XfconfChannel *channel)
     }
 }
 
-void
-cpu_freq_control_changed_cb (GtkWidget *w, XfconfChannel *channel)
+void on_battery_spin_changed (GtkWidget *w,  XfconfChannel *channel)
 {
-#ifdef SYSTEM_IS_LINUX
-    gboolean val = (gint) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(w));
+    gboolean val = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(w));
     
-    if ( !xfconf_channel_set_bool (channel, PROPERTIES_PREFIX CPU_FREQ_CONTROL, val) )
+    if ( !xfconf_channel_set_bool (channel, PROPERTIES_PREFIX SPIN_DOWN_ON_BATTERY, val) )
     {
-	g_critical ("Unable to set value for property %s\n", CPU_FREQ_CONTROL);
+	g_critical ("Unable to set value for property %s", SPIN_DOWN_ON_BATTERY);
     }
-#endif
+    
 }
 
+void on_ac_spin_changed	(GtkWidget *w, XfconfChannel *channel)
+{
+    gboolean val = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(w));
+    
+    if ( !xfconf_channel_set_bool (channel, PROPERTIES_PREFIX SPIN_DOWN_ON_AC, val) )
+    {
+	g_critical ("Unable to set value for property %s", SPIN_DOWN_ON_AC);
+    }
+}
 
 static void
-xfpm_settings_on_battery (XfconfChannel *channel, gboolean user_privilege, gboolean can_suspend, 
-			 gboolean can_hibernate, gboolean has_lcd_brightness, gboolean has_lid)
+xfpm_settings_on_battery (XfconfChannel *channel, gboolean auth_hibernate, 
+			  gboolean auth_suspend, gboolean can_shutdown, 
+			  gboolean can_suspend, gboolean can_hibernate, 
+			  gboolean has_lcd_brightness, gboolean has_lid,
+			  gboolean devkit_disk, gboolean can_spin_down)
 {
     gboolean valid;
     gint list_value;
@@ -733,6 +746,7 @@ xfpm_settings_on_battery (XfconfChannel *channel, gboolean user_privilege, gbool
     GtkWidget *label;
     GtkWidget *brg;
     GtkWidget *frame;
+    GtkWidget *spin_down;
 #ifdef HAVE_DPMS
     GtkWidget *dpms_frame_on_battery;
 #endif
@@ -744,6 +758,11 @@ xfpm_settings_on_battery (XfconfChannel *channel, gboolean user_privilege, gbool
     if ( !can_suspend && !can_hibernate )
     {
 	gtk_widget_set_sensitive (inact, FALSE);
+	gtk_widget_set_tooltip_text (inact, _("Hibernate and suspend operations not supported"));
+    }
+    else if ( !auth_suspend && !auth_hibernate )
+    {
+	gtk_widget_set_sensitive (inact, FALSE);
 	gtk_widget_set_tooltip_text (inact, _("Hibernate and suspend operations not permitted"));
     }
     
@@ -751,12 +770,6 @@ xfpm_settings_on_battery (XfconfChannel *channel, gboolean user_privilege, gbool
     gtk_range_set_value (GTK_RANGE (inact), val);
     
     
-    if (!user_privilege )
-    {
-	gtk_widget_set_sensitive (battery_critical, FALSE);
-	gtk_widget_set_tooltip_text (battery_critical, _("Shutdown and hibernate operations not permitted"));
-    }
-    
     list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
     
     gtk_combo_box_set_model (GTK_COMBO_BOX(battery_critical), GTK_TREE_MODEL(list_store));
@@ -764,20 +777,23 @@ xfpm_settings_on_battery (XfconfChannel *channel, gboolean user_privilege, gbool
     gtk_list_store_append(list_store, &iter);
     gtk_list_store_set (list_store, &iter, 0, _("Nothing"), 1, XFPM_DO_NOTHING, -1);
     
-    if ( can_suspend )
+    if ( can_suspend && auth_suspend )
     {
 	gtk_list_store_append(list_store, &iter);
 	gtk_list_store_set (list_store, &iter, 0, _("Suspend"), 1, XFPM_DO_SUSPEND, -1);
     }
     
-    if ( can_hibernate )
+    if ( can_hibernate && auth_hibernate )
     {
 	gtk_list_store_append(list_store, &iter);
 	gtk_list_store_set (list_store, &iter, 0, _("Hibernate"), 1, XFPM_DO_HIBERNATE, -1);
     }
 
-    gtk_list_store_append(list_store, &iter);
-    gtk_list_store_set (list_store, &iter, 0, _("Shutdown"), 1, XFPM_DO_SHUTDOWN, -1);
+    if ( can_shutdown )
+    {
+	gtk_list_store_append(list_store, &iter);
+	gtk_list_store_set (list_store, &iter, 0, _("Shutdown"), 1, XFPM_DO_SHUTDOWN, -1);
+    }
     
     gtk_list_store_append(list_store, &iter);
     gtk_list_store_set (list_store, &iter, 0, _("Ask"), 1, XFPM_ASK, -1);
@@ -822,12 +838,6 @@ xfpm_settings_on_battery (XfconfChannel *channel, gboolean user_privilege, gbool
     lid = GTK_WIDGET (gtk_builder_get_object (xml, "on-battery-lid"));
     if ( has_lid )
     {
-	if (!user_privilege )
-	{
-	    gtk_widget_set_sensitive (lid, FALSE);
-	    gtk_widget_set_tooltip_text (lid, _("Shutdown and hibernate operations not permitted"));
-	}
-	
 	list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
 	
 	gtk_combo_box_set_model (GTK_COMBO_BOX(lid), GTK_TREE_MODEL(list_store));
@@ -835,13 +845,13 @@ xfpm_settings_on_battery (XfconfChannel *channel, gboolean user_privilege, gbool
 	gtk_list_store_append(list_store, &iter);
 	gtk_list_store_set (list_store, &iter, 0, _("Nothing"), 1, LID_TRIGGER_NOTHING, -1);
 	
-	if ( can_suspend )
+	if ( can_suspend && auth_suspend )
 	{
 	    gtk_list_store_append(list_store, &iter);
 	    gtk_list_store_set (list_store, &iter, 0, _("Suspend"), 1, LID_TRIGGER_SUSPEND, -1);
 	}
 	
-	if ( can_hibernate)
+	if ( can_hibernate && auth_hibernate)
 	{
 	    gtk_list_store_append(list_store, &iter);
 	    gtk_list_store_set (list_store, &iter, 0, _("Hibernate"), 1, LID_TRIGGER_HIBERNATE, -1);
@@ -895,16 +905,31 @@ xfpm_settings_on_battery (XfconfChannel *channel, gboolean user_privilege, gbool
 	gtk_notebook_remove_page (GTK_NOTEBOOK (nt), 1);
     }
 #endif
+
+    spin_down = GTK_WIDGET (gtk_builder_get_object (xml, "spin-down-on-battery"));
+    gtk_widget_set_sensitive (spin_down, can_spin_down);
+    
+    if ( !devkit_disk )
+    {
+	gtk_widget_hide (spin_down);
+    }
+    else if ( !can_spin_down )
+    {
+	gtk_widget_set_tooltip_text (spin_down, _("Spinning down hard disks permission denied"));
+    }
 }
 
 static void
-xfpm_settings_on_ac (XfconfChannel *channel, gboolean user_privilege, gboolean can_suspend, 
-		     gboolean can_hibernate, gboolean has_lcd_brightness, gboolean has_lid)
+xfpm_settings_on_ac (XfconfChannel *channel, gboolean auth_suspend, 
+		     gboolean auth_hibernate, gboolean can_suspend, 
+		     gboolean can_hibernate, gboolean has_lcd_brightness, 
+		     gboolean has_lid, gboolean devkit_disk, gboolean can_spin_down)
 {
     GtkWidget *inact;
     GtkWidget *lid;
     GtkWidget *frame;
     GtkWidget *brg;
+    GtkWidget *spin_down;
     GtkListStore *list_store;
     GtkTreeIter iter;
     guint val;
@@ -920,6 +945,11 @@ xfpm_settings_on_ac (XfconfChannel *channel, gboolean user_privilege, gboolean c
     if ( !can_suspend && !can_hibernate )
     {
 	gtk_widget_set_sensitive (inact, FALSE);
+	gtk_widget_set_tooltip_text (inact, _("Hibernate and suspend operations not supported"));
+    }
+    else  if ( !auth_suspend && !auth_hibernate )
+    {
+	gtk_widget_set_sensitive (inact, FALSE);
 	gtk_widget_set_tooltip_text (inact, _("Hibernate and suspend operations not permitted"));
     }
     
@@ -948,12 +978,6 @@ xfpm_settings_on_ac (XfconfChannel *channel, gboolean user_privilege, gboolean c
     {
 	list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
 	
-	if ( !user_privilege )
-	{
-	    gtk_widget_set_sensitive (lid, FALSE);
-	    gtk_widget_set_tooltip_text (lid, _("Hibernate and suspend operations not permitted"));
-	    
-	}
 	gtk_combo_box_set_model (GTK_COMBO_BOX(lid), GTK_TREE_MODEL(list_store));
 	
 	gtk_list_store_append(list_store, &iter);
@@ -1019,10 +1043,24 @@ xfpm_settings_on_ac (XfconfChannel *channel, gboolean user_privilege, gboolean c
 	gtk_notebook_remove_page (GTK_NOTEBOOK (GTK_WIDGET (gtk_builder_get_object (xml, "on-ac-notebook"))), 1);
     }
 #endif
+
+    spin_down = GTK_WIDGET (gtk_builder_get_object (xml, "spin-down-on-ac"));
+    gtk_widget_set_sensitive (spin_down, can_spin_down);
+    
+    if ( !devkit_disk )
+    {
+	gtk_widget_hide (spin_down);
+    }
+    else if ( !can_spin_down )
+    {
+	gtk_widget_set_tooltip_text (spin_down, _("Spinning down hard disks permission denied"));
+    }
+
 }
 
 static void
-xfpm_settings_general (XfconfChannel *channel, gboolean user_privilege,
+xfpm_settings_general (XfconfChannel *channel, gboolean auth_hibernate, 
+		       gboolean auth_suspend, gboolean can_shutdown,  
 		       gboolean can_suspend, gboolean can_hibernate,
 		       gboolean has_sleep_button, gboolean has_hibernate_button,
 		       gboolean has_power_button)
@@ -1105,31 +1143,28 @@ xfpm_settings_general (XfconfChannel *channel, gboolean user_privilege,
     
     if ( has_power_button )
     {
-	if (!user_privilege )
-	{
-	    gtk_widget_set_sensitive (power, FALSE);
-	    gtk_widget_set_tooltip_text (power, _("Hibernate and suspend operations not permitted"));
-	}
-	
 	gtk_combo_box_set_model (GTK_COMBO_BOX(power), GTK_TREE_MODEL(list_store));
 
 	gtk_list_store_append (list_store, &iter);
 	gtk_list_store_set (list_store, &iter, 0, _("Nothing"), 1, XFPM_DO_NOTHING, -1);
 	
-	if ( can_suspend )
+	if ( can_suspend && auth_suspend)
 	{
 	    gtk_list_store_append (list_store, &iter);
 	    gtk_list_store_set (list_store, &iter, 0, _("Suspend"), 1, XFPM_DO_SUSPEND, -1);
 	}
 	
-	if ( can_hibernate )
+	if ( can_hibernate && auth_hibernate )
 	{
 	    gtk_list_store_append (list_store, &iter);
 	    gtk_list_store_set (list_store, &iter, 0, _("Hibernate"), 1, XFPM_DO_HIBERNATE, -1);
 	}
 	
-	gtk_list_store_append (list_store, &iter);
-	gtk_list_store_set (list_store, &iter, 0, _("Shutdown"), 1, XFPM_DO_SHUTDOWN, -1);
+	if ( can_shutdown )
+	{
+	    gtk_list_store_append (list_store, &iter);
+	    gtk_list_store_set (list_store, &iter, 0, _("Shutdown"), 1, XFPM_DO_SHUTDOWN, -1);
+	}
 	
 	gtk_list_store_append (list_store, &iter);
 	gtk_list_store_set (list_store, &iter, 0, _("Ask"), 1, XFPM_ASK, -1);
@@ -1163,24 +1198,18 @@ xfpm_settings_general (XfconfChannel *channel, gboolean user_privilege,
     
     if (has_hibernate_button )
     {
-	if (!user_privilege )
-	{
-	    gtk_widget_set_sensitive (hibernate, FALSE);
-	    gtk_widget_set_tooltip_text (hibernate, _("Hibernate and suspend operations not permitted"));
-	}
-	
 	gtk_combo_box_set_model (GTK_COMBO_BOX(hibernate), GTK_TREE_MODEL(list_store));
 
 	gtk_list_store_append (list_store, &iter);
 	gtk_list_store_set (list_store, &iter, 0, _("Nothing"), 1, XFPM_DO_NOTHING, -1);
 	
-	if ( can_suspend )
+	if ( can_suspend && auth_suspend)
 	{
 	    gtk_list_store_append (list_store, &iter);
 	    gtk_list_store_set (list_store, &iter, 0, _("Suspend"), 1, XFPM_DO_SUSPEND, -1);
 	}
 	
-	if ( can_hibernate )
+	if ( can_hibernate && auth_hibernate )
 	{
 	    gtk_list_store_append (list_store, &iter);
 	    gtk_list_store_set (list_store, &iter, 0, _("Hibernate"), 1, XFPM_DO_HIBERNATE, -1);
@@ -1190,6 +1219,7 @@ xfpm_settings_general (XfconfChannel *channel, gboolean user_privilege,
 	gtk_list_store_set (list_store, &iter, 0, _("Ask"), 1, XFPM_ASK, -1);
 	
 	value = xfconf_channel_get_uint (channel, PROPERTIES_PREFIX HIBERNATE_SWITCH_CFG, XFPM_DO_NOTHING);
+	
 	for ( valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (list_store), &iter);
 	      valid;
 	      valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (list_store), &iter) )
@@ -1218,24 +1248,18 @@ xfpm_settings_general (XfconfChannel *channel, gboolean user_privilege,
     
     if ( has_sleep_button )
     {
-	if (!user_privilege )
-	{
-	    gtk_widget_set_sensitive (sleep_w, FALSE);
-	    gtk_widget_set_tooltip_text (sleep_w, _("Hibernate and suspend operations not permitted"));
-	}
-	
 	gtk_combo_box_set_model (GTK_COMBO_BOX(sleep_w), GTK_TREE_MODEL(list_store));
 
 	gtk_list_store_append (list_store, &iter);
 	gtk_list_store_set (list_store, &iter, 0, _("Nothing"), 1, XFPM_DO_NOTHING, -1);
 	
-	if ( can_suspend )
+	if ( can_suspend && auth_suspend )
 	{
 	    gtk_list_store_append (list_store, &iter);
 	    gtk_list_store_set (list_store, &iter, 0, _("Suspend"), 1, XFPM_DO_SUSPEND, -1);
 	}
 	
-	if ( can_hibernate )
+	if ( can_hibernate && auth_hibernate)
 	{
 	    gtk_list_store_append (list_store, &iter);
 	    gtk_list_store_set (list_store, &iter, 0, _("Hibernate"), 1, XFPM_DO_HIBERNATE, -1);
@@ -1271,18 +1295,17 @@ xfpm_settings_general (XfconfChannel *channel, gboolean user_privilege,
     val = xfconf_channel_get_bool (channel, PROPERTIES_PREFIX GENERAL_NOTIFICATION_CFG, TRUE);
     
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(notify), val);
-    
 }
 
 static void
-xfpm_settings_advanced (XfconfChannel *channel, gboolean system_laptop, gboolean user_privilege,
+xfpm_settings_advanced (XfconfChannel *channel, gboolean system_laptop, 
+		        gboolean auth_hibernate, gboolean auth_suspend,
 			gboolean can_suspend, gboolean can_hibernate)
 {
     guint val;
     gchar *str;
     GtkWidget *critical_level;
     GtkWidget *lock;
-    GtkWidget *cpu;
     GtkWidget *label;
     GtkWidget *sleep_dpms_mode;
     GtkWidget *suspend_dpms_mode;
@@ -1292,6 +1315,11 @@ xfpm_settings_advanced (XfconfChannel *channel, gboolean system_laptop, gboolean
     
     if ( !can_suspend )
     {
+	gtk_widget_set_sensitive (inact_suspend, FALSE);
+	gtk_widget_set_tooltip_text (inact_suspend, _("Suspend operation not supported"));
+    }
+    else if ( !auth_suspend )
+    {
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (inact_hibernate), TRUE);
 	gtk_widget_set_sensitive (inact_suspend, FALSE);
 	gtk_widget_set_tooltip_text (inact_suspend, _("Suspend operation not permitted"));
@@ -1300,13 +1328,18 @@ xfpm_settings_advanced (XfconfChannel *channel, gboolean system_laptop, gboolean
     if ( !can_hibernate )
     {
 	gtk_widget_set_sensitive (inact_hibernate, FALSE);
+	gtk_widget_set_tooltip_text (inact_hibernate, _("Hibernate operation not supported"));
+    }
+    else if ( !auth_hibernate)
+    {
+	gtk_widget_set_sensitive (inact_hibernate, FALSE);
 	gtk_widget_set_tooltip_text (inact_hibernate, _("Hibernate operation not permitted"));
     }
    
     str = xfconf_channel_get_string (channel, PROPERTIES_PREFIX INACTIVITY_SLEEP_MODE, "Suspend");
-    if ( xfpm_strequal (str, "Suspend") )
+    if ( !g_strcmp0 (str, "Suspend") )
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (inact_suspend), TRUE);
-    else if ( xfpm_strequal (str, "Hibernate"))
+    else if ( !g_strcmp0 (str, "Hibernate"))
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (inact_hibernate), TRUE);
     else 
     {
@@ -1322,9 +1355,9 @@ xfpm_settings_advanced (XfconfChannel *channel, gboolean system_laptop, gboolean
 #ifdef HAVE_DPMS
     str = xfconf_channel_get_string (channel, PROPERTIES_PREFIX DPMS_SLEEP_MODE, "standby");
     
-    if ( xfpm_strequal (str, "standby" ) )
+    if ( !g_strcmp0 (str, "standby" ) )
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sleep_dpms_mode), TRUE);
-    else if ( xfpm_strequal (str, "suspend") )
+    else if ( !g_strcmp0 (str, "suspend") )
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (suspend_dpms_mode), TRUE);
     else 
     {
@@ -1351,7 +1384,7 @@ xfpm_settings_advanced (XfconfChannel *channel, gboolean system_laptop, gboolean
     
 	val = xfconf_channel_get_uint (channel, PROPERTIES_PREFIX CRITICAL_POWER_LEVEL, 10);
 
-	if ( G_UNLIKELY (val > 20) )
+	if ( val > 20 || val < 5)
 	{
 	    g_critical ("Value %d if out of range for property %s\n", val, CRITICAL_POWER_LEVEL);
 	    gtk_spin_button_set_value (GTK_SPIN_BUTTON(critical_level), 10);
@@ -1371,7 +1404,12 @@ xfpm_settings_advanced (XfconfChannel *channel, gboolean system_laptop, gboolean
      */
     lock = GTK_WIDGET (gtk_builder_get_object (xml, "lock-screen"));
     
-    if ( !user_privilege )
+    if ( !can_suspend && !can_hibernate )
+    {
+	gtk_widget_set_sensitive (lock, FALSE);
+	gtk_widget_set_tooltip_text (lock, _("Hibernate and suspend operations not supported"));
+    }
+    else if ( !auth_hibernate && !auth_suspend)
     {
 	gtk_widget_set_sensitive (lock, FALSE);
 	gtk_widget_set_tooltip_text (lock, _("Hibernate and suspend operations not permitted"));
@@ -1379,21 +1417,6 @@ xfpm_settings_advanced (XfconfChannel *channel, gboolean system_laptop, gboolean
     
     val = xfconf_channel_get_bool (channel, PROPERTIES_PREFIX LOCK_SCREEN_ON_SLEEP, TRUE);
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(lock), val);
- 
-    cpu = GTK_WIDGET (gtk_builder_get_object (xml, "cpu-freq"));
-    
-#ifdef SYSTEM_IS_LINUX
-    if ( system_laptop )
-    {
-	val = xfconf_channel_get_bool (channel, PROPERTIES_PREFIX CPU_FREQ_CONTROL, TRUE);
-	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(cpu), val);
-    }
-    else
-	gtk_widget_hide (cpu);
-#else
-    gtk_widget_hide (cpu);
-#endif
-
 }
 
 void
@@ -1454,7 +1477,7 @@ xfpm_settings_tree_view (XfconfChannel *channel, gboolean system_laptop)
     gtk_tree_view_append_column(GTK_TREE_VIEW(view),col);
     
     /*General settings */
-    pix = xfce_themed_icon_load ("preferences-system", 48); 
+    pix = xfpm_icon_load ("preferences-system", 48); 
     
     gtk_list_store_append(list_store, &iter);
     
@@ -1470,7 +1493,7 @@ xfpm_settings_tree_view (XfconfChannel *channel, gboolean system_laptop)
     i++;
     
     /* ON ac power */
-    pix = xfce_themed_icon_load (XFPM_AC_ADAPTER_ICON, 48); 
+    pix = xfpm_icon_load (XFPM_AC_ADAPTER_ICON, 48); 
     gtk_list_store_append(list_store, &iter);
     if ( pix )
     {
@@ -1485,7 +1508,7 @@ xfpm_settings_tree_view (XfconfChannel *channel, gboolean system_laptop)
     
     if ( system_laptop )
     {
-	pix = xfce_themed_icon_load (XFPM_BATTERY_ICON, 48); 
+	pix = xfpm_icon_load (XFPM_BATTERY_ICON, 48); 
 	gtk_list_store_append(list_store, &iter);
 	if ( pix )
 	{
@@ -1499,7 +1522,7 @@ xfpm_settings_tree_view (XfconfChannel *channel, gboolean system_laptop)
     }
     i++;
     
-    pix = xfce_themed_icon_load ("applications-other", 48); 
+    pix = xfpm_icon_load ("applications-other", 48); 
     gtk_list_store_append(list_store, &iter);
     if ( pix )
     {
@@ -1548,12 +1571,14 @@ delete_event_cb (GtkWidget *plug, GdkEvent *ev, XfconfChannel *channel)
     settings_quit (plug, channel);
 }
 
-void
+GtkWidget *
 xfpm_settings_dialog_new (XfconfChannel *channel, gboolean system_laptop, 
-			  gboolean user_privilege, gboolean can_suspend, 
+			  gboolean auth_hibernate, gboolean auth_suspend, 
+			  gboolean can_shutdown, gboolean can_suspend, 
 			  gboolean can_hibernate, gboolean has_lcd_brightness, 
 			  gboolean has_lid, gboolean has_sleep_button, 
 			  gboolean has_hibernate_button, gboolean has_power_button,
+			  gboolean devkit_disk, gboolean can_spin_down, 
 			  GdkNativeWindow id)
 {
     GtkWidget *plug;
@@ -1561,19 +1586,20 @@ xfpm_settings_dialog_new (XfconfChannel *channel, gboolean system_laptop,
     GtkWidget *allbox;
     GError *error = NULL;
 
-    TRACE("system_laptop=%s user_privilege=%s can_suspend=%s can_hibernate=%s has_lcd_brightness=%s has_lid=%s "\
-          "has_sleep_button=%s has_hibernate_button=%s has_power_button=%s",
-	  xfpm_bool_to_string (system_laptop), xfpm_bool_to_string (user_privilege),
+    XFPM_DEBUG ("system_laptop=%s auth_hibernate=%s  auth_suspend=%s can_shutdown=%s can_suspend=%s can_hibernate=%s has_lcd_brightness=%s has_lid=%s "\
+           "has_sleep_button=%s has_hibernate_button=%s has_power_button=%s can_spin_down=%s",
+	  xfpm_bool_to_string (system_laptop), xfpm_bool_to_string (auth_hibernate), 
+	  xfpm_bool_to_string (can_shutdown), xfpm_bool_to_string (auth_suspend),
 	  xfpm_bool_to_string (can_suspend), xfpm_bool_to_string (can_hibernate),
 	  xfpm_bool_to_string (has_lcd_brightness), xfpm_bool_to_string (has_lid),
 	  xfpm_bool_to_string (has_sleep_button), xfpm_bool_to_string (has_hibernate_button),
-	  xfpm_bool_to_string (has_power_button) );
+	  xfpm_bool_to_string (has_power_button), xfpm_bool_to_string (can_spin_down) );
 
     xml = xfpm_builder_new_from_string (xfpm_settings_ui, &error);
     
     if ( G_UNLIKELY (error) )
     {
-	xfce_err ("%s : %s", error->message, _("Check your power manager installation"));
+	xfce_dialog_show_error (NULL, error, "%s", _("Check your power manager installation"));
 	g_error ("%s", error->message);
     }
     
@@ -1589,17 +1615,34 @@ xfpm_settings_dialog_new (XfconfChannel *channel, gboolean system_laptop,
     dialog = GTK_WIDGET (gtk_builder_get_object (xml, "xfpm-settings-dialog"));
     nt = GTK_WIDGET (gtk_builder_get_object (xml, "main-notebook"));
     
-    xfpm_settings_on_ac (channel, user_privilege, can_suspend, can_hibernate, has_lcd_brightness, has_lid );
+    xfpm_settings_on_ac (channel, 
+			 auth_hibernate, 
+			 auth_suspend, 
+			 can_suspend, 
+			 can_hibernate, 
+			 has_lcd_brightness, 
+			 has_lid,
+			 devkit_disk,
+			 can_spin_down);
     
     if ( system_laptop )
-	xfpm_settings_on_battery (channel, user_privilege, can_suspend, can_hibernate, has_lcd_brightness, has_lid);
+	xfpm_settings_on_battery (channel, 
+				  auth_hibernate, 
+				  auth_suspend, 
+				  can_shutdown, 
+				  can_suspend, 
+				  can_hibernate, 
+				  has_lcd_brightness, 
+				  has_lid,
+				  devkit_disk,
+				  can_spin_down);
 	
     xfpm_settings_tree_view (channel, system_laptop);
     
-    xfpm_settings_general   (channel, user_privilege, can_suspend, can_hibernate,
+    xfpm_settings_general   (channel, auth_hibernate, auth_suspend, can_shutdown, can_suspend, can_hibernate,
 			     has_sleep_button, has_hibernate_button, has_power_button );
 			     
-    xfpm_settings_advanced  (channel, system_laptop, user_privilege, can_suspend, can_hibernate);
+    xfpm_settings_advanced  (channel, system_laptop, auth_hibernate, auth_suspend, can_suspend, can_hibernate);
     
     if ( id != 0 )
     {
@@ -1618,4 +1661,6 @@ xfpm_settings_dialog_new (XfconfChannel *channel, gboolean system_laptop,
     }
     
     gtk_builder_connect_signals (xml, channel);
+    
+    return dialog;
 }
diff --git a/settings/xfpm-settings.h b/settings/xfpm-settings.h
index 2f269d0..b23dd0f 100644
--- a/settings/xfpm-settings.h
+++ b/settings/xfpm-settings.h
@@ -22,9 +22,11 @@
 #define __XFPM_SETTINGS_H
 
 
-void	       xfpm_settings_dialog_new 	(XfconfChannel *channel,
-						 gboolean system_laptop,
-						 gboolean user_privilege,
+GtkWidget      *xfpm_settings_dialog_new 	(XfconfChannel *channel,
+						 gboolean has_battery,
+						 gboolean auth_hibernate,
+						 gboolean auth_suspend,
+						 gboolean can_shutdown,
 					         gboolean can_suspend,
 					         gboolean can_hibernate,
 					         gboolean has_lcd_brightness,
@@ -32,6 +34,8 @@ void	       xfpm_settings_dialog_new 	(XfconfChannel *channel,
 						 gboolean has_sleep_button,
 						 gboolean has_hibernate_button,
 						 gboolean has_power_button,
+						 gboolean devkit_disk,
+						 gboolean can_spin_down,
 						 GdkNativeWindow id);
 
 
diff --git a/src/Makefile.am b/src/Makefile.am
index b102448..44563bd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,60 +1,41 @@
-bin_PROGRAMS = xfce4-power-manager
+bin_PROGRAMS = xfce4-power-manager		\
+	       xfce4-power-information
 
-xfce4_power_manager_SOURCES = 			\
-	xfpm-enum-types.c			\
-	xfpm-enum-types.h			\
-	xfpm-marshal.c				\
-	xfpm-marshal.h				\
-	org.freedesktop.PowerManagement.h	\
-	org.freedesktop.PowerManagement.Inhibit.h\
-	org.freedesktop.PowerManagement.Backlight.h\
-	xfce-power-manager-dbus-server.h	\
-	xfce-power-manager-dbus-client.h	\
+xfce4_power_manager_SOURCES =                   \
+	$(BUILT_SOURCES)			\
+	xfpm-enum.h				\
+	xfpm-enum-glib.h			\
 	xfpm-main.c				\
 	xfpm-manager.c				\
 	xfpm-manager.h				\
-	xfpm-engine.c				\
-	xfpm-engine.h				\
-	xfpm-session.c				\
-	xfpm-session.h				\
-	xfpm-xfconf.c				\
-	xfpm-xfconf.h				\
-	xfpm-supply.c				\
-	xfpm-supply.h				\
-	xfpm-adapter.c				\
-	xfpm-adapter.h				\
+	xfpm-power.c				\
+	xfpm-power.h				\
+	xfpm-power-common.c			\
+	xfpm-power-common.h			\
 	xfpm-battery.c				\
 	xfpm-battery.h				\
-	xfpm-battery-info.c			\
-	xfpm-battery-info.h			\
+	xfpm-xfconf.c				\
+	xfpm-xfconf.h				\
+	xfpm-disks.c				\
+	xfpm-disks.h				\
+	xfpm-console-kit.c			\
+	xfpm-console-kit.h			\
+	egg-idletime.c				\
+	egg-idletime.h				\
+	xfpm-backlight.c			\
+	xfpm-backlight.h			\
 	xfpm-dpms.c				\
 	xfpm-dpms.h				\
-	xfpm-cpu.c				\
-	xfpm-cpu.h				\
 	xfpm-button.c				\
 	xfpm-button.h				\
-	xfpm-button-xf86.c			\
-	xfpm-button-xf86.h			\
-	xfpm-button-hal.c			\
-	xfpm-button-hal.h			\
-	xfpm-backlight.c			\
-	xfpm-backlight.h			\
-	xfpm-brightness-hal.c			\
-	xfpm-brightness-hal.h			\
-	xfpm-brightness-widget.c		\
-	xfpm-brightness-widget.h		\
-	xfpm-inhibit.c				\
-	xfpm-inhibit.h				\
-	xfpm-screen-saver.c			\
-	xfpm-screen-saver.h			\
-	xfpm-dbus-monitor.c			\
-	xfpm-dbus-monitor.h			\
-	xfpm-tray-icon.c			\
-	xfpm-tray-icon.h			\
-	xfpm-shutdown.c				\
-	xfpm-shutdown.h				\
 	xfpm-network-manager.c			\
 	xfpm-network-manager.h			\
+	xfpm-inhibit.c				\
+	xfpm-inhibit.h				\
+	xfpm-notify.c				\
+	xfpm-notify.h				\
+	xfpm-polkit.c				\
+	xfpm-polkit.h				\
 	xfpm-errors.c				\
 	xfpm-errors.h				\
 	xfpm-config.h				\
@@ -62,7 +43,9 @@ xfce4_power_manager_SOURCES = 			\
 	xfpm-debug.c				\
 	xfpm-debug.h				\
 	egg-idletime.c				\
-	egg-idletime.h
+	egg-idletime.h				\
+	gsd-media-keys-window.c			\
+	gsd-media-keys-window.h
 
 
 xfce4_power_manager_CFLAGS =			\
@@ -90,25 +73,76 @@ xfce4_power_manager_LDADD   =			\
 	$(LIBNOTIFY_LIBS)			\
 	$(DPMS_LIBS)		
 
+
+xfce4_power_manager_CFLAGS =                    \
+	-I$(top_srcdir)                         \
+	-I$(top_srcdir)/common                  \
+	-I$(top_srcdir)/libdbus                 \
+	-DLOCALEDIR=\"$(localedir)\"            \
+	-DG_LOG_DOMAIN=\"xfce4-power-manager\"  \
+	-DSYSCONFDIR=\"$(sysconfdir)\"		\
+	$(GOBJECT_CFLAGS)                       \
+	$(GTHREAD_CFLAGS)                       \
+	$(DBUS_GLIB_CFLAGS)                     \
+	$(LIBXFCE4UI_CFLAGS)                    \
+	$(XFCONF_CFLAGS)                        \
+	$(LIBNOTIFY_CFLAGS)                     \
+	$(XRANDR_CFLAGS)			\
+	$(POLKIT_CFLAGS)			\
+	$(DPMS_CFLAGS)                  
+
+xfce4_power_manager_LDADD =                     \
+	$(top_builddir)/common/libxfpmcommon.la \
+	$(top_builddir)/libdbus/libxfpmdbus.la  \
+	$(GOBJECT_LIBS)                         \
+	$(GTHREAD_LIBS)                         \
+	$(DBUS_GLIB_LIBS)                       \
+	$(LIBXFCE4UI_LIBS)                      \
+	$(XFCONF_LIBS)                          \
+	$(LIBNOTIFY_LIBS)                       \
+	$(XRANDR_LIBS)				\
+	$(POLKIT_LIBS)				\
+	$(DPMS_LIBS)
+
+xfce4_power_information_SOURCES =		\
+	xfpm-power-info.c			\
+	xfpm-power-common.c			\
+	xfpm-power-common.h
+
+xfce4_power_information_CFLAGS =		\
+	-I$(top_srcdir)                         \
+	-I$(top_srcdir)/common                  \
+	-I$(top_srcdir)/libdbus                 \
+	-DLOCALEDIR=\"$(localedir)\"            \
+	-DG_LOG_DOMAIN=\"xfce4-power-information\"\
+	$(GOBJECT_CFLAGS)                       \
+	$(DBUS_GLIB_CFLAGS)                     \
+	$(LIBXFCE4UI_CFLAGS)
+
+xfce4_power_information_LDADD =			\
+	$(GOBJECT_LIBS)                         \
+	$(DBUS_GLIB_LIBS)                       \
+	$(LIBXFCE4UI_LIBS)			\
+	$(top_builddir)/libdbus/libxfpmdbus.la
+
 manpagedir = $(mandir)/man1
 
 manpage_DATA = xfce4-power-manager.1
 
-xfpm_glib_headers = 				\
-	$(srcdir)/xfpm-enum-glib.h			
+xfpm_glib_headers =                             \
+        $(srcdir)/xfpm-enum-glib.h
 
-if MAINTAINER_MODE
+BUILT_SOURCES =					\
+	xfce-power-manager-dbus-server.h	\
+	xfce-power-manager-dbus-client.h	\
+	xfpm-enum-types.c                       \
+	xfpm-enum-types.h			\
+	xfpm-marshal.c                          \
+        xfpm-marshal.h				\
+	org.freedesktop.PowerManagement.h       \
+	org.freedesktop.PowerManagement.Inhibit.h
 
-BUILT_SOURCES = 					\
-	xfce-power-manager-dbus-server.h		\
-	xfce-power-manager-dbus-client.h		\
-	org.freedesktop.PowerManagement.h		\
-	org.freedesktop.PowerManagement.Inhibit.h	\
-	org.freedesktop.PowerManagement.Backlight.h	\
-	xfpm-marshal.c					\
-	xfpm-marshal.h					\
-	xfpm-enum-types.c				\
-	xfpm-enum-types.h
+if MAINTAINER_MODE
 
 xfpm-enum-types.h: $(xfpm_glib_headers)
 	( cd $(srcdir) && glib-mkenums \
@@ -146,14 +180,11 @@ xfce-power-manager-dbus-client.h: $(srcdir)/org.xfce.Power.Manager.xml
 	dbus-binding-tool --mode=glib-client --prefix=xfpm_manager $< >$@
 
 org.freedesktop.PowerManagement.h: $(srcdir)/org.freedesktop.PowerManagement.xml
-	dbus-binding-tool --mode=glib-server --prefix=xfpm_engine $< >$@
+	dbus-binding-tool --mode=glib-server --prefix=xfpm_power $< >$@
 
 org.freedesktop.PowerManagement.Inhibit.h: $(srcdir)/org.freedesktop.PowerManagement.Inhibit.xml
 	dbus-binding-tool --mode=glib-server --prefix=xfpm_inhibit $< >$@
 
-org.freedesktop.PowerManagement.Backlight.h: $(srcdir)/org.freedesktop.PowerManagement.Backlight.xml
-	dbus-binding-tool --mode=glib-server --prefix=xfpm_backlight $< >$@
-
 endif
 
 @INTLTOOL_DESKTOP_RULE@
@@ -161,13 +192,11 @@ autostartdir = $(sysconfdir)/xdg/autostart
 autostart_in_files = xfce4-power-manager.desktop.in
 autostart_DATA = $(autostart_in_files:.desktop.in=.desktop)
 
-EXTRA_DIST = 					\
+EXTRA_DIST =                                    \
 	xfpm-marshal.list			\
-	xfpm-enum-glib.h			\
-	$(autostart_in_files)			\
-	$(manpage_DATA)
-
-DISTCLEANFILES =				\
-	$(BUILT_SOURCES)			\
-	xfce4-power-manager.desktop
+        $(autostart_in_files)                   \
+        $(manpage_DATA)
 
+DISTCLEANFILES =                                \
+        $(BUILT_SOURCES)                        \
+        xfce4-power-manager.desktop
\ No newline at end of file
diff --git a/src/gsd-media-keys-window.c b/src/gsd-media-keys-window.c
new file mode 100644
index 0000000..b2664e2
--- /dev/null
+++ b/src/gsd-media-keys-window.c
@@ -0,0 +1,1078 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006-2007 William Jon McCann <mccann at jhu.edu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include "gsd-media-keys-window.h"
+
+#include "data/interfaces/acme_ui.h"
+
+#define DIALOG_TIMEOUT 2000     /* dialog timeout in ms */
+#define DIALOG_FADE_TIMEOUT 1500 /* timeout before fade starts */
+#define FADE_TIMEOUT 10        /* timeout in ms between each frame of the fade */
+
+#define BG_ALPHA 0.75
+#define FG_ALPHA 1.00
+
+#define GSD_MEDIA_KEYS_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_MEDIA_KEYS_WINDOW, GsdMediaKeysWindowPrivate))
+
+struct GsdMediaKeysWindowPrivate
+{
+        guint                    is_composited : 1;
+        guint                    hide_timeout_id;
+        guint                    fade_timeout_id;
+        double                   fade_out_alpha;
+        GsdMediaKeysWindowAction action;
+        char                    *icon_name;
+        gboolean                 show_level;
+
+        guint                    volume_muted : 1;
+        int                      volume_level;
+
+        GtkImage                *image;
+        GtkWidget               *progress;
+};
+
+G_DEFINE_TYPE (GsdMediaKeysWindow, gsd_media_keys_window, GTK_TYPE_WINDOW)
+
+static gboolean
+fade_timeout (GsdMediaKeysWindow *window)
+{
+        if (window->priv->fade_out_alpha <= 0.0) {
+                gtk_widget_hide (GTK_WIDGET (window));
+
+                /* Reset it for the next time */
+                window->priv->fade_out_alpha = 1.0;
+                window->priv->fade_timeout_id = 0;
+
+                return FALSE;
+        } else {
+                GdkRectangle rect;
+                GtkWidget *win = GTK_WIDGET (window);
+                GtkAllocation allocation;
+
+                window->priv->fade_out_alpha -= 0.10;
+
+                rect.x = 0;
+                rect.y = 0;
+                gtk_widget_get_allocation (win, &allocation);
+                rect.width = allocation.width;
+                rect.height = allocation.height;
+
+                gtk_widget_realize (win);
+                gdk_window_invalidate_rect (gtk_widget_get_window (win), &rect, FALSE);
+        }
+
+        return TRUE;
+}
+
+static gboolean
+hide_timeout (GsdMediaKeysWindow *window)
+{
+        if (window->priv->is_composited) {
+                window->priv->hide_timeout_id = 0;
+                window->priv->fade_timeout_id = g_timeout_add (FADE_TIMEOUT,
+                                                               (GSourceFunc) fade_timeout,
+                                                               window);
+        } else {
+                gtk_widget_hide (GTK_WIDGET (window));
+        }
+
+        return FALSE;
+}
+
+static void
+remove_hide_timeout (GsdMediaKeysWindow *window)
+{
+        if (window->priv->hide_timeout_id != 0) {
+                g_source_remove (window->priv->hide_timeout_id);
+                window->priv->hide_timeout_id = 0;
+        }
+
+        if (window->priv->fade_timeout_id != 0) {
+                g_source_remove (window->priv->fade_timeout_id);
+                window->priv->fade_timeout_id = 0;
+                window->priv->fade_out_alpha = 1.0;
+        }
+}
+
+static void
+add_hide_timeout (GsdMediaKeysWindow *window)
+{
+        int timeout;
+
+        if (window->priv->is_composited) {
+                timeout = DIALOG_FADE_TIMEOUT;
+        } else {
+                timeout = DIALOG_TIMEOUT;
+        }
+        window->priv->hide_timeout_id = g_timeout_add (timeout,
+                                                       (GSourceFunc) hide_timeout,
+                                                       window);
+}
+
+static void
+update_window (GsdMediaKeysWindow *window)
+{
+        remove_hide_timeout (window);
+        add_hide_timeout (window);
+
+        if (window->priv->is_composited) {
+                gtk_widget_queue_draw (GTK_WIDGET (window));
+        }
+}
+
+static void
+volume_controls_set_visible (GsdMediaKeysWindow *window,
+                             gboolean            visible)
+{
+        if (window->priv->progress == NULL)
+                return;
+
+        if (visible) {
+                gtk_widget_show (window->priv->progress);
+        } else {
+                gtk_widget_hide (window->priv->progress);
+        }
+}
+
+static void
+window_set_icon_name (GsdMediaKeysWindow *window,
+                      const char         *name)
+{
+        if (window->priv->image == NULL)
+                return;
+
+        gtk_image_set_from_icon_name (window->priv->image,
+                                      name, GTK_ICON_SIZE_DIALOG);
+}
+
+static void
+action_changed (GsdMediaKeysWindow *window)
+{
+        if (! window->priv->is_composited) {
+                switch (window->priv->action) {
+                case GSD_MEDIA_KEYS_WINDOW_ACTION_VOLUME:
+                        volume_controls_set_visible (window, TRUE);
+
+                        if (window->priv->volume_muted) {
+                                window_set_icon_name (window, "audio-volume-muted");
+                        } else {
+                                window_set_icon_name (window, "audio-volume-high");
+                        }
+
+                        break;
+                case GSD_MEDIA_KEYS_WINDOW_ACTION_CUSTOM:
+                        volume_controls_set_visible (window, window->priv->show_level);
+                        window_set_icon_name (window, window->priv->icon_name);
+                        break;
+                default:
+                        g_assert_not_reached ();
+                        break;
+                }
+        }
+
+        update_window (window);
+}
+
+static void
+volume_level_changed (GsdMediaKeysWindow *window)
+{
+        update_window (window);
+
+        if (!window->priv->is_composited && window->priv->progress != NULL) {
+                double fraction;
+
+                fraction = (double) window->priv->volume_level / 100.0;
+
+                gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (window->priv->progress),
+                                               fraction);
+        }
+}
+
+static void
+volume_muted_changed (GsdMediaKeysWindow *window)
+{
+        update_window (window);
+
+        if (! window->priv->is_composited) {
+                if (window->priv->volume_muted) {
+                        window_set_icon_name (window, "audio-volume-muted");
+                } else {
+                        window_set_icon_name (window, "audio-volume-high");
+                }
+        }
+}
+
+void
+gsd_media_keys_window_set_action (GsdMediaKeysWindow      *window,
+                                  GsdMediaKeysWindowAction action)
+{
+        g_return_if_fail (GSD_IS_MEDIA_KEYS_WINDOW (window));
+        g_return_if_fail (action == GSD_MEDIA_KEYS_WINDOW_ACTION_VOLUME);
+
+        if (window->priv->action != action) {
+                window->priv->action = action;
+                action_changed (window);
+        } else {
+                update_window (window);
+        }
+}
+
+void
+gsd_media_keys_window_set_action_custom (GsdMediaKeysWindow      *window,
+                                         const char              *icon_name,
+                                         gboolean                 show_level)
+{
+        g_return_if_fail (GSD_IS_MEDIA_KEYS_WINDOW (window));
+        g_return_if_fail (icon_name != NULL);
+
+        if (window->priv->action != GSD_MEDIA_KEYS_WINDOW_ACTION_CUSTOM ||
+            g_strcmp0 (window->priv->icon_name, icon_name) != 0 ||
+            window->priv->show_level != show_level) {
+                window->priv->action = GSD_MEDIA_KEYS_WINDOW_ACTION_CUSTOM;
+                g_free (window->priv->icon_name);
+                window->priv->icon_name = g_strdup (icon_name);
+                window->priv->show_level = show_level;
+                action_changed (window);
+        } else {
+                update_window (window);
+        }
+}
+
+void
+gsd_media_keys_window_set_volume_muted (GsdMediaKeysWindow *window,
+                                        gboolean            muted)
+{
+        g_return_if_fail (GSD_IS_MEDIA_KEYS_WINDOW (window));
+
+        if (window->priv->volume_muted != muted) {
+                window->priv->volume_muted = muted;
+                volume_muted_changed (window);
+        }
+}
+
+void
+gsd_media_keys_window_set_volume_level (GsdMediaKeysWindow *window,
+                                        int                 level)
+{
+        g_return_if_fail (GSD_IS_MEDIA_KEYS_WINDOW (window));
+
+        if (window->priv->volume_level != level) {
+                window->priv->volume_level = level;
+                volume_level_changed (window);
+        }
+}
+
+static void
+rounded_rectangle (cairo_t* cr,
+                   gdouble  aspect,
+                   gdouble  x,
+                   gdouble  y,
+                   gdouble  corner_radius,
+                   gdouble  width,
+                   gdouble  height)
+{
+        gdouble radius = corner_radius / aspect;
+
+        cairo_move_to (cr, x + radius, y);
+
+        cairo_line_to (cr,
+                       x + width - radius,
+                       y);
+        cairo_arc (cr,
+                   x + width - radius,
+                   y + radius,
+                   radius,
+                   -90.0f * G_PI / 180.0f,
+                   0.0f * G_PI / 180.0f);
+        cairo_line_to (cr,
+                       x + width,
+                       y + height - radius);
+        cairo_arc (cr,
+                   x + width - radius,
+                   y + height - radius,
+                   radius,
+                   0.0f * G_PI / 180.0f,
+                   90.0f * G_PI / 180.0f);
+        cairo_line_to (cr,
+                       x + radius,
+                       y + height);
+        cairo_arc (cr,
+                   x + radius,
+                   y + height - radius,
+                   radius,
+                   90.0f * G_PI / 180.0f,
+                   180.0f * G_PI / 180.0f);
+        cairo_line_to (cr,
+                       x,
+                       y + radius);
+        cairo_arc (cr,
+                   x + radius,
+                   y + radius,
+                   radius,
+                   180.0f * G_PI / 180.0f,
+                   270.0f * G_PI / 180.0f);
+        cairo_close_path (cr);
+}
+
+static GdkPixbuf *
+load_pixbuf (GsdMediaKeysWindow *window,
+             const char         *name,
+             int                 icon_size)
+{
+        GtkIconTheme *theme;
+        GdkPixbuf    *pixbuf;
+
+        if (window != NULL && gtk_widget_has_screen (GTK_WIDGET (window))) {
+                theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window)));
+        } else {
+                theme = gtk_icon_theme_get_default ();
+        }
+
+        pixbuf = gtk_icon_theme_load_icon (theme,
+                                           name,
+                                           icon_size,
+                                           GTK_ICON_LOOKUP_FORCE_SVG,
+                                           NULL);
+
+        /* make sure the pixbuf is close to the requested size
+         * this is necessary because GTK_ICON_LOOKUP_FORCE_SVG
+         * seems to be broken */
+        if (pixbuf != NULL) {
+                int width;
+
+                width = gdk_pixbuf_get_width (pixbuf);
+                if (width < (float)icon_size * 0.75) {
+                        g_object_unref (pixbuf);
+                        pixbuf = NULL;
+                }
+        }
+
+        return pixbuf;
+}
+
+static void
+draw_eject (cairo_t *cr,
+            double   _x0,
+            double   _y0,
+            double   width,
+            double   height)
+{
+        int box_height;
+        int tri_height;
+        int separation;
+
+        box_height = height * 0.2;
+        separation = box_height / 3;
+        tri_height = height - box_height - separation;
+
+        cairo_rectangle (cr, _x0, _y0 + height - box_height, width, box_height);
+
+        cairo_move_to (cr, _x0, _y0 + tri_height);
+        cairo_rel_line_to (cr, width, 0);
+        cairo_rel_line_to (cr, -width / 2, -tri_height);
+        cairo_rel_line_to (cr, -width / 2, tri_height);
+        cairo_close_path (cr);
+        cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, FG_ALPHA);
+        cairo_fill_preserve (cr);
+
+        cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, FG_ALPHA / 2);
+        cairo_set_line_width (cr, 2);
+        cairo_stroke (cr);
+}
+
+static void
+draw_waves (cairo_t *cr,
+            double   cx,
+            double   cy,
+            double   max_radius,
+            int      volume_level)
+{
+        const int n_waves = 3;
+        int last_wave;
+        int i;
+
+        last_wave = n_waves * volume_level / 100;
+
+        for (i = 0; i < n_waves; i++) {
+                double angle1;
+                double angle2;
+                double radius;
+                double alpha;
+
+                angle1 = -M_PI / 4;
+                angle2 = M_PI / 4;
+
+                if (i < last_wave)
+                        alpha = 1.0;
+                else if (i > last_wave)
+                        alpha = 0.1;
+                else alpha = 0.1 + 0.9 * (n_waves * volume_level % 100) / 100.0;
+
+                radius = (i + 1) * (max_radius / n_waves);
+                cairo_arc (cr, cx, cy, radius, angle1, angle2);
+                cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, alpha / 2);
+                cairo_set_line_width (cr, 14);
+                cairo_set_line_cap  (cr, CAIRO_LINE_CAP_ROUND);
+                cairo_stroke_preserve (cr);
+
+                cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, alpha);
+                cairo_set_line_width (cr, 10);
+                cairo_set_line_cap  (cr, CAIRO_LINE_CAP_ROUND);
+                cairo_stroke (cr);
+        }
+}
+
+static void
+draw_cross (cairo_t *cr,
+            double   cx,
+            double   cy,
+            double   size)
+{
+        cairo_move_to (cr, cx, cy - size/2.0);
+        cairo_rel_line_to (cr, size, size);
+
+        cairo_move_to (cr, cx, cy + size/2.0);
+        cairo_rel_line_to (cr, size, -size);
+
+        cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, FG_ALPHA / 2);
+        cairo_set_line_width (cr, 14);
+        cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+        cairo_stroke_preserve (cr);
+
+        cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, FG_ALPHA);
+        cairo_set_line_width (cr, 10);
+        cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+        cairo_stroke (cr);
+}
+
+static void
+draw_speaker (cairo_t *cr,
+              double   cx,
+              double   cy,
+              double   width,
+              double   height)
+{
+        double box_width;
+        double box_height;
+        double _x0;
+        double _y0;
+
+        box_width = width / 3;
+        box_height = height / 3;
+
+        _x0 = cx - (width / 2) + box_width;
+        _y0 = cy - box_height / 2;
+
+        cairo_move_to (cr, _x0, _y0);
+        cairo_rel_line_to (cr, - box_width, 0);
+        cairo_rel_line_to (cr, 0, box_height);
+        cairo_rel_line_to (cr, box_width, 0);
+
+        cairo_line_to (cr, cx + box_width, cy + height / 2);
+        cairo_rel_line_to (cr, 0, -height);
+        cairo_line_to (cr, _x0, _y0);
+        cairo_close_path (cr);
+
+        cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, FG_ALPHA);
+        cairo_fill_preserve (cr);
+
+        cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, FG_ALPHA / 2);
+        cairo_set_line_width (cr, 2);
+        cairo_stroke (cr);
+}
+
+static gboolean
+render_speaker (GsdMediaKeysWindow *window,
+                cairo_t            *cr,
+                double              _x0,
+                double              _y0,
+                double              width,
+                double              height)
+{
+        GdkPixbuf         *pixbuf;
+        int                icon_size;
+        int                n;
+        static const char *icon_names[] = {
+                "audio-volume-muted",
+                "audio-volume-low",
+                "audio-volume-medium",
+                "audio-volume-high",
+                NULL
+        };
+
+        if (window->priv->volume_muted) {
+                n = 0;
+        } else {
+                /* select image */
+                n = 3 * window->priv->volume_level / 100 + 1;
+                if (n < 1) {
+                        n = 1;
+                } else if (n > 3) {
+                        n = 3;
+                }
+        }
+
+        icon_size = (int)width;
+
+        pixbuf = load_pixbuf (window, icon_names[n], icon_size);
+
+        if (pixbuf == NULL) {
+                return FALSE;
+        }
+
+        gdk_cairo_set_source_pixbuf (cr, pixbuf, _x0, _y0);
+        cairo_paint_with_alpha (cr, FG_ALPHA);
+
+        g_object_unref (pixbuf);
+
+        return TRUE;
+}
+
+static void
+color_reverse (const GdkColor *a,
+               GdkColor       *b)
+{
+        gdouble red;
+        gdouble green;
+        gdouble blue;
+        gdouble h;
+        gdouble s;
+        gdouble v;
+
+        red = (gdouble) a->red / 65535.0;
+        green = (gdouble) a->green / 65535.0;
+        blue = (gdouble) a->blue / 65535.0;
+
+        gtk_rgb_to_hsv (red, green, blue, &h, &s, &v);
+
+        v = 0.5 + (0.5 - v);
+        if (v > 1.0)
+                v = 1.0;
+        else if (v < 0.0)
+                v = 0.0;
+
+        gtk_hsv_to_rgb (h, s, v, &red, &green, &blue);
+
+        b->red = red * 65535.0;
+        b->green = green * 65535.0;
+        b->blue = blue * 65535.0;
+}
+
+static void
+draw_volume_boxes (GsdMediaKeysWindow *window,
+                   cairo_t            *cr,
+                   double              percentage,
+                   double              _x0,
+                   double              _y0,
+                   double              width,
+                   double              height)
+{
+        gdouble   x1;
+        GdkColor  color;
+        double    r, g, b;
+        GtkStyle *style;
+
+        _x0 += 0.5;
+        _y0 += 0.5;
+        height = round (height) - 1;
+        width = round (width) - 1;
+        x1 = round ((width - 1) * percentage);
+        style = gtk_widget_get_style (GTK_WIDGET (window));
+
+        /* bar background */
+        color_reverse (&style->dark[GTK_STATE_NORMAL], &color);
+        r = (float)color.red / 65535.0;
+        g = (float)color.green / 65535.0;
+        b = (float)color.blue / 65535.0;
+        rounded_rectangle (cr, 1.0, _x0, _y0, height / 6, width, height);
+        cairo_set_source_rgba (cr, r, g, b, FG_ALPHA / 2);
+        cairo_fill_preserve (cr);
+
+        /* bar border */
+        color_reverse (&style->light[GTK_STATE_NORMAL], &color);
+        r = (float)color.red / 65535.0;
+        g = (float)color.green / 65535.0;
+        b = (float)color.blue / 65535.0;
+        cairo_set_source_rgba (cr, r, g, b, FG_ALPHA / 2);
+        cairo_set_line_width (cr, 1);
+        cairo_stroke (cr);
+
+        /* bar progress */
+        if (percentage < 0.01)
+                return;
+        color = style->bg[GTK_STATE_NORMAL];
+        r = (float)color.red / 65535.0;
+        g = (float)color.green / 65535.0;
+        b = (float)color.blue / 65535.0;
+        rounded_rectangle (cr, 1.0, _x0 + 0.5, _y0 + 0.5, height / 6 - 0.5, x1, height - 1);
+        cairo_set_source_rgba (cr, r, g, b, FG_ALPHA);
+        cairo_fill (cr);
+}
+
+static void
+draw_action_volume (GsdMediaKeysWindow *window,
+                    cairo_t            *cr)
+{
+        int window_width;
+        int window_height;
+        double icon_box_width;
+        double icon_box_height;
+        double icon_box_x0;
+        double icon_box_y0;
+        double volume_box_x0;
+        double volume_box_y0;
+        double volume_box_width;
+        double volume_box_height;
+        gboolean res;
+
+        gtk_window_get_size (GTK_WINDOW (window), &window_width, &window_height);
+
+        icon_box_width = round (window_width * 0.65);
+        icon_box_height = round (window_height * 0.65);
+        volume_box_width = icon_box_width;
+        volume_box_height = round (window_height * 0.05);
+
+        icon_box_x0 = (window_width - icon_box_width) / 2;
+        icon_box_y0 = (window_height - icon_box_height - volume_box_height) / 2;
+        volume_box_x0 = round (icon_box_x0);
+        volume_box_y0 = round (icon_box_height + icon_box_y0);
+
+#if 0
+        g_message ("icon box: w=%f h=%f _x0=%f _y0=%f",
+                   icon_box_width,
+                   icon_box_height,
+                   icon_box_x0,
+                   icon_box_y0);
+        g_message ("volume box: w=%f h=%f _x0=%f _y0=%f",
+                   volume_box_width,
+                   volume_box_height,
+                   volume_box_x0,
+                   volume_box_y0);
+#endif
+
+        res = render_speaker (window,
+                              cr,
+                              icon_box_x0, icon_box_y0,
+                              icon_box_width, icon_box_height);
+        if (! res) {
+                double speaker_width;
+                double speaker_height;
+                double speaker_cx;
+                double speaker_cy;
+
+                speaker_width = icon_box_width * 0.5;
+                speaker_height = icon_box_height * 0.75;
+                speaker_cx = icon_box_x0 + speaker_width / 2;
+                speaker_cy = icon_box_y0 + speaker_height / 2;
+
+#if 0
+                g_message ("speaker box: w=%f h=%f cx=%f cy=%f",
+                           speaker_width,
+                           speaker_height,
+                           speaker_cx,
+                           speaker_cy);
+#endif
+
+                /* draw speaker symbol */
+                draw_speaker (cr, speaker_cx, speaker_cy, speaker_width, speaker_height);
+
+                if (! window->priv->volume_muted) {
+                        /* draw sound waves */
+                        double wave_x0;
+                        double wave_y0;
+                        double wave_radius;
+
+                        wave_x0 = window_width / 2;
+                        wave_y0 = speaker_cy;
+                        wave_radius = icon_box_width / 2;
+
+                        draw_waves (cr, wave_x0, wave_y0, wave_radius, window->priv->volume_level);
+                } else {
+                        /* draw 'mute' cross */
+                        double cross_x0;
+                        double cross_y0;
+                        double cross_size;
+
+                        cross_size = speaker_width * 3 / 4;
+                        cross_x0 = icon_box_x0 + icon_box_width - cross_size;
+                        cross_y0 = speaker_cy;
+
+                        draw_cross (cr, cross_x0, cross_y0, cross_size);
+                }
+        }
+
+        /* draw volume meter */
+        draw_volume_boxes (window,
+                           cr,
+                           (double)window->priv->volume_level / 100.0,
+                           volume_box_x0,
+                           volume_box_y0,
+                           volume_box_width,
+                           volume_box_height);
+}
+
+static gboolean
+render_custom (GsdMediaKeysWindow *window,
+               cairo_t            *cr,
+               double              _x0,
+               double              _y0,
+               double              width,
+               double              height)
+{
+        GdkPixbuf         *pixbuf;
+        int                icon_size;
+
+        icon_size = (int)width;
+
+        pixbuf = load_pixbuf (window, window->priv->icon_name, icon_size);
+
+        if (pixbuf == NULL) {
+                char *name;
+                if (gtk_widget_get_direction (GTK_WIDGET (window)) == GTK_TEXT_DIR_RTL)
+                        name = g_strdup_printf ("%s-rtl", window->priv->icon_name);
+                else
+                        name = g_strdup_printf ("%s-ltr", window->priv->icon_name);
+                pixbuf = load_pixbuf (window, name, icon_size);
+                g_free (name);
+                if (pixbuf == NULL)
+                        return FALSE;
+        }
+
+        gdk_cairo_set_source_pixbuf (cr, pixbuf, _x0, _y0);
+        cairo_paint_with_alpha (cr, FG_ALPHA);
+
+        g_object_unref (pixbuf);
+
+        return TRUE;
+}
+
+static void
+draw_action_custom (GsdMediaKeysWindow *window,
+                    cairo_t            *cr)
+{
+        int window_width;
+        int window_height;
+        double icon_box_width;
+        double icon_box_height;
+        double icon_box_x0;
+        double icon_box_y0;
+        double bright_box_x0;
+        double bright_box_y0;
+        double bright_box_width;
+        double bright_box_height;
+        gboolean res;
+
+        gtk_window_get_size (GTK_WINDOW (window), &window_width, &window_height);
+
+        icon_box_width = round (window_width * 0.65);
+        icon_box_height = round (window_height * 0.65);
+        bright_box_width = round (icon_box_width);
+        bright_box_height = round (window_height * 0.05);
+
+        icon_box_x0 = (window_width - icon_box_width) / 2;
+        icon_box_y0 = (window_height - icon_box_height - bright_box_height) / 2;
+        bright_box_x0 = round (icon_box_x0);
+        bright_box_y0 = round (icon_box_height + icon_box_y0);
+
+#if 0
+        g_message ("icon box: w=%f h=%f _x0=%f _y0=%f",
+                   icon_box_width,
+                   icon_box_height,
+                   icon_box_x0,
+                   icon_box_y0);
+        g_message ("brightness box: w=%f h=%f _x0=%f _y0=%f",
+                   bright_box_width,
+                   bright_box_height,
+                   bright_box_x0,
+                   bright_box_y0);
+#endif
+
+        res = render_custom (window,
+                             cr,
+                             icon_box_x0, icon_box_y0,
+                             icon_box_width, icon_box_height);
+        if (! res && g_strcmp0 (window->priv->icon_name, "media-eject") == 0) {
+                /* draw eject symbol */
+                draw_eject (cr,
+                            icon_box_x0, icon_box_y0,
+                            icon_box_width, icon_box_height);
+        }
+
+        if (window->priv->show_level != FALSE) {
+                /* draw volume meter */
+                draw_volume_boxes (window,
+                                   cr,
+                                   (double)window->priv->volume_level / 100.0,
+                                   bright_box_x0,
+                                   bright_box_y0,
+                                   bright_box_width,
+                                   bright_box_height);
+        }
+}
+
+static void
+draw_action (GsdMediaKeysWindow *window,
+             cairo_t            *cr)
+{
+        switch (window->priv->action) {
+        case GSD_MEDIA_KEYS_WINDOW_ACTION_VOLUME:
+                draw_action_volume (window, cr);
+                break;
+        case GSD_MEDIA_KEYS_WINDOW_ACTION_CUSTOM:
+                draw_action_custom (window, cr);
+                break;
+        default:
+                break;
+        }
+}
+
+static gboolean
+on_expose_event (GtkWidget          *widget,
+                 GdkEventExpose     *event,
+                 GsdMediaKeysWindow *window)
+{
+        cairo_t         *context;
+        cairo_t         *cr;
+        cairo_surface_t *surface;
+        int              width;
+        int              height;
+        GtkStyle        *style;
+        GdkColor         color;
+        double           r, g, b;
+
+        context = gdk_cairo_create (gtk_widget_get_window (widget));
+
+        style = gtk_widget_get_style (widget);
+        cairo_set_operator (context, CAIRO_OPERATOR_SOURCE);
+        gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
+
+        surface = cairo_surface_create_similar (cairo_get_target (context),
+                                                CAIRO_CONTENT_COLOR_ALPHA,
+                                                width,
+                                                height);
+
+        if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS) {
+                goto done;
+        }
+
+        cr = cairo_create (surface);
+        if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
+                goto done;
+        }
+        cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0);
+        cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+        cairo_paint (cr);
+
+        /* draw a box */
+        rounded_rectangle (cr, 1.0, 0.5, 0.5, height / 10, width-1, height-1);
+        color_reverse (&style->bg[GTK_STATE_NORMAL], &color);
+        r = (float)color.red / 65535.0;
+        g = (float)color.green / 65535.0;
+        b = (float)color.blue / 65535.0;
+        cairo_set_source_rgba (cr, r, g, b, BG_ALPHA);
+        cairo_fill_preserve (cr);
+
+        color_reverse (&style->text_aa[GTK_STATE_NORMAL], &color);
+        r = (float)color.red / 65535.0;
+        g = (float)color.green / 65535.0;
+        b = (float)color.blue / 65535.0;
+        cairo_set_source_rgba (cr, r, g, b, BG_ALPHA / 2);
+        cairo_set_line_width (cr, 1);
+        cairo_stroke (cr);
+
+        /* draw action */
+        draw_action (window, cr);
+
+        cairo_destroy (cr);
+
+        /* Make sure we have a transparent background */
+        cairo_rectangle (context, 0, 0, width, height);
+        cairo_set_source_rgba (context, 0.0, 0.0, 0.0, 0.0);
+        cairo_fill (context);
+
+        cairo_set_source_surface (context, surface, 0, 0);
+        cairo_paint_with_alpha (context, window->priv->fade_out_alpha);
+
+ done:
+        if (surface != NULL) {
+                cairo_surface_destroy (surface);
+        }
+        cairo_destroy (context);
+
+        return FALSE;
+}
+
+static void
+gsd_media_keys_window_real_show (GtkWidget *widget)
+{
+        GsdMediaKeysWindow *window;
+
+        if (GTK_WIDGET_CLASS (gsd_media_keys_window_parent_class)->show) {
+                GTK_WIDGET_CLASS (gsd_media_keys_window_parent_class)->show (widget);
+        }
+
+        window = GSD_MEDIA_KEYS_WINDOW (widget);
+        remove_hide_timeout (window);
+        add_hide_timeout (window);
+}
+
+static void
+gsd_media_keys_window_real_hide (GtkWidget *widget)
+{
+        GsdMediaKeysWindow *window;
+
+        if (GTK_WIDGET_CLASS (gsd_media_keys_window_parent_class)->hide) {
+                GTK_WIDGET_CLASS (gsd_media_keys_window_parent_class)->hide (widget);
+        }
+
+        window = GSD_MEDIA_KEYS_WINDOW (widget);
+        remove_hide_timeout (window);
+}
+
+static void
+gsd_media_keys_window_real_realize (GtkWidget *widget)
+{
+        GdkColormap *colormap;
+        GtkAllocation allocation;
+        GdkBitmap *mask;
+        cairo_t *cr;
+
+        colormap = gdk_screen_get_rgba_colormap (gtk_widget_get_screen (widget));
+
+        if (colormap != NULL) {
+                gtk_widget_set_colormap (widget, colormap);
+        }
+
+        if (GTK_WIDGET_CLASS (gsd_media_keys_window_parent_class)->realize) {
+                GTK_WIDGET_CLASS (gsd_media_keys_window_parent_class)->realize (widget);
+        }
+
+        gtk_widget_get_allocation (widget, &allocation);
+        mask = gdk_pixmap_new (gtk_widget_get_window (widget),
+                               allocation.width,
+                               allocation.height,
+                               1);
+        cr = gdk_cairo_create (mask);
+
+        cairo_set_source_rgba (cr, 1., 1., 1., 0.);
+        cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+        cairo_paint (cr);
+
+        /* make the whole window ignore events */
+        gdk_window_input_shape_combine_mask (gtk_widget_get_window (widget), mask, 0, 0);
+        g_object_unref (mask);
+        cairo_destroy (cr);
+}
+
+static void
+gsd_media_keys_window_class_init (GsdMediaKeysWindowClass *klass)
+{
+        GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+        widget_class->show = gsd_media_keys_window_real_show;
+        widget_class->hide = gsd_media_keys_window_real_hide;
+        widget_class->realize = gsd_media_keys_window_real_realize;
+
+        g_type_class_add_private (klass, sizeof (GsdMediaKeysWindowPrivate));
+}
+
+gboolean
+gsd_media_keys_window_is_valid (GsdMediaKeysWindow *window)
+{
+        GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (window));
+        return gdk_screen_is_composited (screen) == window->priv->is_composited;
+}
+
+static void
+gsd_media_keys_window_init (GsdMediaKeysWindow *window)
+{
+        GdkScreen *screen;
+
+        window->priv = GSD_MEDIA_KEYS_WINDOW_GET_PRIVATE (window);
+
+        screen = gtk_widget_get_screen (GTK_WIDGET (window));
+
+        window->priv->is_composited = gdk_screen_is_composited (screen);
+
+        if (window->priv->is_composited) {
+                gdouble scalew, scaleh, scale;
+                gint size;
+
+                gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
+                gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
+
+                /* assume 130x130 on a 640x480 display and scale from there */
+                scalew = gdk_screen_get_width (screen) / 640.0;
+                scaleh = gdk_screen_get_height (screen) / 480.0;
+                scale = MIN (scalew, scaleh);
+                size = 130 * MAX (1, scale);
+
+                gtk_window_set_default_size (GTK_WINDOW (window), size, size);
+                g_signal_connect (window, "expose-event", G_CALLBACK (on_expose_event), window);
+
+                window->priv->fade_out_alpha = 1.0;
+        } else {
+                GtkBuilder *builder;
+                const gchar *objects[] = {"acme_frame", NULL};
+                GtkWidget *frame;
+
+                builder = gtk_builder_new ();
+		gtk_builder_add_objects_from_string (builder, acme_ui, acme_ui_length, (char **)objects, NULL);
+
+                window->priv->image = GTK_IMAGE (gtk_builder_get_object (builder, "acme_image"));
+                window->priv->progress = GTK_WIDGET (gtk_builder_get_object (builder, "acme_volume_progressbar"));
+                frame = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                            "acme_frame"));
+
+                if (frame != NULL) {
+                        gtk_container_add (GTK_CONTAINER (window), frame);
+                        gtk_widget_show_all (frame);
+                }
+
+                /* The builder needs to stay alive until the window
+                   takes ownership of the frame (and its children)  */
+                g_object_unref (builder);
+        }
+}
+
+GtkWidget *
+gsd_media_keys_window_new (void)
+{
+        GObject *object;
+
+        object = g_object_new (GSD_TYPE_MEDIA_KEYS_WINDOW,
+                               "type", GTK_WINDOW_POPUP,
+                               "type-hint", GDK_WINDOW_TYPE_HINT_NOTIFICATION,
+                               "skip-taskbar-hint", TRUE,
+                               "skip-pager-hint", TRUE,
+                               "focus-on-map", FALSE,
+                               NULL);
+
+        return GTK_WIDGET (object);
+}
diff --git a/src/gsd-media-keys-window.h b/src/gsd-media-keys-window.h
new file mode 100644
index 0000000..9c74bf5
--- /dev/null
+++ b/src/gsd-media-keys-window.h
@@ -0,0 +1,71 @@
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*-
+ *
+ * Copyright (C) 2006 William Jon McCann <mccann at jhu.edu>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef GSD_MEDIA_KEYS_WINDOW_H
+#define GSD_MEDIA_KEYS_WINDOW_H
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GSD_TYPE_MEDIA_KEYS_WINDOW            (gsd_media_keys_window_get_type ())
+#define GSD_MEDIA_KEYS_WINDOW(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj),  GSD_TYPE_MEDIA_KEYS_WINDOW, GsdMediaKeysWindow))
+#define GSD_MEDIA_KEYS_WINDOW_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),   GSD_TYPE_MEDIA_KEYS_WINDOW, GsdMediaKeysWindowClass))
+#define GSD_IS_MEDIA_KEYS_WINDOW(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj),  GSD_TYPE_MEDIA_KEYS_WINDOW))
+#define GSD_IS_MEDIA_KEYS_WINDOW_CLASS(klass) (G_TYPE_INSTANCE_GET_CLASS ((klass), GSD_TYPE_MEDIA_KEYS_WINDOW))
+
+typedef struct GsdMediaKeysWindow                   GsdMediaKeysWindow;
+typedef struct GsdMediaKeysWindowClass              GsdMediaKeysWindowClass;
+typedef struct GsdMediaKeysWindowPrivate            GsdMediaKeysWindowPrivate;
+
+struct GsdMediaKeysWindow {
+        GtkWindow                   parent;
+
+        GsdMediaKeysWindowPrivate  *priv;
+};
+
+struct GsdMediaKeysWindowClass {
+        GtkWindowClass parent_class;
+};
+
+typedef enum {
+        GSD_MEDIA_KEYS_WINDOW_ACTION_VOLUME,
+        GSD_MEDIA_KEYS_WINDOW_ACTION_CUSTOM
+} GsdMediaKeysWindowAction;
+
+GType                 gsd_media_keys_window_get_type          (void);
+
+GtkWidget *           gsd_media_keys_window_new               (void);
+void                  gsd_media_keys_window_set_action        (GsdMediaKeysWindow      *window,
+                                                               GsdMediaKeysWindowAction action);
+void                  gsd_media_keys_window_set_action_custom (GsdMediaKeysWindow      *window,
+                                                               const char              *icon_name,
+                                                               gboolean                 show_level);
+void                  gsd_media_keys_window_set_volume_muted  (GsdMediaKeysWindow      *window,
+                                                               gboolean                 muted);
+void                  gsd_media_keys_window_set_volume_level  (GsdMediaKeysWindow      *window,
+                                                               int                      level);
+gboolean              gsd_media_keys_window_is_valid          (GsdMediaKeysWindow      *window);
+
+G_END_DECLS
+
+#endif
diff --git a/src/org.freedesktop.PowerManagement.Backlight.xml b/src/org.freedesktop.PowerManagement.Backlight.xml
deleted file mode 100644
index 8d96094..0000000
--- a/src/org.freedesktop.PowerManagement.Backlight.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<node name="/">
-    <interface name="org.freedesktop.PowerManagement.Backlight">
-        <annotation name="org.freedesktop.DBus.GLib.CSymbol"
-                    value="xfpm_backlight_dbus"/>
-        <annotation name="org.freedesktop.DBus.GLib.ClientCSymbol"
-                    value="xfpm_backlight_dbus_client"/>
-
-    <method name="UpdateBrightness">
-      <arg type="u" name="level" direction="in"/>
-    </method>
-
-    </interface>
-</node>
diff --git a/src/org.freedesktop.PowerManagement.xml b/src/org.freedesktop.PowerManagement.xml
index ad11a85..ae00d7a 100644
--- a/src/org.freedesktop.PowerManagement.xml
+++ b/src/org.freedesktop.PowerManagement.xml
@@ -3,9 +3,9 @@
 <node name="/org/freedesktop/PowerManagement">
     <interface name="org.freedesktop.PowerManagement">
         <annotation name="org.freedesktop.DBus.GLib.CSymbol"
-                    value="xfpm_engine_dbus"/>
+                    value="xfpm_power_dbus"/>
         <annotation name="org.freedesktop.DBus.GLib.ClientCSymbol"
-                    value="xfpm_engine_dbus_client"/>   
+                    value="xfpm_power_dbus_client"/>   
 
     <method name="Shutdown">
     </method>
diff --git a/src/xfpm-adapter.c b/src/xfpm-adapter.c
deleted file mode 100644
index c983aff..0000000
--- a/src/xfpm-adapter.c
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-
-#include <glib.h>
-
-#include <libxfce4util/libxfce4util.h>
-
-#include "libxfpm/hal-manager.h"
-#include "libxfpm/hal-device.h"
-#include "libxfpm/xfpm-string.h"
-
-#include "xfpm-adapter.h"
-
-static void xfpm_adapter_finalize   (GObject *object);
-
-#define XFPM_ADAPTER_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_ADAPTER, XfpmAdapterPrivate))
-
-struct XfpmAdapterPrivate
-{
-    HalDevice 	 *device;
-    gboolean      present;
-    gboolean      hw_found;
-};
-
-enum
-{
-    ADAPTER_CHANGED,
-    LAST_SIGNAL
-};
-
-static guint signals [LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(XfpmAdapter, xfpm_adapter, G_TYPE_OBJECT)
-
-static void
-xfpm_adapter_device_changed_cb (HalDevice *device, const gchar *udi, const gchar *key,
-			        gboolean is_added, gboolean is_removed, XfpmAdapter *adapter)
-{
-    //FIXME React correctly is device is removed
-    if ( xfpm_strequal(key, "ac_adapter.present") )
-    {
-	adapter->priv->present = hal_device_get_property_bool (adapter->priv->device, "ac_adapter.present");
-	g_signal_emit (G_OBJECT(adapter), signals[ADAPTER_CHANGED], 0, adapter->priv->present);
-    }
-}
-
-static void
-xfpm_adapter_set_device (XfpmAdapter *adapter, HalManager *manager)
-{
-    gchar **udi;
-    
-    manager = hal_manager_new ();
-    
-    udi = hal_manager_find_device_by_capability (manager, "ac_adapter");
-    
-    if (udi == NULL || udi[0] == NULL)//FIXME Adapter should be present on laptops
-	goto out;
-	
-    TRACE("Found AC Adapter with udi=%s\n", udi[0]);
-
-    adapter->priv->hw_found = TRUE;
-    
-    adapter->priv->device = hal_device_new ();
-    hal_device_set_udi (adapter->priv->device, udi[0]);
-    
-    hal_manager_free_string_array (udi);
-    
-    adapter->priv->present = hal_device_get_property_bool (adapter->priv->device, "ac_adapter.present");
-    
-    g_signal_connect (adapter->priv->device, "device-changed",
-		      G_CALLBACK(xfpm_adapter_device_changed_cb), adapter);
-		      
-    hal_device_watch (adapter->priv->device);
-out:
-    ;
-}
-
-static void
-xfpm_adapter_class_init(XfpmAdapterClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-    signals[ADAPTER_CHANGED] = 
-    	g_signal_new("adapter-changed",
-                      XFPM_TYPE_ADAPTER,
-                      G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET(XfpmAdapterClass, adapter_changed),
-                      NULL, NULL,
-                      g_cclosure_marshal_VOID__BOOLEAN,
-                      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
-		      
-    object_class->finalize = xfpm_adapter_finalize;
-
-    g_type_class_add_private (klass, sizeof(XfpmAdapterPrivate));
-}
-
-static void
-xfpm_adapter_init(XfpmAdapter *adapter)
-{
-    HalManager *manager;
-    
-    adapter->priv = XFPM_ADAPTER_GET_PRIVATE(adapter);
-    
-    adapter->priv->device   = NULL;
-    adapter->priv->present  = TRUE;
-    adapter->priv->hw_found = FALSE;
-    
-    manager = hal_manager_new ();
-        
-    if ( hal_manager_get_is_laptop (manager) )
-    {
-	xfpm_adapter_set_device (adapter, manager);
-	TRACE("System is identified as a laptop");
-    }
-    else
-    {
-	TRACE("System is not identified as a laptop");
-    }
-    
-    g_object_unref (manager);
-}
-
-static void
-xfpm_adapter_finalize(GObject *object)
-{
-    XfpmAdapter *adapter;
-
-    adapter = XFPM_ADAPTER(object);
-    
-    if ( adapter->priv->device )
-	g_object_unref (adapter->priv->device);
-    
-    G_OBJECT_CLASS(xfpm_adapter_parent_class)->finalize(object);
-}
-
-XfpmAdapter *
-xfpm_adapter_new (void)
-{
-    static gpointer xfpm_adapter_object = NULL;
-    
-    if ( G_LIKELY (xfpm_adapter_object != NULL) )
-    {
-	g_object_ref (xfpm_adapter_object);
-    }
-    else
-    {
-	xfpm_adapter_object = g_object_new (XFPM_TYPE_ADAPTER, NULL);
-	g_object_add_weak_pointer (xfpm_adapter_object, &xfpm_adapter_object);
-    }
-    return XFPM_ADAPTER (xfpm_adapter_object);
-}
-
-gboolean xfpm_adapter_get_present (XfpmAdapter *adapter)
-{
-    g_return_val_if_fail (XFPM_IS_ADAPTER(adapter), FALSE);
-    
-    return adapter->priv->present;
-}
-
-gboolean xfpm_adapter_has_hw (XfpmAdapter *adapter)
-{
-    g_return_val_if_fail (XFPM_IS_ADAPTER(adapter), FALSE);
-    
-    return adapter->priv->hw_found;
-}
-
-void xfpm_adapter_reload (XfpmAdapter *adapter)
-{
-    HalManager *manager;
-    
-    g_return_if_fail (XFPM_IS_ADAPTER (adapter));
-    
-    g_object_unref (adapter->priv->device);
-    
-    manager = hal_manager_new ();
-    xfpm_adapter_set_device (adapter, manager);
-    g_object_unref (manager);
-}
diff --git a/src/xfpm-adapter.h b/src/xfpm-adapter.h
deleted file mode 100644
index 838ae13..0000000
--- a/src/xfpm-adapter.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __XFPM_ADAPTER_H
-#define __XFPM_ADAPTER_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_ADAPTER        (xfpm_adapter_get_type () )
-#define XFPM_ADAPTER(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_ADAPTER, XfpmAdapter))
-#define XFPM_IS_ADAPTER(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_ADAPTER))
-
-typedef struct XfpmAdapterPrivate XfpmAdapterPrivate;
-
-typedef struct
-{
-    GObject		  parent;
-    XfpmAdapterPrivate	 *priv;
-    
-} XfpmAdapter;
-
-typedef struct
-{
-    GObjectClass 	  parent_class;
-    
-    void                 (*adapter_changed)    	      (XfpmAdapter *adapter,
-    						       gboolean present);
-    
-} XfpmAdapterClass;
-
-GType        	 	 xfpm_adapter_get_type        (void) G_GNUC_CONST;
-XfpmAdapter      	*xfpm_adapter_new             (void);
-
-gboolean 	  	 xfpm_adapter_get_present     (XfpmAdapter *adapter) G_GNUC_PURE;
-
-gboolean 		 xfpm_adapter_has_hw 	      (XfpmAdapter *adapter) G_GNUC_PURE;
-
-void                     xfpm_adapter_reload          (XfpmAdapter *adapter);
-
-G_END_DECLS
-
-#endif /* __XFPM_ADAPTER_H */
diff --git a/src/xfpm-backlight.c b/src/xfpm-backlight.c
index e138db0..bdf6d22 100644
--- a/src/xfpm-backlight.c
+++ b/src/xfpm-backlight.c
@@ -26,168 +26,452 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <math.h>
+
+#include <gtk/gtk.h>
 #include <libxfce4util/libxfce4util.h>
 
 #include "xfpm-backlight.h"
-#include "xfpm-brightness-hal.h"
-#include "xfpm-brightness-widget.h"
+#include "egg-idletime.h"
+#include "xfpm-notify.h"
+#include "xfpm-xfconf.h"
+#include "xfpm-power.h"
+#include "xfpm-config.h"
+#include "xfpm-button.h"
+#include "xfpm-brightness.h"
+#include "xfpm-debug.h"
+#include "xfpm-icons.h"
+
+#include "gsd-media-keys-window.h"
+
+static void xfpm_backlight_finalize     (GObject *object);
 
-static void xfpm_backlight_finalize   (GObject *object);
+static void xfpm_backlight_create_popup (XfpmBacklight *backlight);
 
-static void xfpm_backlight_dbus_class_init (XfpmBacklightClass *klass);
-static void xfpm_backlight_dbus_init       (XfpmBacklight *bk);
+#define ALARM_DISABLED 9
+#define BRIGHTNESS_POPUP_SIZE	180
 
 #define XFPM_BACKLIGHT_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_BACKLIGHT, XfpmBacklightPrivate))
+(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_BACKLIGHT, XfpmBacklightPrivate))
 
 struct XfpmBacklightPrivate
 {
-    XfpmBrightnessHal    *br;
-    XfpmBrightnessWidget *widget;
+    XfpmBrightness *brightness;
+    XfpmPower      *power;
+    EggIdletime    *idle;
+    XfpmXfconf     *conf;
+    XfpmButton     *button;
+    XfpmNotify     *notify;
+    
+    GtkWidget	   *osd;
+    NotifyNotification *n;
+    
     
-    gboolean has_hw;
+    gulong	    destroy_id;
+    
+    gboolean	    has_hw;
+    gboolean	    on_battery;
+    
+    gint            last_level;
+    gint 	    max_level;
+    
+    gboolean        dimmed;
+    gboolean	    block;
+#ifdef WITH_HAL
+    gboolean	    brightness_in_hw;
+#endif
 };
 
-G_DEFINE_TYPE(XfpmBacklight, xfpm_backlight, G_TYPE_OBJECT)
+G_DEFINE_TYPE (XfpmBacklight, xfpm_backlight, G_TYPE_OBJECT)
 
 static void
-xfpm_backlight_brightness_up (XfpmBrightnessHal *brg, guint level, XfpmBacklight *bk)
+xfpm_backlight_dim_brightness (XfpmBacklight *backlight)
 {
-    xfpm_brightness_widget_set_level (bk->priv->widget, level);
+    gboolean ret;
+    
+    ret = xfpm_brightness_get_level (backlight->priv->brightness, &backlight->priv->last_level);
+    
+    if ( !ret )
+    {
+	g_warning ("Unable to get current brightness level");
+	return;
+    }
+    XFPM_DEBUG ("Current brightness level before dimming : %u", backlight->priv->last_level);
+    
+    backlight->priv->dimmed = xfpm_brightness_dim_down (backlight->priv->brightness);
+}
+
+static gboolean
+xfpm_backlight_destroy_popup (gpointer data)
+{
+    XfpmBacklight *backlight;
+    
+    backlight = XFPM_BACKLIGHT (data);
+    
+    if ( backlight->priv->osd )
+    {
+	gtk_widget_destroy (backlight->priv->osd);
+	backlight->priv->osd = NULL;
+    }
+    
+    if ( backlight->priv->n )
+    {
+	g_object_unref (backlight->priv->n);
+	backlight->priv->n = NULL;
+    }
+    
+    return FALSE;
 }
 
 static void
-xfpm_backlight_brightness_down (XfpmBrightnessHal *brg, guint level, XfpmBacklight *bk)
+xfpm_backlight_composited_changed_cb (XfpmBacklight *backlight)
 {
-    xfpm_brightness_widget_set_level (bk->priv->widget, level);
+    xfpm_backlight_destroy_popup (backlight);
+    xfpm_backlight_create_popup (backlight);
 }
 
 static void
-xfpm_backlight_get_device (XfpmBacklight *bk)
+xfpm_backlight_show_notification (XfpmBacklight *backlight, gfloat value)
 {
-    guint max_level;
-    bk->priv->br     = xfpm_brightness_hal_new ();
-    bk->priv->has_hw = xfpm_brightness_hal_has_hw (bk->priv->br);
+    gint i;
     
-    if ( bk->priv->has_hw == FALSE )
-	g_object_unref (bk->priv->br);
-    else
+    static const char *display_icon_name[] = 
     {
-	bk->priv->widget = xfpm_brightness_widget_new ();
-	g_signal_connect (G_OBJECT(bk->priv->br), "brigthness-up",
-			  G_CALLBACK (xfpm_backlight_brightness_up), bk);
-			  
-	g_signal_connect (G_OBJECT(bk->priv->br), "brigthness-down",
-			  G_CALLBACK (xfpm_backlight_brightness_down), bk);
-	
-	max_level = xfpm_brightness_hal_get_max_level (bk->priv->br);
-	xfpm_brightness_widget_set_max_level (bk->priv->widget,
-					      max_level);
+	"notification-display-brightness-off",
+	"notification-display-brightness-low",
+	"notification-display-brightness-medium",
+	"notification-display-brightness-high",
+	"notification-display-brightness-full",
+	NULL
+    };
+    
+    if ( backlight->priv->n == NULL )
+    {
+	backlight->priv->n = xfpm_notify_new_notification (backlight->priv->notify, 
+							   " ", 
+							   "", 
+							   NULL, 
+							   0, 
+							   XFPM_NOTIFY_NORMAL,
+							   NULL);
     }
     
+    i = (gint)value / 25;
+    
+    if ( i > 4 || i < 0 )
+	return;
+    
+    notify_notification_set_hint_int32  (backlight->priv->n,
+					 "value",
+					 value);
+    
+    notify_notification_set_hint_string (backlight->priv->n,
+					 "x-canonical-private-synchronous",
+					 "brightness");
+    
+    notify_notification_update (backlight->priv->n,
+			        " ",
+				"",
+				display_icon_name[i]);
+				
+    notify_notification_show (backlight->priv->n, NULL);
 }
 
 static void
-xfpm_backlight_class_init(XfpmBacklightClass *klass)
+xfpm_backlight_create_popup (XfpmBacklight *backlight)
 {
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-    object_class->finalize = xfpm_backlight_finalize;
-
-    g_type_class_add_private(klass,sizeof(XfpmBacklightPrivate));
+    if ( backlight->priv->osd != NULL )
+	return;
+	
+    backlight->priv->osd = gsd_media_keys_window_new ();
+    gsd_media_keys_window_set_action_custom (GSD_MEDIA_KEYS_WINDOW (backlight->priv->osd),
+					     XFPM_DISPLAY_BRIGHTNESS_ICON,
+					     TRUE);
+    gtk_window_set_position (GTK_WINDOW (backlight->priv->osd), GTK_WIN_POS_CENTER);
     
-    xfpm_backlight_dbus_class_init (klass);
+    g_signal_connect_swapped (backlight->priv->osd, "composited-changed",
+			      G_CALLBACK (xfpm_backlight_composited_changed_cb), backlight);
+			      
 }
 
 static void
-xfpm_backlight_init(XfpmBacklight *bk)
+xfpm_backlight_show (XfpmBacklight *backlight, gint level)
 {
-    bk->priv = XFPM_BACKLIGHT_GET_PRIVATE(bk);
+    gfloat value;
+    gboolean sync;
+    gboolean show_popup;
+    
+    XFPM_DEBUG ("Level %u", level);
+    
+    g_object_get (G_OBJECT (backlight->priv->conf),
+                  SHOW_BRIGHTNESS_POPUP, &show_popup,
+                  NULL);
+		  
+    if ( !show_popup )
+	goto out;
+    
+    g_object_get (G_OBJECT (backlight->priv->notify),
+		  "sync", &sync,
+		  NULL);
+    
+    value = (gfloat) 100 * level / backlight->priv->max_level;
+    
+    if ( !sync ) /*Notification server doesn't support sync notifications*/
+    {
+	xfpm_backlight_create_popup (backlight);
+	gsd_media_keys_window_set_volume_level (GSD_MEDIA_KEYS_WINDOW (backlight->priv->osd),
+						round (value));
+	if ( !GTK_WIDGET_VISIBLE (backlight->priv->osd))
+	    gtk_window_present (GTK_WINDOW (backlight->priv->osd));
+    }
+    else
+    {
+	xfpm_backlight_show_notification (backlight, value);
+    }
+    
+    if ( backlight->priv->destroy_id != 0 )
+    {
+	g_source_remove (backlight->priv->destroy_id);
+	backlight->priv->destroy_id = 0;
+    }
     
-    xfpm_backlight_get_device (bk);
+out:
+    /* Release the memory after 60 seconds */
+    backlight->priv->destroy_id = g_timeout_add_seconds (60, (GSourceFunc) xfpm_backlight_destroy_popup, backlight);
+}
+
+
+static void
+xfpm_backlight_alarm_timeout_cb (EggIdletime *idle, guint id, XfpmBacklight *backlight)
+{
+    backlight->priv->block = FALSE;
     
-    xfpm_backlight_dbus_init (bk);
+    if ( id == TIMEOUT_BRIGHTNESS_ON_AC && !backlight->priv->on_battery)
+	xfpm_backlight_dim_brightness (backlight);
+    else if ( id == TIMEOUT_BRIGHTNESS_ON_BATTERY && backlight->priv->on_battery)
+	xfpm_backlight_dim_brightness (backlight);
 }
 
 static void
-xfpm_backlight_finalize(GObject *object)
+xfpm_backlight_reset_cb (EggIdletime *idle, XfpmBacklight *backlight)
 {
-    XfpmBacklight *bk;
+    if ( backlight->priv->dimmed)
+    {
+	if ( !backlight->priv->block)
+	{
+	    XFPM_DEBUG ("Alarm reset, setting level to %i", backlight->priv->last_level);
+	    xfpm_brightness_set_level (backlight->priv->brightness, backlight->priv->last_level);
+	}
+	backlight->priv->dimmed = FALSE;
+    }
+}
 
-    bk = XFPM_BACKLIGHT(object);
+static void
+xfpm_backlight_button_pressed_cb (XfpmButton *button, XfpmButtonKey type, XfpmBacklight *backlight)
+{
+    gint level;
+    gboolean ret = TRUE;
     
-    if ( bk->priv->has_hw == TRUE )
+    gboolean enable_brightness, show_popup;
+    
+    g_object_get (G_OBJECT (backlight->priv->conf),
+                  ENABLE_BRIGHTNESS_CONTROL, &enable_brightness,
+		  SHOW_BRIGHTNESS_POPUP, &show_popup,
+                  NULL);
+    
+    if ( type == BUTTON_MON_BRIGHTNESS_UP )
     {
-	g_object_unref (bk->priv->br);
-	g_object_unref (bk->priv->widget);
+	backlight->priv->block = TRUE;
+#ifdef WITH_HAL
+	if ( !backlight->priv->brightness_in_hw && enable_brightness)
+	    ret = xfpm_brightness_up (backlight->priv->brightness, &level);
+#else
+	if ( enable_brightness )
+	    ret = xfpm_brightness_up (backlight->priv->brightness, &level);
+#endif
+	if ( ret && show_popup)
+	    xfpm_backlight_show (backlight, level);
     }
+    else if ( type == BUTTON_MON_BRIGHTNESS_DOWN )
+    {
+	backlight->priv->block = TRUE;
+#ifdef WITH_HAL
+	if ( !backlight->priv->brightness_in_hw && enable_brightness )
+	    ret = xfpm_brightness_down (backlight->priv->brightness, &level);
+#else
+	if ( enable_brightness )
+	    ret = xfpm_brightness_down (backlight->priv->brightness, &level);
+#endif
+	if ( ret && show_popup)
+	    xfpm_backlight_show (backlight, level);
+    }
+}
+
+static void
+xfpm_backlight_brightness_on_ac_settings_changed (XfpmBacklight *backlight)
+{
+    guint timeout_on_ac;
     
-    G_OBJECT_CLASS(xfpm_backlight_parent_class)->finalize(object);
+    g_object_get (G_OBJECT (backlight->priv->conf),
+		  BRIGHTNESS_ON_AC, &timeout_on_ac,
+		  NULL);
+		  
+    XFPM_DEBUG ("Alarm on ac timeout changed %u", timeout_on_ac);
+    
+    if ( timeout_on_ac == ALARM_DISABLED )
+    {
+	egg_idletime_alarm_remove (backlight->priv->idle, TIMEOUT_BRIGHTNESS_ON_AC );
+    }
+    else
+    {
+	egg_idletime_alarm_set (backlight->priv->idle, TIMEOUT_BRIGHTNESS_ON_AC, timeout_on_ac * 1000);
+    }
 }
 
-XfpmBacklight *
-xfpm_backlight_new(void)
+static void
+xfpm_backlight_brightness_on_battery_settings_changed (XfpmBacklight *backlight)
 {
-    XfpmBacklight *bk = NULL;
-    bk = g_object_new (XFPM_TYPE_BACKLIGHT, NULL);
-    return bk;
+    guint timeout_on_battery ;
+    
+    g_object_get (G_OBJECT (backlight->priv->conf),
+		  BRIGHTNESS_ON_BATTERY, &timeout_on_battery,
+		  NULL);
+    
+    XFPM_DEBUG ("Alarm on battery timeout changed %u", timeout_on_battery);
+    
+    if ( timeout_on_battery == ALARM_DISABLED )
+    {
+	egg_idletime_alarm_remove (backlight->priv->idle, TIMEOUT_BRIGHTNESS_ON_BATTERY );
+    }
+    else
+    {
+	egg_idletime_alarm_set (backlight->priv->idle, TIMEOUT_BRIGHTNESS_ON_BATTERY, timeout_on_battery * 1000);
+    } 
 }
 
-/*
- * 
- * DBus server implementation for org.freedesktop.PowerManagement.Backlight (Not standard) 
- *
- */
 
-static gboolean xfpm_backlight_dbus_update_brightness (XfpmBacklight *bk,
-						       guint IN_level,
-						       GError **error);
+static void
+xfpm_backlight_set_timeouts (XfpmBacklight *backlight)
+{
+    xfpm_backlight_brightness_on_ac_settings_changed (backlight);
+    xfpm_backlight_brightness_on_battery_settings_changed (backlight);
+}
 
-#include "org.freedesktop.PowerManagement.Backlight.h"
+static void
+xfpm_backlight_on_battery_changed_cb (XfpmPower *power, gboolean on_battery, XfpmBacklight *backlight)
+{
+    backlight->priv->on_battery = on_battery;
+}
 
-static void xfpm_backlight_dbus_class_init  (XfpmBacklightClass *klass)
+static void
+xfpm_backlight_class_init (XfpmBacklightClass *klass)
 {
-    dbus_g_object_type_install_info (G_TYPE_FROM_CLASS(klass),
-				     &dbus_glib_xfpm_backlight_object_info);
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    object_class->finalize = xfpm_backlight_finalize;
+
+    g_type_class_add_private (klass, sizeof (XfpmBacklightPrivate));
 }
 
-static void xfpm_backlight_dbus_init	  (XfpmBacklight *bk)
+static void
+xfpm_backlight_init (XfpmBacklight *backlight)
 {
-    DBusGConnection *bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+    backlight->priv = XFPM_BACKLIGHT_GET_PRIVATE (backlight);
+    
+    backlight->priv->brightness = xfpm_brightness_new ();
+    backlight->priv->has_hw     = xfpm_brightness_setup (backlight->priv->brightness);
     
-    dbus_g_connection_register_g_object (bus,
-					 "/org/freedesktop/PowerManagement/Backlight",
-					 G_OBJECT(bk));
+    backlight->priv->osd    = NULL;
+    backlight->priv->notify = NULL;
+    backlight->priv->idle   = NULL;
+    backlight->priv->conf   = NULL;
+    backlight->priv->button = NULL;
+    backlight->priv->power    = NULL;
+    backlight->priv->dimmed = FALSE;
+    backlight->priv->block = FALSE;
+    backlight->priv->destroy_id = 0;
+    
+    if ( !backlight->priv->has_hw )
+    {
+	g_object_unref (backlight->priv->brightness);
+	backlight->priv->brightness = NULL;
+    }
+    else
+    {
+	backlight->priv->idle   = egg_idletime_new ();
+	backlight->priv->conf   = xfpm_xfconf_new ();
+	backlight->priv->button = xfpm_button_new ();
+	backlight->priv->power    = xfpm_power_get ();
+	backlight->priv->notify = xfpm_notify_new ();
+	backlight->priv->max_level = xfpm_brightness_get_max_level (backlight->priv->brightness);
+#ifdef WITH_HAL
+	if ( xfpm_brightness_get_control (backlight->priv->brightness) == XFPM_BRIGHTNESS_CONTROL_HAL )
+	    backlight->priv->brightness_in_hw = xfpm_brightness_in_hw (backlight->priv->brightness);
+#endif
+	g_signal_connect (backlight->priv->idle, "alarm-expired",
+                          G_CALLBACK (xfpm_backlight_alarm_timeout_cb), backlight);
+        
+        g_signal_connect (backlight->priv->idle, "reset",
+                          G_CALLBACK(xfpm_backlight_reset_cb), backlight);
+			  
+	g_signal_connect (backlight->priv->button, "button-pressed",
+		          G_CALLBACK (xfpm_backlight_button_pressed_cb), backlight);
+			  
+	g_signal_connect_swapped (backlight->priv->conf, "notify::" BRIGHTNESS_ON_AC,
+				  G_CALLBACK (xfpm_backlight_brightness_on_ac_settings_changed), backlight);
+	
+	g_signal_connect_swapped (backlight->priv->conf, "notify::" BRIGHTNESS_ON_BATTERY,
+				  G_CALLBACK (xfpm_backlight_brightness_on_battery_settings_changed), backlight);
+				
+	g_signal_connect (backlight->priv->power, "on-battery-changed",
+			  G_CALLBACK (xfpm_backlight_on_battery_changed_cb), backlight);
+	g_object_get (G_OBJECT (backlight->priv->power),
+		      "on-battery", &backlight->priv->on_battery,
+		      NULL);
+	xfpm_brightness_get_level (backlight->priv->brightness, &backlight->priv->last_level);
+	xfpm_backlight_set_timeouts (backlight);
+    }
 }
 
-
-static gboolean xfpm_backlight_dbus_update_brightness (XfpmBacklight *bk,
-						       guint IN_level,
-						       GError **error)
+static void
+xfpm_backlight_finalize (GObject *object)
 {
-    TRACE("Update backlight message received");
-    if ( bk->priv->has_hw )
-	xfpm_brightness_hal_update_level (bk->priv->br, IN_level);
-    
-    return TRUE;
+    XfpmBacklight *backlight;
+
+    backlight = XFPM_BACKLIGHT (object);
+
+    xfpm_backlight_destroy_popup (backlight);
+
+    if ( backlight->priv->brightness )
+	g_object_unref (backlight->priv->brightness);
+
+    if ( backlight->priv->idle )
+	g_object_unref (backlight->priv->idle);
+
+    if ( backlight->priv->conf )
+	g_object_unref (backlight->priv->conf);
+
+    if ( backlight->priv->button )
+	g_object_unref (backlight->priv->button);
+
+    if ( backlight->priv->power )
+	g_object_unref (backlight->priv->power);
+
+    if ( backlight->priv->notify)
+	g_object_unref (backlight->priv->notify);
+
+    G_OBJECT_CLASS (xfpm_backlight_parent_class)->finalize (object);
 }
 
-gboolean xfpm_backlight_has_hw (XfpmBacklight *bk)
+XfpmBacklight *
+xfpm_backlight_new (void)
 {
-    g_return_val_if_fail (XFPM_IS_BACKLIGHT (bk), FALSE);
-    
-    return bk->priv->has_hw;
+    XfpmBacklight *backlight = NULL;
+    backlight = g_object_new (XFPM_TYPE_BACKLIGHT, NULL);
+    return backlight;
 }
 
-void xfpm_backlight_reload (XfpmBacklight *bk)
+gboolean xfpm_backlight_has_hw (XfpmBacklight *backlight)
 {
-    g_return_if_fail (XFPM_IS_BACKLIGHT (bk));
-    
-    if ( bk->priv->has_hw == TRUE )
-    {
-	g_object_unref (bk->priv->br);
-	g_object_unref (bk->priv->widget);
-    }
-    
-    xfpm_backlight_get_device (bk);
+    return backlight->priv->has_hw;
 }
diff --git a/src/xfpm-backlight.h b/src/xfpm-backlight.h
index 99171fd..3f9160d 100644
--- a/src/xfpm-backlight.h
+++ b/src/xfpm-backlight.h
@@ -26,30 +26,29 @@
 G_BEGIN_DECLS
 
 #define XFPM_TYPE_BACKLIGHT        (xfpm_backlight_get_type () )
-#define XFPM_BACKLIGHT(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_BACKLIGHT, XfpmBacklight))
-#define XFPM_IS_BACKLIGHT(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_BACKLIGHT))
+#define XFPM_BACKLIGHT(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_BACKLIGHT, XfpmBacklight))
+#define XFPM_IS_BACKLIGHT(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_BACKLIGHT))
 
 typedef struct XfpmBacklightPrivate XfpmBacklightPrivate;
 
 typedef struct
 {
-    GObject		 	  parent;
-    XfpmBacklightPrivate	 *priv;
-	
+    GObject         		parent;
+    XfpmBacklightPrivate       *priv;
+    
 } XfpmBacklight;
 
 typedef struct
 {
-    GObjectClass parent_class;
-	
+    GObjectClass 		parent_class;
+    
 } XfpmBacklightClass;
 
-GType			         xfpm_backlight_get_type        (void) G_GNUC_CONST;
-XfpmBacklight       		*xfpm_backlight_new             (void);
+GType        			xfpm_backlight_get_type         (void) G_GNUC_CONST;
 
-gboolean                         xfpm_backlight_has_hw          (XfpmBacklight *bk) G_GNUC_PURE;
+XfpmBacklight       	       *xfpm_backlight_new              (void);
 
-void                             xfpm_backlight_reload          (XfpmBacklight *bk);
+gboolean			xfpm_backlight_has_hw		(XfpmBacklight *backlight);
 
 G_END_DECLS
 
diff --git a/src/xfpm-battery-info.c b/src/xfpm-battery-info.c
deleted file mode 100644
index 6580116..0000000
--- a/src/xfpm-battery-info.c
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <libxfce4util/libxfce4util.h>
-#include <libxfcegui4/libxfcegui4.h>
-
-#include "xfpm-battery-info.h"
-
-static GtkWidget *
-xfpm_battery_info (HalBattery *device)
-{
-    PangoFontDescription *pfd;
-    
-    GtkWidget *table;
-    GtkWidget *label;
-    GtkWidget *align;
-    
-    gint i = 0;
-
-    gchar   *unit = NULL;
-    gchar   *str;
-    guint32  last_full = 0;
-    guint32  design_capacity = 0;
-    gchar   *tech = NULL;
-    gchar   *vendor = NULL;
-    gchar   *model = NULL;
-
-    g_object_get (G_OBJECT(device), 
-    		  "unit", &unit,
-		  "reporting-last-full", &last_full, 
-		  "technology", &tech, 
-		  "vendor", &vendor,
-		  "model", &model,
-		  "reporting-design", &design_capacity,
-		  NULL);
-		  
-    pfd = pango_font_description_from_string("bold");
-    
-    table = gtk_table_new (4, 2, FALSE);
-    
-    if (!unit)
-    	unit = g_strdup (_("Unknown unit"));
-    
-    //Technology
-    if ( tech )
-    {
-    	align = gtk_alignment_new (0.0, 0.5, 0, 0);
-    
-    	label = gtk_label_new (_("Technology:"));
-    	gtk_container_add (GTK_CONTAINER(align), label);
-    	gtk_widget_modify_font (label, pfd);
-    
-    	gtk_table_attach(GTK_TABLE(table), align,
-			 0, 1, i, i+1, 
-		     	 GTK_FILL, GTK_FILL,
-		     	 2, 8);
-
-	label = gtk_label_new (tech);
-	align = gtk_alignment_new (0.0, 0.5, 0, 0);
-	gtk_container_add (GTK_CONTAINER(align), label);
-	g_free (tech);
-	gtk_table_attach(GTK_TABLE(table), align,
-			 1, 2, i, i+1, 
-			 GTK_FILL, GTK_FILL,
-		     	 2, 8);
-    	i++;
-    }
-
-    /// Capacity design
-    if ( design_capacity != 0 )
-    {
-	label = gtk_label_new (_("Design:"));
-	align = gtk_alignment_new (0.0, 0.5, 0, 0);
-	gtk_container_add (GTK_CONTAINER(align), label);
-	
-	gtk_widget_modify_font (label, pfd);
-	
-	gtk_table_attach(GTK_TABLE(table), align,
-			 0, 1, i, i+1, 
-			 GTK_FILL, GTK_FILL,
-			 2, 8);
-			 
-	str = g_strdup_printf ("%d %s", design_capacity, unit);
-	
-	label = gtk_label_new (str);
-	g_free (str);
-	align = gtk_alignment_new (0.0, 0.5, 0, 0);
-	gtk_container_add (GTK_CONTAINER(align), label);
-	
-	gtk_table_attach(GTK_TABLE(table), align,
-			 1, 2, i, i+1, 
-			 GTK_FILL, GTK_FILL,
-			 2, 8);
-	i++;
-    }
-    
-    
-    if ( last_full != 0 )
-    {
-    	label = gtk_label_new (_("Last full:"));
-	align = gtk_alignment_new (0.0, 0.5, 0, 0);
-	gtk_container_add (GTK_CONTAINER(align), label);
-    	gtk_widget_modify_font (label, pfd);
-    
-    	gtk_table_attach(GTK_TABLE(table), align,
-			 0, 1, i, i+1, 
-			 GTK_FILL, GTK_FILL,
-		     	 2, 8);
-			 
-	str = g_strdup_printf ("%d %s", last_full, unit);
-	label = gtk_label_new (str);
-	align = gtk_alignment_new (0.0, 0.5, 0, 0);
-	gtk_container_add (GTK_CONTAINER(align), label);
-	g_free (str);
-	gtk_table_attach(GTK_TABLE(table), align,
-			 1, 2, i, i+1, 
-			 GTK_FILL, GTK_FILL,
-		     	 2, 8);
-    	i++;
-    }
-    
-    if ( vendor )
-    {
-    	label = gtk_label_new (_("Vendor:"));
-	align = gtk_alignment_new (0.0, 0.5, 0, 0);
-	gtk_container_add (GTK_CONTAINER(align), label);
-	gtk_widget_modify_font (label, pfd);
-	
-	gtk_table_attach(GTK_TABLE(table), align,
-			 0, 1, i, i+1, 
-			 GTK_FILL, GTK_FILL,
-			 2, 8);
-	
-	label = gtk_label_new (vendor);
-	align = gtk_alignment_new (0.0, 0.5, 0, 0);
-	gtk_container_add (GTK_CONTAINER(align), label);
-	g_free (vendor);
-	gtk_table_attach(GTK_TABLE(table), align,
-			 1, 2, i, i+1, 
-			 GTK_FILL, GTK_FILL,
-		     	 2, 8);
-	i++;
-    }
-    
-     
-    if ( model )
-    {
-    	label = gtk_label_new (_("Model:"));
-	align = gtk_alignment_new (0.0, 0.5, 0, 0);
-	gtk_container_add (GTK_CONTAINER(align), label);
-	gtk_widget_modify_font (label, pfd);
-	
-	gtk_table_attach(GTK_TABLE(table), align,
-			 0, 1, i, i+1, 
-			 GTK_FILL, GTK_FILL,
-			 2, 8);
-	
-	label = gtk_label_new (model);
-	align = gtk_alignment_new (0.0, 0.5, 0, 0);
-	gtk_container_add (GTK_CONTAINER(align), label);
-	g_free (model);
-	gtk_table_attach(GTK_TABLE(table), align,
-			 1, 2, i, i+1, 
-			 GTK_FILL, GTK_FILL,
-		     	 2, 8);
-	i++;
-    }
-    
-    if ( unit )
-    	g_free(unit);
-	
-    return table;
-}
-
-GtkWidget *xfpm_battery_info_new (HalBattery *device, const gchar *icon_name)
-{
-    GtkWidget *info;
-    GtkWidget *mainbox;
-    GtkWidget *allbox;
-    
-    info = xfce_titled_dialog_new_with_buttons(_("Battery information"),
-					       NULL,
-                                               GTK_DIALOG_DESTROY_WITH_PARENT,
-                                               GTK_STOCK_CLOSE,
-                                               GTK_RESPONSE_CANCEL,
-					       NULL);
-					       
-    gtk_window_set_icon_name (GTK_WINDOW(info), icon_name);
-    gtk_dialog_set_default_response (GTK_DIALOG(info), GTK_RESPONSE_CLOSE);
-    
-    mainbox = GTK_DIALOG (info)->vbox;
-    
-    allbox = gtk_vbox_new (FALSE, 0);
-    gtk_box_pack_start (GTK_BOX(mainbox), allbox, TRUE, TRUE, 0);
-    
-    gtk_box_pack_start (GTK_BOX (allbox), xfpm_battery_info(device), FALSE, FALSE, 8);
-    
-    g_signal_connect (info, "response", G_CALLBACK(gtk_widget_destroy), NULL);
-    
-    return info;
-}
diff --git a/src/xfpm-battery-info.h b/src/xfpm-battery-info.h
deleted file mode 100644
index 766a750..0000000
--- a/src/xfpm-battery-info.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __XFPM_BATTERY_INFO_H
-#define __XFPM_BATTERY_INFO_H
-
-#include <gtk/gtk.h>
-#include <glib.h>
-
-#include "libxfpm/hal-battery.h"
-
-G_BEGIN_DECLS
-
-GtkWidget 	*xfpm_battery_info_new 		(HalBattery *device, const gchar *icon_name);
-
-G_END_DECLS
-
-#endif /*__XFPM_BATTERY_INFO_H */
diff --git a/src/xfpm-battery.c b/src/xfpm-battery.c
index a2315ec..dea3a90 100644
--- a/src/xfpm-battery.c
+++ b/src/xfpm-battery.c
@@ -1,5 +1,5 @@
 /*
- * * Copyright (C) 2008 Ali <aliov at xfce.org>
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
  *
  * Licensed under the GNU General Public License Version 2
  *
@@ -26,107 +26,85 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <glib.h>
 #include <gtk/gtk.h>
 
-#include <glib.h>
-
 #include <libxfce4util/libxfce4util.h>
 
-#include "libxfpm/xfpm-string.h"
-#include "libxfpm/xfpm-notify.h"
-#include "libxfpm/xfpm-icons.h"
-
 #include "xfpm-battery.h"
-#include "xfpm-tray-icon.h"
-#include "xfpm-string.h"
-#include "xfpm-marshal.h"
-#include "xfpm-enum-types.h"
-#include "xfpm-enum.h"
-#include "xfpm-battery-info.h"
+#include "xfpm-dbus.h"
+#include "xfpm-icons.h"
 #include "xfpm-xfconf.h"
+#include "xfpm-notify.h"
 #include "xfpm-config.h"
-#include "xfpm-adapter.h"
+#include "xfpm-enum-glib.h"
+#include "xfpm-enum-types.h"
 #include "xfpm-debug.h"
+#include "xfpm-power-common.h"
+#include "xfpm-common.h"
 
 static void xfpm_battery_finalize   (GObject *object);
 
 #define XFPM_BATTERY_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_BATTERY, XfpmBatteryPrivate))
+(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_BATTERY, XfpmBatteryPrivate))
 
 struct XfpmBatteryPrivate
 {
-    XfpmTrayIcon    *icon;
-    XfpmAdapter     *adapter;
-    HalBattery      *device;
-    XfpmXfconf      *conf;
-    XfpmNotify      *notify;
-
-    HalDeviceType    type;
-    gchar 	    *icon_prefix;
-    
-    gboolean         adapter_present;
-    XfpmBatteryState state;
-    
-    gulong	     sig_1;
-    gulong           sig_2;
-    gulong           sig_3;
+    XfpmXfconf             *conf;
+    XfpmNotify		   *notify;
+    DBusGProxy             *proxy;
+    DBusGProxy 		   *proxy_prop;
+    
+    gchar		   *icon_prefix;
+    
+    XfpmBatteryCharge       charge;
+    XfpmDeviceState         state;
+    XfpmDeviceType          type;
+    gboolean		    ac_online;
+    gboolean                present;
+    guint 		    percentage;
+    gint64		    time_to_full;
+    gint64		    time_to_empty;
+    
+    gulong		    sig;
 };
 
 enum
 {
-    BATTERY_STATE_CHANGED,
+    PROP_0,
+    PROP_AC_ONLINE,
+    PROP_CHARGE_STATUS,
+    PROP_DEVICE_TYPE
+};
+    
+enum
+{
+    BATTERY_CHARGE_CHANGED,
     LAST_SIGNAL
 };
 
-static guint signals[LAST_SIGNAL] = { 0 };
+static guint signals [LAST_SIGNAL] = { 0 };
 
-G_DEFINE_TYPE(XfpmBattery, xfpm_battery, G_TYPE_OBJECT)
+G_DEFINE_TYPE (XfpmBattery, xfpm_battery, GTK_TYPE_STATUS_ICON)
 
 static const gchar * G_GNUC_CONST
-xfpm_battery_get_icon_index (HalDeviceType type, guint percent)
+xfpm_battery_get_icon_index (XfpmDeviceType type, guint percent)
 {
     if (percent < 10) {
-	return "000";
+        return "000";
     } else if (percent < 30) {
-	return (type == HAL_DEVICE_TYPE_PRIMARY || type == HAL_DEVICE_TYPE_UPS ? "020" : "030");
+        return ( (type == XFPM_DEVICE_TYPE_BATTERY || type == XFPM_DEVICE_TYPE_UPS) ? "020" : "030");
     } else if (percent < 50) {
-	return (type == HAL_DEVICE_TYPE_PRIMARY || type == HAL_DEVICE_TYPE_UPS ? "040" : "030");
+        return ( (type == XFPM_DEVICE_TYPE_BATTERY || type == XFPM_DEVICE_TYPE_UPS ) ? "040" : "030");
     } else if (percent < 70) {
-	return "060";
+        return "060";
     } else if (percent < 90) {
-	return (type == HAL_DEVICE_TYPE_PRIMARY || type == HAL_DEVICE_TYPE_UPS ? "080" : "060");
+        return ((type == XFPM_DEVICE_TYPE_BATTERY || type == XFPM_DEVICE_TYPE_UPS) ? "080" : "060");
     }
     return "100";
 }
 
-static const gchar * G_GNUC_CONST
-xfpm_battery_get_message_from_battery_state (XfpmBatteryState state, gboolean adapter_present)
-{
-    switch (state)
-    {
-	case BATTERY_FULLY_CHARGED:
-	    return _("Your battery is fully charged");
-	    break;
-	case BATTERY_NOT_FULLY_CHARGED:
-	    return _("Your battery is charging");
-	    break;
-	case BATTERY_IS_CHARGING:
-	    return  _("Battery is charging");
-	    break;
-	case BATTERY_IS_DISCHARGING:
-	    return  adapter_present ? _("Your battery is discharging"): _("System is running on battery power");
-	    break;
-	case BATTERY_CHARGE_LOW:
-	    return adapter_present ? _("Your battery charge is low") : _("System is running on low power"); 
-	    break;
-	default:
-	    return NULL;
-    }
-}
-
 static void
-xfpm_battery_refresh_visible_icon (XfpmBattery *battery)
+xfpm_battery_refresh_visible (XfpmBattery *battery)
 {
     XfpmShowIcon show_icon;
     gboolean visible = TRUE;
@@ -141,96 +119,95 @@ xfpm_battery_refresh_visible_icon (XfpmBattery *battery)
 	visible = FALSE;
     else if ( show_icon == SHOW_ICON_WHEN_BATTERY_PRESENT )
     {
-	if ( battery->priv->state == BATTERY_NOT_PRESENT )
-	    visible = FALSE;
-	else visible = TRUE;
+	if ( battery->priv->present )
+	    visible = TRUE;
+	else visible = FALSE;
     }
     else if ( show_icon == SHOW_ICON_WHEN_BATTERY_CHARGING_DISCHARGING )
     {
-	if ( battery->priv->state == BATTERY_FULLY_CHARGED )
+	if ( battery->priv->state == XFPM_DEVICE_STATE_FULLY_CHARGED )
 	    visible = FALSE;
 	else visible = TRUE;
     }
 
-    XFPM_DEBUG_ENUM ("Tray icon configuration: ", show_icon, XFPM_TYPE_SHOW_ICON);
-    XFPM_DEBUG_ENUM_FULL (battery->priv->state, XFPM_TYPE_BATTERY_STATE, " setting tray icon visible %s", 
-			  xfpm_bool_to_string (visible));
-    xfpm_tray_icon_set_visible (battery->priv->icon, visible);
+    XFPM_DEBUG_ENUM (show_icon, XFPM_TYPE_SHOW_ICON, "visible=%s", xfpm_bool_to_string (visible));
+			  
+    gtk_status_icon_set_visible (GTK_STATUS_ICON (battery), visible);
 }
-    
-static void
-xfpm_battery_refresh_icon (XfpmBattery *battery, 
-			   XfpmBatteryState state,
-			   guint percentage)
-{
-    gchar *icon;
 
-    if ( state == BATTERY_NOT_PRESENT )
+
+static const gchar * G_GNUC_CONST
+xfpm_battery_get_message_from_battery_state (XfpmDeviceState state, gboolean ac_online)
+{
+    switch (state)
     {
-	xfpm_tray_icon_set_icon (battery->priv->icon, 
-				 battery->priv->type == HAL_DEVICE_TYPE_UPS ? 
-				 XFPM_UPS_ICON_PREFIX "missing" : 
-				 XFPM_PRIMARY_ICON_PREFIX "missing");
-	return;
+	case XFPM_DEVICE_STATE_FULLY_CHARGED:
+	    return _("Your battery is fully charged");
+	    break;
+	case XFPM_DEVICE_STATE_CHARGING:
+	    return  _("Your battery is charging");
+	    break;
+	case XFPM_DEVICE_STATE_DISCHARGING:
+	    return  ac_online ? _("Your battery is discharging"): _("System is running on battery power");
+	    break;
+	default:
+	    return NULL;
     }
+}
+
+static void
+xfpm_battery_refresh_icon (XfpmBattery *battery)
+{
+    gchar icon_name[128];
+    
+    XFPM_DEBUG ("Battery state %d", battery->priv->state);
     
-    /* Battery full */
-    if ( state == BATTERY_FULLY_CHARGED )
+    if ( battery->priv->type == XFPM_DEVICE_TYPE_BATTERY || 
+	 battery->priv->type == XFPM_DEVICE_TYPE_UPS )
     {
-	if ( battery->priv->type == HAL_DEVICE_TYPE_PRIMARY)
-	    xfpm_tray_icon_set_icon (battery->priv->icon, 
-				     battery->priv->adapter_present ? 
-				     XFPM_PRIMARY_ICON_PREFIX "charged" : 
-				     XFPM_PRIMARY_ICON_PREFIX "100");
-	else
+	if (!battery->priv->present)
 	{
-	    icon = g_strdup_printf("%s%s", 
-	    		           battery->priv->icon_prefix, 
-	    			   xfpm_battery_get_icon_index (battery->priv->type, percentage));
-	    xfpm_tray_icon_set_icon (battery->priv->icon, icon);
-	    g_free(icon);
+	    g_snprintf (icon_name, 128, "%s%s", battery->priv->icon_prefix, "missing");
 	}
-    }
-    else if ( state == BATTERY_NOT_FULLY_CHARGED )
-    {
-	if ( battery->priv->adapter_present )
+	else if (battery->priv->state == XFPM_DEVICE_STATE_FULLY_CHARGED )
 	{
-	    icon = g_strdup_printf("%s%s-%s",
-			      battery->priv->icon_prefix, 
-			      xfpm_battery_get_icon_index (battery->priv->type, percentage),
-			      "charging");
+	    g_snprintf (icon_name, 128, "%s%s", battery->priv->icon_prefix, battery->priv->ac_online ? "charged" : "100");
 	}
-	else
+	else if ( battery->priv->state == XFPM_DEVICE_STATE_CHARGING || 
+		  battery->priv->state == XFPM_DEVICE_STATE_PENDING_CHARGING)
 	{
-	    icon = g_strdup_printf("%s%s",
-			      battery->priv->icon_prefix, 
-			      xfpm_battery_get_icon_index (battery->priv->type, percentage));
+	    g_snprintf (icon_name, 128, "%s%s-%s", 
+			battery->priv->icon_prefix, 
+			xfpm_battery_get_icon_index (battery->priv->type, battery->priv->percentage),
+			"charging");
+	}
+	else if ( battery->priv->state == XFPM_DEVICE_STATE_DISCHARGING ||
+		  battery->priv->state == XFPM_DEVICE_STATE_PENDING_DISCHARGING)
+	{
+	    g_snprintf (icon_name, 128, "%s%s", 
+			battery->priv->icon_prefix, 
+			xfpm_battery_get_icon_index (battery->priv->type, battery->priv->percentage));
 	}
-	xfpm_tray_icon_set_icon (battery->priv->icon, icon);
-	g_free(icon);
-	
-    }
-    else if ( state == BATTERY_IS_CHARGING )
-    {
-	icon = g_strdup_printf("%s%s-%s",
-			      battery->priv->icon_prefix, 
-			      xfpm_battery_get_icon_index (battery->priv->type, percentage),
-			      "charging");
-				      
-	xfpm_tray_icon_set_icon (battery->priv->icon, icon);
-	g_free(icon);
     }
-    else if ( state == BATTERY_IS_DISCHARGING || state == BATTERY_CHARGE_CRITICAL ||
-	      state == BATTERY_CHARGE_LOW )
+    else
     {
-	icon = g_strdup_printf("%s%s",
-			      battery->priv->icon_prefix, 
-			      xfpm_battery_get_icon_index (battery->priv->type, percentage));
-				      
-	xfpm_tray_icon_set_icon (battery->priv->icon, icon);
-	g_free(icon);
-	
+	if ( !battery->priv->present )
+	{
+	    g_snprintf (icon_name, 128, "%s-000", battery->priv->icon_prefix);
+	}
+	else if ( battery->priv->state == XFPM_DEVICE_STATE_FULLY_CHARGED )
+	{
+	    g_snprintf (icon_name, 128, "%s-100", battery->priv->icon_prefix);
+	}
+	else if ( battery->priv->state == XFPM_DEVICE_STATE_DISCHARGING )
+	{
+	    g_snprintf (icon_name, 128, "%s-%s", 
+			battery->priv->icon_prefix, 
+			xfpm_battery_get_icon_index (battery->priv->type, battery->priv->percentage));
+	}
     }
+    
+    gtk_status_icon_set_from_icon_name (GTK_STATUS_ICON (battery), icon_name);
 }
 
 static gboolean
@@ -241,496 +218,537 @@ xfpm_battery_notify_idle (gpointer data)
     
     battery = XFPM_BATTERY (data);
     
-    message = xfpm_battery_get_message_from_battery_state (battery->priv->state, battery->priv->adapter_present);
+    message = xfpm_battery_get_message_from_battery_state (battery->priv->state, battery->priv->ac_online);
+    
     if ( !message )
 	return FALSE;
 	
     xfpm_notify_show_notification (battery->priv->notify, 
-				    _("Xfce power manager"), 
-				    message, 
-				    xfpm_tray_icon_get_icon_name (battery->priv->icon),
-				    8000,
-				    battery->priv->type == HAL_DEVICE_TYPE_PRIMARY ? FALSE : TRUE,
-				    XFPM_NOTIFY_NORMAL,
-				    xfpm_tray_icon_get_tray_icon(battery->priv->icon));
-    
+				   _("Xfce power manager"), 
+				   message, 
+				   gtk_status_icon_get_icon_name (GTK_STATUS_ICON (battery)),
+				   8000,
+				   FALSE,
+				   XFPM_NOTIFY_NORMAL,
+				   GTK_STATUS_ICON (battery));
     return FALSE;
 }
 
 static void
-xfpm_battery_notify (XfpmBattery *battery)
+xfpm_battery_notify_state (XfpmBattery *battery)
 {
     gboolean notify;
     static gboolean starting_up = TRUE;
-
-    if ( starting_up )
-    {
-	starting_up = FALSE;
+    
+    if ( !gtk_status_icon_get_visible (GTK_STATUS_ICON (battery)) )
 	return;
-    }
-
-    g_object_get (G_OBJECT (battery->priv->conf),
-		  GENERAL_NOTIFICATION_CFG, &notify,
-		  NULL);
-		  
-    if ( notify )
+    
+    if ( battery->priv->type == XFPM_DEVICE_TYPE_BATTERY ||
+	 battery->priv->type == XFPM_DEVICE_TYPE_UPS )
     {
-	g_idle_add ((GSourceFunc) xfpm_battery_notify_idle, battery);
+	if ( starting_up )
+	{
+	    starting_up = FALSE;
+	    return;
+	}
+    
+	g_object_get (G_OBJECT (battery->priv->conf),
+		      GENERAL_NOTIFICATION_CFG, &notify,
+		      NULL);
+		      
+	if ( notify )
+	{
+	    g_idle_add ((GSourceFunc) xfpm_battery_notify_idle, battery);
+	}
     }
 }
 
-static const gchar * G_GNUC_CONST
-_get_battery_name (HalDeviceType type)
+/*
+ * Taken from gpm
+ */
+static gchar *
+xfpm_battery_get_time_string (guint seconds)
 {
-    if ( type ==  HAL_DEVICE_TYPE_UPS)
-	return _("Your UPS");
-    else if ( type == HAL_DEVICE_TYPE_MOUSE )
-	return _("Your Mouse battery");
-    else if ( type == HAL_DEVICE_TYPE_KEYBOARD )
-	return _("Your Keyboard battery");
-    else if ( type ==  HAL_DEVICE_TYPE_CAMERA )
-	return _("Your Camera battery");
-    else if ( type == HAL_DEVICE_TYPE_PDA)
-	return _("Your PDA battery");
-	
-    return _("Your Battery");
-}
+    char* timestring = NULL;
+    gint  hours;
+    gint  minutes;
 
-static const gchar * G_GNUC_PURE
-xfpm_battery_get_battery_state (XfpmBatteryState *state, 
-				gboolean is_charging, 
-				gboolean is_discharging,
-				guint32 last_full, 
-				guint32 current_charge, 
-				guint percentage,
-				guint8 critical_level)
-{
-    if ( G_UNLIKELY (current_charge == 0 || percentage == 0) )
+    /* Add 0.5 to do rounding */
+    minutes = (int) ( ( seconds / 60.0 ) + 0.5 );
+
+    if (minutes == 0) 
     {
-	*state = BATTERY_CHARGE_CRITICAL;
-	return _("is empty");
+	timestring = g_strdup (_("Unknown time"));
+	return timestring;
     }
-    
-    if ( !is_charging && !is_discharging &&  current_charge >= last_full )
+
+    if (minutes < 60) 
     {
-	*state = BATTERY_FULLY_CHARGED;
-	return _("is fully charged");
+	timestring = g_strdup_printf (ngettext ("%i minute",
+			              "%i minutes",
+				      minutes), minutes);
+	return timestring;
     }
-    else if ( !is_charging && !is_discharging && last_full != current_charge )
+
+    hours = minutes / 60;
+    minutes = minutes % 60;
+
+    if (minutes == 0)
+	timestring = g_strdup_printf (ngettext (
+			    "%i hour",
+			    "%i hours",
+			    hours), hours);
+    else
+	/* TRANSLATOR: "%i %s %i %s" are "%i hours %i minutes"
+	 * Swap order with "%2$s %2$i %1$s %1$i if needed */
+	timestring = g_strdup_printf (_("%i %s %i %s"),
+			    hours, ngettext ("hour", "hours", hours),
+			    minutes, ngettext ("minute", "minutes", minutes));
+    return timestring;
+}
+
+/*
+ * Refresh tooltip function for UPS and battery device only.
+ */
+static void
+xfpm_battery_set_tooltip_primary (XfpmBattery *battery, GtkTooltip *tooltip)
+{
+    const gchar *battery_name;
+    gchar *tip = NULL;
+    gchar *est_time_str = NULL;
+    gchar *power_status = NULL;
+    
+    power_status = g_strdup_printf (battery->priv->ac_online ? _("Adaptor is online") : _("System is running on battery power"));
+    
+    battery_name = battery->priv->type == XFPM_DEVICE_TYPE_BATTERY ? _("Battery") : _("UPS");
+    
+    if ( battery->priv->state == XFPM_DEVICE_STATE_FULLY_CHARGED )
     {
-	*state = BATTERY_NOT_FULLY_CHARGED;
-	return _("charge level");
+	if ( battery->priv->time_to_empty > 0 )
+	{
+	    est_time_str = xfpm_battery_get_time_string (battery->priv->time_to_empty);
+	    tip = g_strdup_printf (_("%s\nYour %s is fully charged (%i%%).\nProvides %s runtime"), 
+				   power_status,
+				   battery_name, 
+				   battery->priv->percentage,
+				   est_time_str);
+	    g_free (est_time_str);
+	}
+	else
+	{
+	    tip = g_strdup_printf (_("%s\nYour %s is fully charged (%i%%)."), 
+				   power_status,
+				   battery_name,
+				   battery->priv->percentage);
+	}
     }
-    else if ( is_charging && !is_discharging )
+    else if ( battery->priv->state == XFPM_DEVICE_STATE_CHARGING )
     {
-	*state = BATTERY_IS_CHARGING;
-	return  _("is charging");
+	if ( battery->priv->time_to_full != 0 )
+	{
+	    est_time_str = xfpm_battery_get_time_string (battery->priv->time_to_full);
+	    tip = g_strdup_printf (_("%s\nYour %s is charging (%i%%)\n%s until is fully charged."), 
+				   power_status,
+				   battery_name, 
+				   battery->priv->percentage, 
+				   est_time_str);
+	    g_free (est_time_str);
+	}
+	else
+	{
+	    tip = g_strdup_printf (_("%s\nYour %s is charging (%i%%)."),
+				   power_status,
+				   battery_name,
+				   battery->priv->percentage);
+	}
     }
-    else if ( !is_charging && is_discharging )
+    else if ( battery->priv->state == XFPM_DEVICE_STATE_DISCHARGING )
     {
-	if ( percentage >= 30 )
+	if ( battery->priv->time_to_empty != 0 )
 	{
-	    *state = BATTERY_IS_DISCHARGING;
-	    return  _("is discharging");
+	    est_time_str = xfpm_battery_get_time_string (battery->priv->time_to_empty);
+	    tip = g_strdup_printf (_("%s\nYour %s is discharging (%i%%)\nestimated time left is %s."), 
+				   power_status,
+				   battery_name, 
+				   battery->priv->percentage, 
+				   est_time_str);
+	    g_free (est_time_str);
 	}
-	else if ( percentage >= critical_level && percentage < 30)
+	else
 	{
-	    *state = BATTERY_CHARGE_LOW;
-	    return  _("charge is low");
+	    tip = g_strdup_printf (_("%s\nYour %s is discharging (%i%%)."),
+				   power_status,
+				   battery_name,
+				   battery->priv->percentage);
 	}
-	else if ( percentage < critical_level )
-	{
-	    *state = BATTERY_CHARGE_CRITICAL;
-	    return _("is almost empty");
-    	}
+	
+    }
+    else if ( battery->priv->state == XFPM_DEVICE_STATE_PENDING_CHARGING )
+    {
+	tip = g_strdup_printf (_("%s\n%s waiting to discharge (%i%%)."), power_status, battery_name, battery->priv->percentage);
+    }
+    else if ( battery->priv->state == XFPM_DEVICE_STATE_PENDING_DISCHARGING )
+    {
+	tip = g_strdup_printf (_("%s\n%s waiting to charge (%i%%)."), power_status, battery_name, battery->priv->percentage);
+    }
+    else if ( battery->priv->state == XFPM_DEVICE_STATE_EMPTY )
+    {
+	tip = g_strdup_printf (_("%s\nYour %s is empty"), power_status, battery_name);
     }
     
-    g_warn_if_reached ();
-    
-    return "";
+    gtk_tooltip_set_text (tooltip, tip);
+    g_free (power_status);
+    g_free (tip);
 }
 
 static void
-xfpm_battery_refresh_common (XfpmBattery *battery, guint percentage, XfpmBatteryState state)
+xfpm_battery_check_charge (XfpmBattery *battery)
 {
-    XfpmShowIcon show_icon;
+    XfpmBatteryCharge charge;
+    guint critical_level, low_level;
     
     g_object_get (G_OBJECT (battery->priv->conf),
-		  SHOW_TRAY_ICON_CFG, &show_icon,
+		  CRITICAL_POWER_LEVEL, &critical_level,
 		  NULL);
-
-    if ( show_icon != NEVER_SHOW_ICON )
-	xfpm_battery_refresh_icon (battery, state, percentage);
-    
-    if ( battery->priv->state != state)
-    {
-	battery->priv->state = state;
-	XFPM_DEBUG_ENUM ("battery state change", battery->priv->state, XFPM_TYPE_BATTERY_STATE);
-	TRACE("Emitting signal battery state changed");
-	g_signal_emit (G_OBJECT(battery), signals[BATTERY_STATE_CHANGED], 0, state);
+		  
+    low_level = critical_level + 10;
+    
+    if ( battery->priv->percentage > low_level )
+	charge = XFPM_BATTERY_CHARGE_OK;
+    else if ( battery->priv->percentage <= low_level && battery->priv->percentage > critical_level )
+	charge = XFPM_BATTERY_CHARGE_LOW;
+    else if ( battery->priv->percentage <= critical_level )
+	charge = XFPM_BATTERY_CHARGE_CRITICAL;
 	
-	if ( battery->priv->state != BATTERY_NOT_FULLY_CHARGED && show_icon != NEVER_SHOW_ICON)
-	    xfpm_battery_notify (battery);
-	else
-	    xfpm_notify_close_normal (battery->priv->notify);
+    if ( charge != battery->priv->charge)
+    {
+	battery->priv->charge = charge;
+	/*
+	 * only emit signal when when battery charge changes from ok->low->critical
+	 * and not the other way round.
+	 */
+	if ( battery->priv->charge != XFPM_BATTERY_CHARGE_CRITICAL || charge != XFPM_BATTERY_CHARGE_LOW )
+	    g_signal_emit (G_OBJECT (battery), signals [BATTERY_CHARGE_CHANGED], 0);
     }
 }
 
 static void
-xfpm_battery_refresh_misc (XfpmBattery *battery, gboolean is_present, 
-			   gboolean is_charging, gboolean is_discharging,
-			   guint32 last_full, guint32 current_charge,
-			   guint percentage, guint time_per)
+xfpm_battery_refresh (XfpmBattery *battery, GHashTable *props)
 {
-    gchar *tip;
-    XfpmBatteryState state;
-    const gchar *str;
-    guint critical_level;
+    GValue *value;
+    guint state;
     
-    g_object_get (G_OBJECT (battery->priv->conf),
-		  CRITICAL_POWER_LEVEL, &critical_level,
-		  NULL);
+    value = g_hash_table_lookup (props, "IsPresent");
     
-    if ( !is_present )
+    if ( value == NULL )
     {
-	tip = g_strdup_printf ("%s %s", _get_battery_name(battery->priv->type), _("is not present"));
-	xfpm_tray_icon_set_tooltip (battery->priv->icon, tip);
-	g_free(tip);
-	battery->priv->state = BATTERY_NOT_PRESENT;
-	return;
+	g_warning ("No 'IsPresent' property found");
+	goto out;
     }
     
-    state = battery->priv->state;
-    str = xfpm_battery_get_battery_state (&state, is_charging, is_discharging,
-    				          last_full, current_charge, percentage, 
-					  critical_level);
-    tip = g_strdup_printf("%i%% %s %s", percentage, _get_battery_name(battery->priv->type), str);
-    //FIXME: Time for misc batteries
-    xfpm_tray_icon_set_tooltip (battery->priv->icon, tip);
-    g_free (tip);
+    battery->priv->present = g_value_get_boolean (value);
     
-    xfpm_battery_refresh_common (battery, percentage, state);
-}
-
-static void
-xfpm_battery_refresh_primary (XfpmBattery *battery, gboolean is_present, 
-			      gboolean is_charging, gboolean is_discharging,
-			      guint32 last_full, guint32 current_charge,
-			      guint percentage, guint time_per)
-{
-    gchar *tip;
-    const gchar *str;
-    guint critical_level;
-
-    XfpmBatteryState state = battery->priv->state;
+    value = g_hash_table_lookup (props, "State");
     
-    g_object_get (G_OBJECT (battery->priv->conf),
-		  CRITICAL_POWER_LEVEL, &critical_level,
-		  NULL);
-    
-    TRACE ("Start");
+    if ( value == NULL )
+    {
+	g_warning ("No 'State' property found");
+    }
     
-    if ( !is_present )
+    state = g_value_get_uint (value);
+    if ( state != battery->priv->state )
     {
-	xfpm_tray_icon_set_tooltip(battery->priv->icon, _("Battery not present"));
-	battery->priv->state = BATTERY_NOT_PRESENT;
-	return;
+	battery->priv->state = state;
+	xfpm_battery_refresh_visible (battery);
+	xfpm_battery_notify_state (battery);
     }
-
-    str = xfpm_battery_get_battery_state (&state, is_charging, is_discharging,
-					  last_full, current_charge, percentage, critical_level);
     
-    XFPM_DEBUG_ENUM ("battery state", state, XFPM_TYPE_BATTERY_STATE);
+    value = g_hash_table_lookup (props, "Percentage");
     
-    if ( time_per != 0  && time_per <= 28800 /* 8 hours */ && 
-	 state != BATTERY_FULLY_CHARGED && state != BATTERY_NOT_FULLY_CHARGED )
+    if ( value == NULL )
     {
-	gchar *time_str;
-        gchar *tip_no_time;
-	const gchar *est_time;
-	        
-        gint minutes, hours, minutes_left;
-       	hours = time_per / 3600;
-		minutes = time_per / 60;
-		minutes_left = minutes % 60;
-
-	tip_no_time = g_strdup_printf ("%i%% %s %s\n%s", 
-			       percentage, 
-			       _("Battery"),
-			       str,
-			       battery->priv->adapter_present ? 
-			       _("System is running on AC power") :
-			       _("System is running on battery power"));
-
-	if ( state == BATTERY_IS_DISCHARGING || 
-	     state == BATTERY_CHARGE_LOW         || 
-	     state == BATTERY_CHARGE_CRITICAL )
-        {
-            est_time = _("Estimated time left");
-        }
-        else //* BATTERY_IS_CHARGING
-        {
-            est_time = _("Estimated time to be fully charged");
-        }
-
-        time_str = g_strdup_printf("%s: %d %s %d %s",est_time,
-                                   hours,hours > 1 ? _("hours") : _("hour") ,
-                                   minutes_left, minutes_left > 1 ? _("minutes") : _("minute"));
-
-	tip = (hours != 0 || minutes_left != 0 ) ? 
-	     g_strdup_printf ("%s\n%s", tip_no_time, time_str) :
-	     g_strdup (tip_no_time);
-	     
-	g_free (tip_no_time);
-	g_free (time_str);
+	g_warning ("No 'Percentage' property found on battery device");
+	goto out;
     }
-    else
+    
+    battery->priv->percentage = (guint) g_value_get_double (value);
+    
+    xfpm_battery_check_charge (battery);
+    
+    xfpm_battery_refresh_icon (battery);
+    
+    if ( battery->priv->type == XFPM_DEVICE_TYPE_BATTERY ||
+	 battery->priv->type == XFPM_DEVICE_TYPE_UPS )
     {
-	 tip = g_strdup_printf ("%i%% %s %s\n%s", 
-			   percentage, 
-			   _("Battery"),
-			   str, 
-			   battery->priv->adapter_present ? 
-			   _("System is running on AC power") :
-			   _("System is running on battery power"));
+	value = g_hash_table_lookup (props, "TimeToEmpty");
+	
+	if ( value == NULL )
+	{
+	    g_warning ("No 'TimeToEmpty' property found on battery device");
+	    goto out;
+	}
+	
+	battery->priv->time_to_empty = g_value_get_int64 (value);
+	
+	value = g_hash_table_lookup (props, "TimeToFull");
+	
+	if ( value == NULL )
+	{
+	    g_warning ("No 'TimeToFull' property found on battery device");
+	    goto out;
+	}
+	
+	battery->priv->time_to_full = g_value_get_int64 (value);
     }
-
-    xfpm_tray_icon_set_tooltip(battery->priv->icon, tip);
-    g_free(tip);
-
-    xfpm_battery_refresh_common (battery, percentage, state);
+    
+    out:
+	g_hash_table_destroy (props);
 }
 
 static void
-xfpm_battery_refresh (XfpmBattery *battery)
+xfpm_battery_changed_cb (DBusGProxy *proxy, XfpmBattery *battery)
 {
-    gboolean is_present, is_charging, is_discharging = FALSE;
-    guint percentage = 0;
-    guint32 last_full, current_charge = 0;
-    guint time_per = 0;
-    
-    g_object_get (G_OBJECT(battery->priv->device), 
-    		  "is-present", &is_present,
-		  "is-charging", &is_charging,
-		  "is-discharging", &is_discharging, 
-		  "percentage", &percentage,
-		  "last-full", &last_full,
-		  "current-charge", &current_charge,
-		  "time", &time_per,
-		  NULL);
-		  
-    TRACE ("Battery status is_present %s is_charging %s is_discharging %s", 
-	   xfpm_bool_to_string (is_present), 
-	   xfpm_bool_to_string (is_charging), 
-	   xfpm_bool_to_string (is_discharging));
-	   
-    TRACE ("Battery info precentage %i last_full %i current_charge %i time_per %i",
-	   percentage, last_full, current_charge, time_per);
-	   
-    battery->priv->type == HAL_DEVICE_TYPE_PRIMARY ?
-			   xfpm_battery_refresh_primary (battery, is_present, 
-							 is_charging, is_discharging, 
-							 last_full, current_charge,
-							 percentage, time_per)
-  					           :
-			    xfpm_battery_refresh_misc   (battery, is_present, 
-							 is_charging, is_discharging, 
-							 last_full, current_charge,
-							 percentage, time_per);
-							 
-    xfpm_battery_refresh_visible_icon (battery);
+    GHashTable *props;
+    
+    props = xfpm_power_get_interface_properties (battery->priv->proxy_prop, DKP_IFACE_DEVICE);
+    
+    if ( props )
+	xfpm_battery_refresh (battery, props);
 }
 
-static void
-xfpm_battery_device_changed_cb (HalBattery *device, XfpmBattery *battery)
+static gboolean
+xfpm_battery_query_tooltip (GtkStatusIcon *icon, 
+			    gint x,
+			    gint y,
+			    gboolean keyboard_mode,
+			    GtkTooltip *tooltip)
 {
-    TRACE("start");
-    xfpm_battery_refresh (battery);
-}
+    XfpmBattery *battery;
+    
+    battery = XFPM_BATTERY (icon);
 
-static gchar *
-_get_icon_prefix_from_enum_type (HalDeviceType type)
-{
-    if ( type == HAL_DEVICE_TYPE_PRIMARY )
-    {
-	return g_strdup (XFPM_PRIMARY_ICON_PREFIX);
-    }
-    else if ( type == HAL_DEVICE_TYPE_UPS ) 
-    {
-	return g_strdup (XFPM_UPS_ICON_PREFIX);
-    }
-    else if ( type == HAL_DEVICE_TYPE_MOUSE ) 
-    {
-	return g_strdup (XFPM_MOUSE_ICON_PREFIX);
-    }
-    else if ( type == HAL_DEVICE_TYPE_KEYBOARD ) 
-    {
-	return g_strdup (XFPM_KBD_ICON_PREFIX);
-    }
-    else if ( type == HAL_DEVICE_TYPE_CAMERA ) 
-    {
-	return g_strdup (XFPM_CAMERA_ICON_PREFIX);
-    }
-    else if ( type == HAL_DEVICE_TYPE_PDA ) 
-    {
-	return g_strdup (XFPM_PDA_ICON_PREFIX);
-    }
-    else if ( type == HAL_DEVICE_TYPE_KEYBOARD_MOUSE ) 
+    if ( battery->priv->type == XFPM_DEVICE_TYPE_BATTERY ||
+	 battery->priv->type == XFPM_DEVICE_TYPE_UPS )
     {
-	return g_strdup (XFPM_KBD_MOUSE_ICON_PREFIX);
+	xfpm_battery_set_tooltip_primary (battery, tooltip);
+	return TRUE;
     }
     
-    return g_strdup (XFPM_PRIMARY_ICON_PREFIX);
+    return FALSE;
 }
 
 static void
-xfpm_battery_adapter_changed_cb (XfpmAdapter *adapter, gboolean present, XfpmBattery *battery)
+xfpm_battery_tray_icon_settings_changed (GObject *obj, GParamSpec *spec, XfpmBattery *battery)
 {
-    battery->priv->adapter_present = present;
-    xfpm_battery_refresh (battery);
+    xfpm_battery_refresh_visible (battery);
 }
 
-static void
-xfpm_battery_tray_icon_settings_changed (GObject *obj, GParamSpec *spec, XfpmBattery *battery)
+static void xfpm_battery_get_property (GObject *object,
+				       guint prop_id,
+				       GValue *value,
+				       GParamSpec *pspec)
 {
-    xfpm_battery_refresh_visible_icon (battery);
+    XfpmBattery *battery;
+    
+    battery = XFPM_BATTERY (object);
+    
+    switch (prop_id)
+    {
+	case PROP_AC_ONLINE:
+	    g_value_set_boolean (value, battery->priv->ac_online);
+	    break;
+	case PROP_DEVICE_TYPE:
+	    g_value_set_enum (value, battery->priv->type);
+	    break;
+	case PROP_CHARGE_STATUS:
+	    g_value_set_enum (value, battery->priv->charge);
+	    break;
+	default:
+	    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+            break;
+    }
 }
 
-static void
-xfpm_battery_show_info (XfpmTrayIcon *tray, XfpmBattery *battery)
+static void xfpm_battery_set_property (GObject *object,
+				       guint prop_id,
+				       const GValue *value,
+				       GParamSpec *pspec)
 {
-    gchar *icon = g_strdup_printf("%s%s",
-				  battery->priv->icon_prefix, 
-	    			  xfpm_battery_get_icon_index(battery->priv->type, 100));
-				      
-    GtkWidget *info = xfpm_battery_info_new (battery->priv->device, icon);
+    XfpmBattery *battery;
     
-    g_free (icon);
+    battery = XFPM_BATTERY (object);
     
-    gtk_widget_show_all (info);
+    switch (prop_id)
+    {
+	case PROP_AC_ONLINE:
+	    battery->priv->ac_online = g_value_get_boolean (value);
+	    xfpm_battery_refresh_icon (battery);
+	    break;
+	default:
+	    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+            break;
+    }
 }
 
+
 static void
-xfpm_battery_class_init(XfpmBatteryClass *klass)
+xfpm_battery_class_init (XfpmBatteryClass *klass)
 {
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-    signals[BATTERY_STATE_CHANGED] = 
-    	g_signal_new("battery-state-changed",
-		      XFPM_TYPE_BATTERY,
-		      G_SIGNAL_RUN_LAST,
-		      G_STRUCT_OFFSET(XfpmBatteryClass, battery_state_changed),
-		      NULL, NULL,
-		      g_cclosure_marshal_VOID__ENUM,
-		      G_TYPE_NONE, 1, XFPM_TYPE_BATTERY_STATE);
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+    GtkStatusIconClass *status_icon_class = GTK_STATUS_ICON_CLASS (klass);
 
     object_class->finalize = xfpm_battery_finalize;
-    
-    g_type_class_add_private(klass,sizeof(XfpmBatteryPrivate));
+    object_class->get_property = xfpm_battery_get_property;
+    object_class->set_property = xfpm_battery_set_property;
+
+    status_icon_class->query_tooltip = xfpm_battery_query_tooltip;
+    
+    signals [BATTERY_CHARGE_CHANGED] = 
+        g_signal_new ("battery-charge-changed",
+                      XFPM_TYPE_BATTERY,
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET(XfpmBatteryClass, battery_charge_changed),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE, 0, G_TYPE_NONE);
+    
+    g_object_class_install_property (object_class,
+                                     PROP_AC_ONLINE,
+                                     g_param_spec_boolean("ac-online",
+                                                          NULL, NULL,
+                                                          FALSE,
+                                                          G_PARAM_READWRITE));
+
+    g_object_class_install_property (object_class,
+                                     PROP_DEVICE_TYPE,
+                                     g_param_spec_enum ("device-type",
+                                                        NULL, NULL,
+							XFPM_TYPE_DEVICE_TYPE,
+							XFPM_DEVICE_TYPE_UNKNOWN,
+                                                        G_PARAM_READABLE));
+
+    g_object_class_install_property (object_class,
+                                     PROP_CHARGE_STATUS,
+                                     g_param_spec_enum ("charge-status",
+                                                        NULL, NULL,
+							XFPM_TYPE_BATTERY_CHARGE,
+							XFPM_BATTERY_CHARGE_UNKNOWN,
+                                                        G_PARAM_READABLE));
+
+    g_type_class_add_private (klass, sizeof (XfpmBatteryPrivate));
 }
 
 static void
-xfpm_battery_init(XfpmBattery *battery)
+xfpm_battery_init (XfpmBattery *battery)
 {
-    battery->priv = XFPM_BATTERY_GET_PRIVATE(battery);
-    
-    battery->priv->icon      = xfpm_tray_icon_new ();
-    battery->priv->adapter   = xfpm_adapter_new ();
-    battery->priv->conf      = xfpm_xfconf_new ();
-    battery->priv->notify    = xfpm_notify_new ();
-    battery->priv->state = BATTERY_STATE_UNKNOWN;
-    battery->priv->icon_prefix = NULL;
-    
-    battery->priv->adapter_present = xfpm_adapter_get_present (battery->priv->adapter);
-    
-    battery->priv->sig_1 = g_signal_connect (battery->priv->adapter ,"adapter-changed",
-					     G_CALLBACK (xfpm_battery_adapter_changed_cb), battery);
-    
-    g_signal_connect (battery->priv->icon, "show-information", 
-		      G_CALLBACK (xfpm_battery_show_info), battery);
+    battery->priv = XFPM_BATTERY_GET_PRIVATE (battery);
+    
+    battery->priv->conf          = xfpm_xfconf_new ();
+    battery->priv->notify        = xfpm_notify_new ();
+    battery->priv->proxy_prop    = NULL;
+    battery->priv->state         = XFPM_DEVICE_STATE_UNKNOWN;
+    battery->priv->type          = XFPM_DEVICE_TYPE_UNKNOWN;
+    battery->priv->charge        = XFPM_BATTERY_CHARGE_UNKNOWN;
+    battery->priv->icon_prefix   = NULL;
+    battery->priv->time_to_full  = 0;
+    battery->priv->time_to_empty = 0;
+    battery->priv->ac_online     = TRUE;
+    
+    battery->priv->sig = g_signal_connect (G_OBJECT (battery->priv->conf), "notify::" SHOW_TRAY_ICON_CFG,
+					   G_CALLBACK (xfpm_battery_tray_icon_settings_changed), battery);
 }
 
 static void
-xfpm_battery_finalize(GObject *object)
+xfpm_battery_finalize (GObject *object)
 {
     XfpmBattery *battery;
-    battery = XFPM_BATTERY(object);
- 
-    if ( g_signal_handler_is_connected (battery->priv->adapter, battery->priv->sig_1 ) )
-	g_signal_handler_disconnect (G_OBJECT (battery->priv->adapter), battery->priv->sig_1);
-	
-    if ( g_signal_handler_is_connected (battery->priv->conf, battery->priv->sig_2 ) )
-	g_signal_handler_disconnect (G_OBJECT (battery->priv->conf), battery->priv->sig_2);
-	
-     if ( g_signal_handler_is_connected (battery->priv->device, battery->priv->sig_3 ) )
-	g_signal_handler_disconnect (G_OBJECT (battery->priv->device), battery->priv->sig_3);
 
-    g_object_unref (battery->priv->icon);
+    battery = XFPM_BATTERY (object);
     
-    g_object_unref (battery->priv->device);
-	
-    if ( battery->priv->icon_prefix )
-    	g_free(battery->priv->icon_prefix);
-	
-    g_object_unref (battery->priv->adapter);
+    g_free (battery->priv->icon_prefix);
     
+    dbus_g_proxy_disconnect_signal (battery->priv->proxy, "Changed",
+				    G_CALLBACK (xfpm_battery_changed_cb), battery);
+				    
+    if ( g_signal_handler_is_connected (battery->priv->conf, battery->priv->sig ) )
+	g_signal_handler_disconnect (G_OBJECT (battery->priv->conf), battery->priv->sig);
+				    
+    g_object_unref (battery->priv->proxy);
+    g_object_unref (battery->priv->proxy_prop);
     g_object_unref (battery->priv->conf);
-    
     g_object_unref (battery->priv->notify);
 
-    G_OBJECT_CLASS(xfpm_battery_parent_class)->finalize(object);
+    G_OBJECT_CLASS (xfpm_battery_parent_class)->finalize (object);
 }
 
-XfpmBattery *
-xfpm_battery_new(const HalBattery *device)
+static gchar *
+xfpm_battery_get_icon_prefix_device_enum_type (XfpmDeviceType type)
 {
-    XfpmBattery *battery = NULL;
-    
-    battery = g_object_new(XFPM_TYPE_BATTERY, NULL);
-    
-    battery->priv->device = (HalBattery *)g_object_ref(G_OBJECT(device));
-    
-    g_object_get(G_OBJECT(battery->priv->device), "type", &battery->priv->type, NULL);
-    
-    battery->priv->icon_prefix = _get_icon_prefix_from_enum_type(battery->priv->type);
-    
-    xfpm_battery_refresh (battery);
-    
-    battery->priv->sig_3 = g_signal_connect (G_OBJECT(battery->priv->device), "battery-changed",
-					     G_CALLBACK(xfpm_battery_device_changed_cb), battery);
-		      
-    battery->priv->sig_2 = g_signal_connect (G_OBJECT(battery->priv->conf), "notify::" SHOW_TRAY_ICON_CFG,
-					     G_CALLBACK(xfpm_battery_tray_icon_settings_changed), battery);
+    if ( type == XFPM_DEVICE_TYPE_BATTERY )
+    {
+	return g_strdup (XFPM_PRIMARY_ICON_PREFIX);
+    }
+    else if ( type == XFPM_DEVICE_TYPE_UPS ) 
+    {
+	return g_strdup (XFPM_UPS_ICON_PREFIX);
+    }
+    else if ( type == XFPM_DEVICE_TYPE_MOUSE ) 
+    {
+	return g_strdup (XFPM_MOUSE_ICON_PREFIX);
+    }
+    else if ( type == XFPM_DEVICE_TYPE_KBD ) 
+    {
+	return g_strdup (XFPM_KBD_ICON_PREFIX);
+    }
+    else if ( type == XFPM_DEVICE_TYPE_PHONE ) 
+    {
+	return g_strdup (XFPM_PHONE_ICON_PREFIX);
+    }
     
-    return battery;
+    return g_strdup (XFPM_PRIMARY_ICON_PREFIX);
 }
 
-const HalBattery*
-xfpm_battery_get_device (XfpmBattery *battery)
+GtkStatusIcon *
+xfpm_battery_new (void)
 {
-    g_return_val_if_fail (XFPM_IS_BATTERY(battery), NULL);
+    XfpmBattery *battery = NULL;
+    
+    battery = g_object_new (XFPM_TYPE_BATTERY, NULL);
     
-    return battery->priv->device;
+    return GTK_STATUS_ICON (battery);
 }
 
-XfpmBatteryState xfpm_battery_get_state (XfpmBattery *battery)
+void xfpm_battery_monitor_device (XfpmBattery *battery,
+				  DBusGProxy *proxy,
+				  DBusGProxy *proxy_prop,
+				  XfpmDeviceType device_type)
 {
-    g_return_val_if_fail (XFPM_IS_BATTERY(battery), BATTERY_NOT_PRESENT);
+    battery->priv->type = device_type;
+    battery->priv->proxy_prop = proxy_prop;
+    battery->priv->proxy = proxy;
+    battery->priv->icon_prefix = xfpm_battery_get_icon_prefix_device_enum_type (device_type);
     
-    return battery->priv->state;
+    dbus_g_proxy_add_signal (proxy, "Changed", G_TYPE_INVALID);
+    dbus_g_proxy_connect_signal (proxy, "Changed",
+				 G_CALLBACK (xfpm_battery_changed_cb), battery, NULL);
+
+    g_object_set (G_OBJECT (battery),
+		  "has-tooltip", TRUE,
+		  NULL);
+
+    xfpm_battery_changed_cb (proxy, battery);
 }
 
-GtkStatusIcon  *xfpm_battery_get_status_icon    (XfpmBattery *battery)
+XfpmDeviceType xfpm_battery_get_device_type (XfpmBattery *battery)
 {
-    g_return_val_if_fail (XFPM_IS_BATTERY(battery), NULL);
-    
-    return xfpm_tray_icon_get_tray_icon (battery->priv->icon);
+    g_return_val_if_fail (XFPM_IS_BATTERY (battery), XFPM_DEVICE_TYPE_UNKNOWN );
     
+    return battery->priv->type;
 }
 
-const gchar *xfpm_battery_get_icon_name (XfpmBattery *battery)
+XfpmBatteryCharge xfpm_battery_get_charge (XfpmBattery *battery)
 {
-    g_return_val_if_fail (XFPM_IS_BATTERY (battery), NULL);
+    g_return_val_if_fail (XFPM_IS_BATTERY (battery), XFPM_BATTERY_CHARGE_UNKNOWN);
     
-    return xfpm_tray_icon_get_icon_name (battery->priv->icon);
+    return battery->priv->charge;
 }
diff --git a/src/xfpm-battery.h b/src/xfpm-battery.h
index 02ab5a4..2d0728a 100644
--- a/src/xfpm-battery.h
+++ b/src/xfpm-battery.h
@@ -1,5 +1,5 @@
 /*
- * * Copyright (C) 2008 Ali <aliov at xfce.org>
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
  *
  * Licensed under the GNU General Public License Version 2
  *
@@ -23,46 +23,46 @@
 
 #include <glib-object.h>
 #include <gtk/gtk.h>
-
-#include "libxfpm/hal-battery.h"
+#include <dbus/dbus-glib.h>
 
 #include "xfpm-enum-glib.h"
-#include "xfpm-notify.h"
 
 G_BEGIN_DECLS
 
 #define XFPM_TYPE_BATTERY        (xfpm_battery_get_type () )
-#define XFPM_BATTERY(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_BATTERY, XfpmBattery))
-#define XFPM_IS_BATTERY(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_BATTERY))
+#define XFPM_BATTERY(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_BATTERY, XfpmBattery))
+#define XFPM_IS_BATTERY(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_BATTERY))
 
 typedef struct XfpmBatteryPrivate XfpmBatteryPrivate;
 
 typedef struct
 {
-    GObject		 parent;
-    XfpmBatteryPrivate	*priv;
+    GtkStatusIcon      	    parent;
+    
+    XfpmBatteryPrivate     *priv;
     
 } XfpmBattery;
 
 typedef struct
 {
-    GObjectClass         parent_class;
+    GtkStatusIconClass 	    parent_class;
+    
+    void		    (*battery_charge_changed)	 (XfpmBattery *battery);
     
-    void	        (*battery_state_changed)	(XfpmBattery *battery,
-    					            	 XfpmBatteryState state);
-       
 } XfpmBatteryClass;
 
-GType        		 xfpm_battery_get_type           (void) G_GNUC_CONST;
-XfpmBattery    		*xfpm_battery_new                (const HalBattery *device);
+GType        		    xfpm_battery_get_type        (void) G_GNUC_CONST;
 
-const HalBattery	*xfpm_battery_get_device         (XfpmBattery *battery) G_GNUC_PURE;
+GtkStatusIcon              *xfpm_battery_new             (void);
 
-XfpmBatteryState         xfpm_battery_get_state          (XfpmBattery *battery) G_GNUC_PURE;
+void			    xfpm_battery_monitor_device  (XfpmBattery *battery,
+							  DBusGProxy *proxy,
+							  DBusGProxy *proxy_prop,
+							  XfpmDeviceType device_type);
 
-GtkStatusIcon  		*xfpm_battery_get_status_icon    (XfpmBattery *battery);
+XfpmDeviceType	   	    xfpm_battery_get_device_type (XfpmBattery *battery);
 
-const gchar    		*xfpm_battery_get_icon_name      (XfpmBattery *battery) G_GNUC_PURE;
+XfpmBatteryCharge	    xfpm_battery_get_charge      (XfpmBattery *battery);
 
 G_END_DECLS
 
diff --git a/src/xfpm-brightness-hal.c b/src/xfpm-brightness-hal.c
deleted file mode 100644
index 0b0c7d3..0000000
--- a/src/xfpm-brightness-hal.c
+++ /dev/null
@@ -1,594 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <dbus/dbus-glib.h>
-
-#include <libxfce4util/libxfce4util.h>
-#include <xfconf/xfconf.h>
-
-#include "libxfpm/hal-manager.h"
-#include "libxfpm/hal-device.h"
-#include "libxfpm/xfpm-string.h"
-
-#include "xfpm-brightness-hal.h"
-#include "xfpm-button.h"
-#include "xfpm-enum-glib.h"
-#include "xfpm-xfconf.h"
-#include "egg-idletime.h"
-#include "xfpm-config.h"
-#include "xfpm-adapter.h"
-#include "xfpm-screen-saver.h"
-
-static void xfpm_brightness_hal_finalize   (GObject *object);
-
-#define XFPM_BRIGHTNESS_HAL_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_BRIGHTNESS_HAL, XfpmBrightnessHalPrivate))
-
-#define ALARM_DISABLED 9
-
-struct XfpmBrightnessHalPrivate
-{
-    DBusGProxy      *proxy;
-    
-    XfpmXfconf      *conf;
-    EggIdletime     *idle;
-    XfpmButton      *button;
-    XfpmAdapter     *adapter;
-    XfpmScreenSaver *saver;
-    
-    guint           max_level;
-    guint           hw_level;
-    guint           step;
-    gboolean        brightness_in_hw;
-    gboolean        hw_found;
-    gboolean        block;
-    gboolean        inhibited;
-    
-    gboolean        on_battery;
-    
-    gulong	    sig[6];
-};
-
-enum
-{
-    BRIGHTNESS_UP,
-    BRIGHTNESS_DOWN,
-    LAST_SIGNAL
-};
-
-static guint signals [LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(XfpmBrightnessHal, xfpm_brightness_hal, G_TYPE_OBJECT)
-
-static gint 
-xfpm_brightness_hal_get_level (XfpmBrightnessHal *brg, GError **error)
-{
-    gint level = 0;
-    gboolean ret = FALSE;
-    
-    ret = dbus_g_proxy_call (brg->priv->proxy, "GetBrightness", error,
-	 		     G_TYPE_INVALID,
-			     G_TYPE_INT, &level,
-			     G_TYPE_INVALID);
-
-    if (!ret)
-    {
-	g_warning("GetBrightness failed\n");
-    }
-    return level;
-}
-
-static gboolean
-xfpm_brightness_hal_set_level (XfpmBrightnessHal *brg, gint level)
-{
-    GError *error = NULL;
-    gboolean ret = FALSE;
-    gint dummy;
-    
-    TRACE ("Setting level %d", level);
-    
-    ret = dbus_g_proxy_call (brg->priv->proxy, "SetBrightness", &error,
-			     G_TYPE_INT, level,
-			     G_TYPE_INVALID,
-			     G_TYPE_INT, &dummy, /* Just to avoid a warning! */
-			     G_TYPE_INVALID );
-		       
-    if ( error )
-    {
-	g_critical ("Error setting brightness level: %s\n", error->message);
-	g_error_free (error);
-	return FALSE;
-    }
-    
-    if (!ret)
-    {
-	g_warning("SetBrightness failed\n");
-    }
-    
-    return TRUE;
-}
-
-static void
-xfpm_brightness_hal_set_proxy (XfpmBrightnessHal *brg, const gchar *udi)
-{
-    DBusGConnection *bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
-    
-    brg->priv->hw_found = TRUE;
-    
-    brg->priv->proxy = dbus_g_proxy_new_for_name (bus,
-		   			          "org.freedesktop.Hal",
-						  udi,
-					          "org.freedesktop.Hal.Device.LaptopPanel");
-     
-    if ( !brg->priv->proxy )
-	g_warning ("Unable to get proxy for device %s\n", udi);
-}
-
-static void
-xfpm_brightness_hal_get_device (XfpmBrightnessHal *brg, const gchar *udi)
-{
-    HalDevice *device = hal_device_new ();
-    hal_device_set_udi (device, udi);
-
-    brg->priv->max_level = 
-	hal_device_get_property_int (device, "laptop_panel.num_levels") -1;
-    
-    brg->priv->step = brg->priv->max_level <= 20 ? 1 : brg->priv->max_level / 20;
-    
-    if ( hal_device_has_key (device, "laptop_panel.brightness_in_hardware") )
-	brg->priv->brightness_in_hw = hal_device_get_property_bool (device ,"laptop_panel.brightness_in_hardware");
-	
-    TRACE ("laptop_panel.num_levels=%d\n", brg->priv->max_level);
-    
-    g_object_unref (device);
-}
-
-static void
-xfpm_brightness_hal_read_hal_level (XfpmBrightnessHal *brg)
-{
-    GError *error = NULL;
-    
-    brg->priv->hw_level = xfpm_brightness_hal_get_level (brg, &error);
-   
-    if ( error )
-    {
-	g_warning ("Error getting brightness level: %s\n", error->message);
-	g_error_free (error);
-    }
-}
-
-static gboolean
-xfpm_brightness_hal_setup (XfpmBrightnessHal *brg)
-{
-    gchar **udi = NULL;
-
-    HalManager *manager = hal_manager_new ();
-    
-    udi = hal_manager_find_device_by_capability (manager, "laptop_panel");
-    
-    if ( !udi || !udi[0])
-    {
-	g_object_unref ( manager);
-    	return FALSE;
-    }
-	
-    TRACE ("Found laptop_panel with udi=%s\n", udi[0]);
-    xfpm_brightness_hal_get_device (brg, udi[0]);
-    xfpm_brightness_hal_set_proxy (brg, udi[0]);
-
-    xfpm_brightness_hal_read_hal_level (brg);
-    
-    TRACE ("Current hw level =%d\n", brg->priv->hw_level);
-    
-    hal_manager_free_string_array (udi);
-    return TRUE;
-}
-
-static void
-xfpm_brightness_hal_up (XfpmBrightnessHal *brg)
-{
-    gboolean show_popup;
-    gboolean enable_brightness;
-    
-    g_object_get (G_OBJECT (brg->priv->conf),
-		  ENABLE_BRIGHTNESS_CONTROL, &enable_brightness,
-		  SHOW_BRIGHTNESS_POPUP, &show_popup,
-		  NULL);
-    
-    if ( enable_brightness == FALSE || brg->priv->brightness_in_hw)
-	goto signal;
-	
-    if ( brg->priv->hw_level <= brg->priv->max_level -1 )
-    {
-	TRACE ("Brightness key up");
-	xfpm_brightness_hal_set_level (brg, brg->priv->hw_level + brg->priv->step );
-    }
-    
-signal:
-    xfpm_brightness_hal_read_hal_level (brg);
-    
-    if ( show_popup )
-	g_signal_emit (G_OBJECT (brg), signals [BRIGHTNESS_UP], 0, brg->priv->hw_level);
-}
-
-static void
-xfpm_brightness_hal_down (XfpmBrightnessHal *brg)
-{
-    gboolean show_popup, enable_brightness;
-    
-    g_object_get (G_OBJECT (brg->priv->conf),
-		  ENABLE_BRIGHTNESS_CONTROL, &enable_brightness,
-		  SHOW_BRIGHTNESS_POPUP, &show_popup,
-		  NULL);
-    
-    if ( enable_brightness == FALSE || brg->priv->brightness_in_hw)
-	goto signal;
-	
-    if ( brg->priv->hw_level != 0)
-    {
-	TRACE("Brightness key down");
-	xfpm_brightness_hal_set_level (brg, brg->priv->hw_level - brg->priv->step );
-    }
-    
-signal:
-    xfpm_brightness_hal_read_hal_level (brg);
-    
-    if ( show_popup )
-	g_signal_emit (G_OBJECT (brg), signals [BRIGHTNESS_UP], 0, brg->priv->hw_level);
-}
-
-static void
-xfpm_brightness_hal_button_pressed_cb (XfpmButton *button, XfpmButtonKey type, XfpmBrightnessHal *brg)
-{
-    if ( type == BUTTON_MON_BRIGHTNESS_UP )
-    {
-	brg->priv->block = TRUE;
-	xfpm_brightness_hal_up (brg);
-    }
-    else if ( type == BUTTON_MON_BRIGHTNESS_DOWN )
-    {
-	brg->priv->block = TRUE;
-	xfpm_brightness_hal_down (brg);
-    }
-}
-
-static void
-xfpm_brightness_hal_reset_cb (EggIdletime *idle, XfpmBrightnessHal *brg)
-{
-    GError *error = NULL;
-    guint level;
-    
-    if (brg->priv->block)
-	return;
-    
-    if ( brg->priv->inhibited )
-	return;
-    
-    level = xfpm_brightness_hal_get_level (brg, &error);
-     
-    if ( error )
-    {
-	g_warning ("Error getting brightness level: %s\n", error->message);
-	g_error_free (error);
-	return;
-    }
-     
-    if ( level != brg->priv->hw_level && level != 0)
-    {
-	TRACE("Resetting brightness level to %d", brg->priv->hw_level);
-	xfpm_brightness_hal_set_level(brg, brg->priv->hw_level);
-    }
-}
-
-static void
-xfpm_brightness_timeout_on_ac (XfpmBrightnessHal *brg)
-{
-    GError *error = NULL;
-    guint level;
-    
-    if ( brg->priv->on_battery )
-	    return;
-    
-    level = xfpm_brightness_hal_get_level (brg, &error);
-    
-    brg->priv->hw_level = level;
-    
-    if ( error )
-    {
-	g_warning ("Error getting brightness level: %s\n", error->message);
-	g_error_free (error);
-	return;
-    }
-    
-    if ( level != 0 && level != brg->priv->step )
-    {
-	TRACE ("Reducing brightness, on AC power\n");
-	xfpm_brightness_hal_set_level(brg, brg->priv->step);
-    }
-}
-
-static void
-xfpm_brightness_timeout_on_battery (XfpmBrightnessHal *brg)
-{
-    GError *error = NULL;
-    guint level;
-    
-    if ( !brg->priv->on_battery )
-	    return;
-    
-    level = xfpm_brightness_hal_get_level (brg, &error);
-    
-    brg->priv->hw_level = level;
-    
-    if ( error )
-    {
-	g_warning ("Error getting brightness level: %s\n", error->message);
-	g_error_free (error);
-	return;
-    }
-    
-    if ( level != 0 && level != brg->priv->step )
-    {
-	xfpm_brightness_hal_set_level(brg, brg->priv->step);
-	TRACE ("Reducing brightness, on battery power\n");
-    }
-}
-
-static void
-xfpm_brightness_hal_alarm_timeout_cb (EggIdletime *idle, guint id, XfpmBrightnessHal *brg)
-{
-    if ( brg->priv->block )
-	brg->priv->block = FALSE;
-    
-    if ( brg->priv->inhibited )
-	return;
-    
-    id == TIMEOUT_BRIGHTNESS_ON_AC ? xfpm_brightness_timeout_on_ac (brg) :
-			     xfpm_brightness_timeout_on_battery (brg);
-}
-
-static void
-xfpm_brightness_hal_adapter_changed_cb (XfpmAdapter *adapter, gboolean present, XfpmBrightnessHal *brg)
-{
-    brg->priv->on_battery = !present;
-}
-
-static void
-xfpm_brightness_hal_inhibit_changed_cb (XfpmScreenSaver *saver, gboolean inhibited, XfpmBrightnessHal *brg)
-{
-    TRACE("Inhibit changed %s", xfpm_bool_to_string (inhibited));
-    brg->priv->inhibited = inhibited;
-}
-
-static void
-xfpm_brightness_get_user_timeouts (XfpmBrightnessHal *brg, guint *timeout_on_ac, guint *timeout_on_battery)
-{
-    g_object_get (G_OBJECT (brg->priv->conf),
-		  BRIGHTNESS_ON_AC, timeout_on_ac,
-		  BRIGHTNESS_ON_BATTERY, timeout_on_battery,
-		  NULL);
-}
-
-static void
-xfpm_brightness_hal_set_timeouts (XfpmBrightnessHal *brg )
-{
-    guint timeout_on_ac, timeout_on_battery ;
-    
-    xfpm_brightness_get_user_timeouts (brg, &timeout_on_ac, &timeout_on_battery);
-    
-    if ( timeout_on_ac == ALARM_DISABLED )
-    {
-	egg_idletime_alarm_remove (brg->priv->idle, TIMEOUT_BRIGHTNESS_ON_AC );
-    }
-    else
-    {
-	egg_idletime_alarm_set (brg->priv->idle, TIMEOUT_BRIGHTNESS_ON_AC, timeout_on_ac * 1000);
-    }
-    
-    if ( timeout_on_battery == ALARM_DISABLED )
-    {
-	egg_idletime_alarm_remove (brg->priv->idle, TIMEOUT_BRIGHTNESS_ON_BATTERY );
-    }
-    else
-    {
-	egg_idletime_alarm_set (brg->priv->idle, TIMEOUT_BRIGHTNESS_ON_BATTERY, timeout_on_battery * 1000);
-    }
-    
-    egg_idletime_alarm_reset_all (brg->priv->idle);
-}
-
-static void
-xfpm_brightness_hal_settings_changed_cb (GObject *objm, GParamSpec *spec, XfpmBrightnessHal *brg)
-{
-    if ( g_str_has_prefix (spec->name, "brightness") )
-    {
-	TRACE ("User settings changed");
-	xfpm_brightness_hal_set_timeouts (brg);
-    }
-}
-
-static void
-xfpm_brightness_hal_class_init(XfpmBrightnessHalClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-     signals [BRIGHTNESS_UP] = 
-        g_signal_new("brigthness-up",
-                      XFPM_TYPE_BRIGHTNESS_HAL,
-                      G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET (XfpmBrightnessHalClass, brightness_up),
-                      NULL, NULL,
-                      g_cclosure_marshal_VOID__UINT,
-                      G_TYPE_NONE, 1, G_TYPE_UINT);
-
-    signals [BRIGHTNESS_DOWN] = 
-        g_signal_new("brigthness-down",
-                      XFPM_TYPE_BRIGHTNESS_HAL,
-                      G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET (XfpmBrightnessHalClass, brightness_down),
-                      NULL, NULL,
-                      g_cclosure_marshal_VOID__UINT,
-                      G_TYPE_NONE, 1, G_TYPE_UINT);
-
-    object_class->finalize = xfpm_brightness_hal_finalize;
-
-    g_type_class_add_private (klass, sizeof (XfpmBrightnessHalPrivate));
-}
-
-static void
-xfpm_brightness_hal_init(XfpmBrightnessHal *brg)
-{
-    brg->priv = XFPM_BRIGHTNESS_HAL_GET_PRIVATE(brg);
-    
-    brg->priv->proxy    	= NULL;
-    brg->priv->idle             = NULL;
-    brg->priv->hw_found 	= FALSE;
-    brg->priv->on_battery       = FALSE;
-    brg->priv->block            = FALSE;
-    brg->priv->brightness_in_hw = FALSE;
-    brg->priv->max_level        = 0;
-    brg->priv->inhibited        = FALSE;
-    
-    xfpm_brightness_hal_setup (brg);
-
-    if ( brg->priv->hw_found && brg->priv->max_level > 0 )
-    {
-	brg->priv->idle     = egg_idletime_new ();
-	brg->priv->conf     = xfpm_xfconf_new ();
-	brg->priv->button   = xfpm_button_new ();
-	brg->priv->adapter  = xfpm_adapter_new ();
-	brg->priv->saver    = xfpm_screen_saver_new ();
-	
-	brg->priv->sig[0] =
-	g_signal_connect (brg->priv->saver, "screen-saver-inhibited",
-			  G_CALLBACK(xfpm_brightness_hal_inhibit_changed_cb), brg);
-	
-	brg->priv->on_battery = !xfpm_adapter_get_present (brg->priv->adapter);
-	
-	brg->priv->sig[1] =
-	g_signal_connect (brg->priv->adapter, "adapter-changed",
-			  G_CALLBACK(xfpm_brightness_hal_adapter_changed_cb), brg);
-	
-	brg->priv->sig[2] =
-	g_signal_connect (brg->priv->button, "button-pressed",	
-			  G_CALLBACK(xfpm_brightness_hal_button_pressed_cb), brg);
-	
-	brg->priv->sig[3] =
-	g_signal_connect (brg->priv->idle, "alarm-expired",
-			  G_CALLBACK(xfpm_brightness_hal_alarm_timeout_cb), brg);
-	
-	brg->priv->sig[4] =
-	g_signal_connect (brg->priv->idle, "reset",
-			  G_CALLBACK(xfpm_brightness_hal_reset_cb), brg);
-			
-	brg->priv->sig[5] =
-	g_signal_connect (brg->priv->conf, "notify", 
-			  G_CALLBACK(xfpm_brightness_hal_settings_changed_cb), brg);
-			  
-	xfpm_brightness_hal_set_timeouts (brg);
-    }
-    else
-    {
-	TRACE("No lcd brightness control found in the system");
-    }
-}
-
-static void
-xfpm_brightness_hal_finalize (GObject *object)
-{
-    XfpmBrightnessHal *brg;
-
-    brg = XFPM_BRIGHTNESS_HAL(object);
-    
-    if ( brg->priv->saver && g_signal_handler_is_connected (brg->priv->saver, brg->priv->sig[0]) )
-	g_signal_handler_disconnect (G_OBJECT (brg->priv->saver), brg->priv->sig[0]);
-    
-    if ( brg->priv->adapter && g_signal_handler_is_connected (brg->priv->adapter, brg->priv->sig[1]) )
-	g_signal_handler_disconnect (G_OBJECT (brg->priv->adapter), brg->priv->sig[1]);
-    
-    if ( brg->priv->button && g_signal_handler_is_connected (brg->priv->button, brg->priv->sig[2]) )
-	g_signal_handler_disconnect (G_OBJECT (brg->priv->button), brg->priv->sig[2]);
-	
-    if ( brg->priv->idle && g_signal_handler_is_connected (brg->priv->idle, brg->priv->sig[3]) )
-	g_signal_handler_disconnect (G_OBJECT (brg->priv->idle), brg->priv->sig[3]);
-	
-    if ( brg->priv->idle && g_signal_handler_is_connected (brg->priv->idle, brg->priv->sig[4]) )
-	g_signal_handler_disconnect (G_OBJECT (brg->priv->idle), brg->priv->sig[4]);
-    
-    if ( brg->priv->conf && g_signal_handler_is_connected (brg->priv->conf, brg->priv->sig[5]) )
-	g_signal_handler_disconnect (G_OBJECT (brg->priv->conf), brg->priv->sig[5]);
-	
-    if ( brg->priv->proxy )
-	g_object_unref (brg->priv->proxy);
-
-    if ( brg->priv->conf )
-	g_object_unref (brg->priv->conf);
-	
-    if ( brg->priv->adapter)
-	g_object_unref (brg->priv->adapter);
-	
-    if ( brg->priv->saver )
-	g_object_unref (brg->priv->saver);
-    
-    if ( brg->priv->idle )
-	g_object_unref (brg->priv->idle);
-	
-    if ( brg->priv->button)
-	g_object_unref (brg->priv->button);
-	
-    G_OBJECT_CLASS(xfpm_brightness_hal_parent_class)->finalize(object);
-}
-
-XfpmBrightnessHal *
-xfpm_brightness_hal_new (void)
-{
-    XfpmBrightnessHal *brg = NULL;
-    brg = g_object_new (XFPM_TYPE_BRIGHTNESS_HAL, NULL);
-    return brg;
-}
-
-gboolean xfpm_brightness_hal_has_hw (XfpmBrightnessHal *brg)
-{
-    g_return_val_if_fail (XFPM_IS_BRIGHTNESS_HAL (brg), FALSE);
-    
-    return brg->priv->hw_found;
-}
-
-void xfpm_brightness_hal_update_level (XfpmBrightnessHal *brg, guint level)
-{
-    g_return_if_fail (XFPM_IS_BRIGHTNESS_HAL (brg));
-    
-    brg->priv->hw_level = level;
-}
-
-guint xfpm_brightness_hal_get_max_level (XfpmBrightnessHal *brg)
-{
-    g_return_val_if_fail (XFPM_IS_BRIGHTNESS_HAL (brg), 0);
-    
-    return brg->priv->max_level;
-}
diff --git a/src/xfpm-brightness-hal.h b/src/xfpm-brightness-hal.h
deleted file mode 100644
index b574677..0000000
--- a/src/xfpm-brightness-hal.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __XFPM_BRIGHTNESS_HAL_H
-#define __XFPM_BRIGHTNESS_HAL_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_BRIGHTNESS_HAL        (xfpm_brightness_hal_get_type () )
-#define XFPM_BRIGHTNESS_HAL(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_BRIGHTNESS_HAL, XfpmBrightnessHal))
-#define XFPM_IS_BRIGHTNESS_HAL(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_BRIGHTNESS_HAL))
-
-typedef struct XfpmBrightnessHalPrivate XfpmBrightnessHalPrivate;
-
-typedef struct
-{
-    GObject		 		parent;
-    XfpmBrightnessHalPrivate	       *priv;
-    
-} XfpmBrightnessHal;
-
-typedef struct
-{
-    GObjectClass 			parent_class;
-    
-    void                                (*brightness_up)		    (XfpmBrightnessHal *brg,
-									     guint level);
-									     
-    void                                (*brightness_down)		    (XfpmBrightnessHal *brg,
-									     guint level);
-    
-} XfpmBrightnessHalClass;
-
-GType        				xfpm_brightness_hal_get_type        (void) G_GNUC_CONST;
-XfpmBrightnessHal      		       *xfpm_brightness_hal_new             (void);
-
-gboolean                                xfpm_brightness_hal_has_hw          (XfpmBrightnessHal *brg) G_GNUC_PURE;
-
-void                                    xfpm_brightness_hal_update_level    (XfpmBrightnessHal *brg,
-									     guint level);
-
-guint                                   xfpm_brightness_hal_get_max_level   (XfpmBrightnessHal *brg) G_GNUC_PURE;									     
-G_END_DECLS
-
-#endif /* __XFPM_BRIGHTNESS_HAL_H */
diff --git a/src/xfpm-brightness-widget.c b/src/xfpm-brightness-widget.c
deleted file mode 100644
index 6f90240..0000000
--- a/src/xfpm-brightness-widget.c
+++ /dev/null
@@ -1,352 +0,0 @@
-/* * 
- *  Copyright (C) 2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <math.h>
-
-#include <gtk/gtk.h>
-#include <glib.h>
-#include <cairo.h>
-
-#include <libnotify/notify.h>
-
-#include <libxfce4util/libxfce4util.h>
-
-#include "libxfpm/xfpm-common.h"
-
-#include "xfpm-brightness-widget.h"
-#include "xfpm-dbus-monitor.h"
-
-static void xfpm_brightness_widget_finalize   (GObject *object);
-
-#define XFPM_BRIGHTNESS_WIDGET_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_BRIGHTNESS_WIDGET, XfpmBrightnessWidgetPrivate))
-
-#define BRIGHTNESS_POPUP_SIZE	180
-
-struct XfpmBrightnessWidgetPrivate
-{
-    XfpmDBusMonitor     *monitor;
-    GtkWidget 		*window;
-    GtkWidget           *progress_bar;
-    
-    guint      		 level;
-    guint      		 max_level;
-    gulong     		 timeout_id;
-    gulong		 destroy_id;
-    
-    gboolean		 check_server_caps;
-    gboolean		 notify_osd;
-    NotifyNotification	*n;
-    
-    gulong		 sig_1;
-};
-
-G_DEFINE_TYPE (XfpmBrightnessWidget, xfpm_brightness_widget, G_TYPE_OBJECT)
-
-static void
-xfpm_brightness_widget_service_connection_changed_cb (XfpmDBusMonitor *monitor, gchar *service_name, 
-						      gboolean connected, gboolean on_session,
-						      XfpmBrightnessWidget *widget)
-{
-    if ( !g_strcmp0 (service_name, "org.freedesktop.Notifications")  && on_session )
-    {
-	if ( connected )
-	    widget->priv->check_server_caps = TRUE;
-	else
-	    widget->priv->notify_osd = FALSE;
-    }
-}
-
-static gboolean
-xfpm_brightness_widget_server_is_notify_osd (void)
-{
-    gboolean supports_sync = FALSE;
-    GList *caps = NULL;
-
-    caps = notify_get_server_caps ();
-    if (caps != NULL) 
-    {
-	if (g_list_find_custom (caps, "x-canonical-private-synchronous", (GCompareFunc) g_strcmp0) != NULL)
-	    supports_sync = TRUE;
-
-	    g_list_foreach(caps, (GFunc)g_free, NULL);
-	    g_list_free(caps);
-    }
-
-    return supports_sync;
-}
-
-static void
-xfpm_brightness_widget_display_notification (XfpmBrightnessWidget *widget)
-{
-    guint i;
-    gfloat value = 0;
-    
-    static const char *display_icon_name[] = 
-    {
-	"notification-display-brightness-off",
-	"notification-display-brightness-low",
-	"notification-display-brightness-medium",
-	"notification-display-brightness-high",
-	"notification-display-brightness-full",
-	NULL
-    };
-    
-    value = (gfloat) 100 * widget->priv->level / widget->priv->max_level;
-    
-    i = (gint)value / 25;
-    
-    notify_notification_set_hint_int32 (widget->priv->n,
-					"value",
-					 value);
-    
-    notify_notification_set_hint_string (widget->priv->n,
-					 "x-canonical-private-synchronous",
-					 "brightness");
-					 
-    notify_notification_update (widget->priv->n,
-			        " ",
-				"",
-				display_icon_name[i]);
-				
-    notify_notification_show (widget->priv->n, NULL);
-}
-
-static gboolean
-xfpm_brightness_widget_timeout (XfpmBrightnessWidget *widget)
-{
-    gtk_widget_hide (widget->priv->window);
-    return FALSE;
-}
-
-static void
-xfpm_brightness_widget_create_popup (XfpmBrightnessWidget *widget)
-{
-    GtkWidget *vbox;
-    GtkWidget *img;
-    GtkWidget *align;
-    GtkObject *adj;
-    
-    if ( widget->priv->window != NULL )
-	return;
-	
-    widget->priv->window = gtk_window_new (GTK_WINDOW_POPUP);
-
-    g_object_set (G_OBJECT (widget->priv->window), 
-		  "window-position", GTK_WIN_POS_CENTER_ALWAYS,
-		  "decorated", FALSE,
-		  "resizable", FALSE,
-		  "type-hint", GDK_WINDOW_TYPE_HINT_UTILITY,
-		  "app-paintable", TRUE,
-		  NULL);
-
-    gtk_window_set_default_size (GTK_WINDOW (widget->priv->window), BRIGHTNESS_POPUP_SIZE, BRIGHTNESS_POPUP_SIZE);
-    
-    align = gtk_alignment_new (0., 0.5, 0, 0);
-    gtk_alignment_set_padding (GTK_ALIGNMENT (align), 5, 5, 5, 5);
-    
-    vbox = gtk_vbox_new (FALSE, 0);
-    
-    gtk_container_add (GTK_CONTAINER (widget->priv->window), align);
-    gtk_container_add (GTK_CONTAINER (align), vbox);
-    
-    img = gtk_image_new_from_icon_name ("xfpm-brightness-lcd", GTK_ICON_SIZE_DIALOG);
-    
-    gtk_box_pack_start (GTK_BOX (vbox), img, TRUE, TRUE, 0);
-    
-    widget->priv->progress_bar = gtk_progress_bar_new ();
-    
-    adj = gtk_adjustment_new (0., 0., widget->priv->max_level, 1., 0., 0.);
-
-    g_object_set (G_OBJECT (widget->priv->progress_bar),
-		  "adjustment", adj,
-		  NULL);
-    
-    gtk_box_pack_start (GTK_BOX (vbox), widget->priv->progress_bar, TRUE, TRUE, 0);
-    
-    gtk_widget_show_all (align);
-}
-
-static void
-xfpm_brightness_widget_create_notification (XfpmBrightnessWidget *widget)
-{
-    if ( widget->priv->n == NULL )
-    {
-	widget->priv->n = notify_notification_new (" ",
-						   "",
-					           NULL,
-					           NULL);
-    }
-}
-
-static gboolean
-xfpm_brightness_widget_destroy (gpointer data)
-{
-    XfpmBrightnessWidget *widget;
-    
-    widget = XFPM_BRIGHTNESS_WIDGET (data);
-    
-    if ( widget->priv->window )
-    {
-	gtk_widget_destroy (widget->priv->window);
-	widget->priv->window = NULL;
-    }
-    
-    
-    if ( widget->priv->n )
-    {
-	g_object_unref (widget->priv->n);
-	widget->priv->n = NULL;
-    }
-    
-    return FALSE;
-}
-
-static void
-xfpm_brightness_widget_class_init (XfpmBrightnessWidgetClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-    object_class->finalize = xfpm_brightness_widget_finalize;
-    
-    g_type_class_add_private (klass, sizeof (XfpmBrightnessWidgetPrivate));
-}
-
-static void
-xfpm_brightness_widget_init (XfpmBrightnessWidget *widget)
-{
-    widget->priv = XFPM_BRIGHTNESS_WIDGET_GET_PRIVATE (widget);
-    
-    widget->priv->monitor = xfpm_dbus_monitor_new ();
-    
-    widget->priv->level  = 0;
-    widget->priv->max_level = 0;
-    widget->priv->timeout_id = 0;
-    widget->priv->destroy_id = 0;
-    widget->priv->notify_osd = FALSE;
-    widget->priv->check_server_caps = TRUE;
-    widget->priv->window = NULL;
-    widget->priv->progress_bar = NULL;
-    widget->priv->n = NULL;
-    
-    xfpm_dbus_monitor_add_service (widget->priv->monitor, 
-				   DBUS_BUS_SESSION,
-				   "org.freedesktop.Notifications");
-    
-    widget->priv->sig_1 = g_signal_connect (widget->priv->monitor, "service-connection-changed",
-					    G_CALLBACK (xfpm_brightness_widget_service_connection_changed_cb),
-					    widget);
-}
-
-static void
-xfpm_brightness_widget_finalize (GObject *object)
-{
-    XfpmBrightnessWidget *widget;
-
-    widget = XFPM_BRIGHTNESS_WIDGET (object);
-    
-    if ( g_signal_handler_is_connected (G_OBJECT (widget->priv->monitor), widget->priv->sig_1) )
-	g_signal_handler_disconnect (G_OBJECT (widget->priv->monitor), widget->priv->sig_1);
-	
-    xfpm_brightness_widget_destroy (widget);
-    
-    g_object_unref (widget->priv->monitor);
-
-    G_OBJECT_CLASS (xfpm_brightness_widget_parent_class)->finalize (object);
-}
-
-static void
-xfpm_brightness_widget_show (XfpmBrightnessWidget *widget)
-{
-    if ( widget->priv->notify_osd )
-    {
-	xfpm_brightness_widget_create_notification (widget);
-	xfpm_brightness_widget_display_notification (widget);
-    }
-    else
-    {
-	GtkAdjustment *adj;
-	
-	xfpm_brightness_widget_create_popup (widget);
-	g_object_get (G_OBJECT (widget->priv->progress_bar),
-		      "adjustment", &adj,
-		      NULL);
-	
-	gtk_adjustment_set_value (adj, widget->priv->level);
-	
-	if ( !GTK_WIDGET_VISIBLE (widget->priv->window))
-	    gtk_window_present (GTK_WINDOW (widget->priv->window));
-	
-	if ( widget->priv->timeout_id != 0 )
-	    g_source_remove (widget->priv->timeout_id);
-	    
-	widget->priv->timeout_id = 
-	    g_timeout_add (900, (GSourceFunc) xfpm_brightness_widget_timeout, widget);
-    }
-    
-    if ( widget->priv->destroy_id != 0 )
-    {
-	g_source_remove (widget->priv->destroy_id);
-	widget->priv->destroy_id = 0;
-    }
-    
-    /* Release the memory after 60 seconds */
-    widget->priv->destroy_id = g_timeout_add_seconds (60, (GSourceFunc) xfpm_brightness_widget_destroy, widget);
-}
-    
-
-XfpmBrightnessWidget *
-xfpm_brightness_widget_new (void)
-{
-    XfpmBrightnessWidget *widget = NULL;
-    widget = g_object_new (XFPM_TYPE_BRIGHTNESS_WIDGET, NULL);
-
-    return widget;
-}
-
-void xfpm_brightness_widget_set_max_level (XfpmBrightnessWidget *widget, guint level)
-{
-    g_return_if_fail (XFPM_IS_BRIGHTNESS_WIDGET (widget));
-
-    widget->priv->max_level = level;
-}
-
-void xfpm_brightness_widget_set_level (XfpmBrightnessWidget *widget, guint level)
-{
-    g_return_if_fail (XFPM_IS_BRIGHTNESS_WIDGET (widget));
-    
-    widget->priv->level = level;
-
-    if ( widget->priv->check_server_caps )
-    {
-	widget->priv->notify_osd = xfpm_brightness_widget_server_is_notify_osd ();
-	widget->priv->check_server_caps = FALSE;
-    }
-    
-    xfpm_brightness_widget_show (widget);
-}
diff --git a/src/xfpm-brightness-widget.h b/src/xfpm-brightness-widget.h
deleted file mode 100644
index 8b861fe..0000000
--- a/src/xfpm-brightness-widget.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* * 
- *  Copyright (C) 2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __XFPM_BRIGHTNESS_WIDGET_H
-#define __XFPM_BRIGHTNESS_WIDGET_H
-
-#include <gtk/gtk.h>
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_BRIGHTNESS_WIDGET        (xfpm_brightness_widget_get_type () )
-#define XFPM_BRIGHTNESS_WIDGET(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_BRIGHTNESS_WIDGET, XfpmBrightnessWidget))
-#define XFPM_IS_BRIGHTNESS_WIDGET(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_BRIGHTNESS_WIDGET))
-
-typedef struct XfpmBrightnessWidgetPrivate XfpmBrightnessWidgetPrivate;
-
-typedef struct
-{
-    GObject         		     parent;
-    XfpmBrightnessWidgetPrivate     *priv;
-    
-} XfpmBrightnessWidget;
-
-typedef struct
-{
-    GObjectClass 		     parent_class;
-    
-} XfpmBrightnessWidgetClass;
-
-GType        		   	     xfpm_brightness_widget_get_type      (void) G_GNUC_CONST;
-
-XfpmBrightnessWidget   	            *xfpm_brightness_widget_new           (void);
-
-void				     xfpm_brightness_widget_set_max_level (XfpmBrightnessWidget *widget, 
-									   guint level);
-
-void                        	     xfpm_brightness_widget_set_level     (XfpmBrightnessWidget *widget,
-									   guint level);
-
-G_END_DECLS
-
-#endif /* __XFPM_BRIGHTNESS_WIDGET_H */
diff --git a/src/xfpm-button-hal.c b/src/xfpm-button-hal.c
deleted file mode 100644
index db6cbfb..0000000
--- a/src/xfpm-button-hal.c
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * * Copyright (C) 2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <glib.h>
-
-#include <libxfce4util/libxfce4util.h>
-
-#include "libxfpm/hal-manager.h"
-#include "libxfpm/hal-device.h"
-
-#include "libxfpm/xfpm-string.h"
-
-#include "xfpm-button-hal.h"
-#include "xfpm-enum.h"
-#include "xfpm-enum-types.h"
-
-static void xfpm_button_hal_finalize   (GObject *object);
-
-#define XFPM_BUTTON_HAL_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_BUTTON_HAL, XfpmButtonHalPrivate))
-
-struct XfpmButtonHalPrivate
-{
-    GPtrArray  *array;
-    guint8 	keys;
-    guint8      mapped_keys;
-};
-
-enum
-{
-    HAL_BUTTON_PRESSED,
-    LID_EVENT,
-    LAST_SIGNAL
-};
-
-static guint signals [LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE (XfpmButtonHal, xfpm_button_hal, G_TYPE_OBJECT)
-
-static void
-xfpm_button_hal_emit_signals (XfpmButtonHal *bt, const gchar *condition, const gchar *detail)
-{
-    if ( !xfpm_strequal (condition, "ButtonPressed") )
-	return;
-
-    if ( xfpm_strequal (detail, "power") )
-    {
-	if ( bt->priv->mapped_keys & POWER_KEY )
-	{
-	    TRACE ("Emitting signal button press condition %s detail %s", condition, detail);
-	    g_signal_emit (G_OBJECT (bt), signals [HAL_BUTTON_PRESSED], 0, BUTTON_POWER_OFF);
-	}
-    }
-    else if ( ( xfpm_strequal (detail, "sleep")  || xfpm_strequal (detail, "suspend") ) && !(bt->priv->keys & SLEEP_KEY) )
-    {
-	if ( bt->priv->mapped_keys & SLEEP_KEY )
-	{
-	    TRACE ("Emitting signal button press condition %s detail %s", condition, detail);
-	    g_signal_emit (G_OBJECT (bt), signals [HAL_BUTTON_PRESSED], 0, BUTTON_SLEEP);
-	}
-    }
-    else if ( xfpm_strequal (detail, "hibernate") && !(bt->priv->keys & HIBERNATE_KEY) )
-    {
-	if ( bt->priv->mapped_keys & HIBERNATE_KEY )
-	{
-	    TRACE ("Emitting signal button press condition %s detail %s", condition, detail);
-	    g_signal_emit (G_OBJECT (bt), signals [HAL_BUTTON_PRESSED], 0, BUTTON_HIBERNATE);
-	}
-    }
-    else if ( xfpm_strequal (detail, "brightness-up")  && !(bt->priv->keys & BRIGHTNESS_KEY) )
-    {
-	TRACE ("Emitting signal button press condition %s detail %s", condition, detail);
-	g_signal_emit (G_OBJECT (bt), signals [HAL_BUTTON_PRESSED], 0, BUTTON_MON_BRIGHTNESS_UP);
-    }
-    else if ( xfpm_strequal (detail, "brightness-down")  && !(bt->priv->keys & BRIGHTNESS_KEY) )
-    {
-	TRACE ("Emitting signal button press condition %s detail %s", condition, detail);
-	g_signal_emit (G_OBJECT (bt), signals [HAL_BUTTON_PRESSED], 0, BUTTON_MON_BRIGHTNESS_DOWN);
-    }
-}
-
-static void
-xfpm_button_hal_device_changed_cb (HalDevice *device, const gchar *udi, const gchar *key,
-				   gboolean is_added, gboolean is_removed, XfpmButtonHal *bt)
-{
-    gboolean pressed;
-    gchar   *button_type;
-    
-    if ( !xfpm_strequal (key, "button.state.value") )
-	return;
-	
-    if ( hal_device_has_key (device, "button.type") )
-    {
-	button_type = hal_device_get_property_string (device, "button.type");
-	
-	if ( button_type == NULL )
-	    return;
-	    
-	if ( xfpm_strequal (button_type, "lid") )
-	{
-	    pressed = hal_device_get_property_bool (device, key);
-    
-	    TRACE ("Emitting signal lid event : pressed %s", xfpm_bool_to_string (pressed));
-	    g_signal_emit (G_OBJECT (bt), signals [LID_EVENT], 0, pressed);
-	}
-	g_free (button_type);
-    }
-}
-
-static void
-xfpm_button_hal_condition_cb (HalDevice *device, const gchar *condition, 
-			      const gchar *detail, XfpmButtonHal *bt)
-{
-    xfpm_button_hal_emit_signals (bt, condition, detail);
-}
-
-static void
-xfpm_button_hal_add_button (XfpmButtonHal *bt, const gchar *udi, gboolean lid_only)
-{
-    HalDevice *device;
-    gchar *button_type;
-    
-    device = hal_device_new ();
-    
-    hal_device_set_udi (device, udi);
-   
-    if ( lid_only == TRUE )
-    {
-	if ( hal_device_has_key (device, "button.type") == FALSE )
-	{
-	    g_object_unref (device);
-	    return;
-	}
-	
-	button_type = hal_device_get_property_string (device, "button.type");
-	if ( button_type == NULL ) return;
-	
-	if ( xfpm_strequal (button_type, "lid") )
-	{
-	    bt->priv->mapped_keys |= LID_KEY;
-	    g_free (button_type);
-	    goto out;
-	}
-	else
-	{
-	    g_free (button_type);
-	    g_object_unref (device);
-	    return;
-	}
-    }
-    
-    if ( hal_device_has_key (device, "button.type") )
-    {
-	button_type = hal_device_get_property_string (device, "button.type");
-	if ( button_type == NULL ) goto out;
-	
-	if ( xfpm_strequal (button_type, "lid") )
-	    bt->priv->mapped_keys |= LID_KEY;
-	else if ( xfpm_strequal (button_type, "sleep") )
-	    bt->priv->mapped_keys |= SLEEP_KEY;
-	else if ( xfpm_strequal (button_type, "suspend") )
-	    bt->priv->mapped_keys |= SLEEP_KEY;
-	else if ( xfpm_strequal (button_type, "hibernate") )
-	    bt->priv->mapped_keys |= HIBERNATE_KEY;
-	else if ( xfpm_strequal (button_type, "power") )
-	    bt->priv->mapped_keys |= POWER_KEY;
-	    
-	g_free (button_type);
-    }
-    
-out:    
-    g_signal_connect (device, "device-changed",
-		      G_CALLBACK (xfpm_button_hal_device_changed_cb), bt);
-		      
-    g_signal_connect (device, "device-condition",
-		      G_CALLBACK (xfpm_button_hal_condition_cb), bt);
-		      
-    hal_device_watch (device);
-    hal_device_watch_condition (device);
-   
-    g_ptr_array_add (bt->priv->array, device);
-}
-
-static void
-xfpm_button_hal_get_buttons (XfpmButtonHal *bt, gboolean lid_only)
-{
-    HalManager *manager;
-    gchar     **udi;
-    int 	i;
-    
-    manager = hal_manager_new ();
-    
-    udi = hal_manager_find_device_by_capability (manager, "button");
-    
-    g_object_unref (manager);
-    
-    if ( udi == NULL || udi[0] == NULL )
-	return;
-	
-    for ( i = 0; udi[i]; i++)
-    {
-	xfpm_button_hal_add_button (bt, udi[i], lid_only);
-    }
-    hal_manager_free_string_array (udi);
-}
-
-static void
-xfpm_button_hal_class_init (XfpmButtonHalClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-    signals[HAL_BUTTON_PRESSED] = 
-        g_signal_new("hal-button-pressed",
-                      XFPM_TYPE_BUTTON_HAL,
-                      G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET(XfpmButtonHalClass, hal_button_pressed),
-                      NULL, NULL,
-                      g_cclosure_marshal_VOID__ENUM,
-                      G_TYPE_NONE, 1, XFPM_TYPE_BUTTON_KEY);
-
-    signals[LID_EVENT] = 
-        g_signal_new("lid-event",
-                      XFPM_TYPE_BUTTON_HAL,
-                      G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET(XfpmButtonHalClass, lid_event),
-                      NULL, NULL,
-                      g_cclosure_marshal_VOID__BOOLEAN,
-                      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
-
-    object_class->finalize = xfpm_button_hal_finalize;
-
-    g_type_class_add_private (klass, sizeof (XfpmButtonHalPrivate));
-}
-
-static void
-xfpm_button_hal_init (XfpmButtonHal *button)
-{
-    button->priv = XFPM_BUTTON_HAL_GET_PRIVATE (button);
-    button->priv->array = g_ptr_array_new ();
-    button->priv->keys  = 0;
-    button->priv->mapped_keys = 0;
-}
-
-static void
-xfpm_button_hal_free_device_array (XfpmButtonHal *button)
-{
-    HalDevice *device;
-    guint i;
-    
-    for ( i = 0 ; i<button->priv->array->len; i++)
-    {
-	device = g_ptr_array_index (button->priv->array, i);
-	g_object_unref (device);
-    }
-}
-
-static void
-xfpm_button_hal_finalize (GObject *object)
-{
-    XfpmButtonHal *button;
-
-    button = XFPM_BUTTON_HAL (object);
-    
-    xfpm_button_hal_free_device_array (button);
-    
-    g_ptr_array_free (button->priv->array, TRUE);
-
-    G_OBJECT_CLASS (xfpm_button_hal_parent_class)->finalize (object);
-}
-
-XfpmButtonHal *
-xfpm_button_hal_get (void)
-{
-    static gpointer button = NULL;
-    
-    if ( G_LIKELY (button) )
-    {
-	g_object_ref (button);
-    }
-    else
-    {
-	button = g_object_new (XFPM_TYPE_BUTTON_HAL, NULL);
-	g_object_add_weak_pointer (button, &button);
-    }
-	
-    return XFPM_BUTTON_HAL (button);
-}
-
-void xfpm_button_hal_get_keys (XfpmButtonHal *button, gboolean lid_only, guint8 keys)
-{
-    g_return_if_fail (XFPM_IS_BUTTON_HAL (button));
-    
-    button->priv->keys = keys;
-    xfpm_button_hal_get_buttons (button, lid_only);
-}
-
-guint8 xfpm_button_hal_get_mapped_keys (XfpmButtonHal *button)
-{
-    g_return_val_if_fail (XFPM_IS_BUTTON_HAL (button), 0);
-    
-    return button->priv->mapped_keys;
-}
diff --git a/src/xfpm-button-hal.h b/src/xfpm-button-hal.h
deleted file mode 100644
index 2d991f4..0000000
--- a/src/xfpm-button-hal.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * * Copyright (C) 2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __XFPM_BUTTON_HAL_H
-#define __XFPM_BUTTON_HAL_H
-
-#include <glib-object.h>
-
-#include "xfpm-enum-glib.h"
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_BUTTON_HAL        (xfpm_button_hal_get_type () )
-#define XFPM_BUTTON_HAL(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_BUTTON_HAL, XfpmButtonHal))
-#define XFPM_IS_BUTTON_HAL(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_BUTTON_HAL))
-
-typedef struct XfpmButtonHalPrivate XfpmButtonHalPrivate;
-
-typedef struct
-{
-    GObject         	      parent;
-    XfpmButtonHalPrivate     *priv;
-    
-} XfpmButtonHal;
-
-typedef struct
-{
-    GObjectClass 	      parent_class;
-    
-    void                      (*hal_button_pressed)	      (XfpmButtonHal *button,
-							       XfpmButtonKey type);
-							       
-    void		      (*lid_event)		      (XfpmButtonHal *button,
-							       gboolean pressed);
-    
-} XfpmButtonHalClass;
-
-GType        		      xfpm_button_hal_get_type        (void) G_GNUC_CONST;
-
-XfpmButtonHal       	     *xfpm_button_hal_get             (void);
-
-void                          xfpm_button_hal_get_keys        (XfpmButtonHal *button,
-							       gboolean lid_only,
-							       guint8 buttons);
-							       
-guint8                        xfpm_button_hal_get_mapped_keys (XfpmButtonHal *button) G_GNUC_PURE;
-
-G_END_DECLS
-
-#endif /* __XFPM_BUTTON_HAL_H */
diff --git a/src/xfpm-button-xf86.c b/src/xfpm-button-xf86.c
deleted file mode 100644
index 04f8315..0000000
--- a/src/xfpm-button-xf86.c
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-
-/*
- * Based on code from gpm-button (gnome power manager)
- * Copyright (C) 2006-2007 Richard Hughes <richard at hughsie.com>
- * 
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <X11/X.h>
-#include <X11/XF86keysym.h>
-
-#include <gdk/gdkx.h>
-#include <gtk/gtk.h>
-
-#include <glib.h>
-
-#include <libxfce4util/libxfce4util.h>
-
-#include "xfpm-button-xf86.h"
-#include "xfpm-enum.h"
-#include "xfpm-enum-types.h"
-#include "xfpm-debug.h"
-
-static void xfpm_button_xf86_finalize   (GObject *object);
-
-#define XFPM_BUTTON_XF86_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_BUTTON_XF86, XfpmButtonXf86Private))
-
-static struct
-{
-    XfpmButtonKey    key;
-    guint            key_code;
-} xfpm_key_map [NUMBER_OF_BUTTONS] = { {0, 0}, };
-
-struct XfpmButtonXf86Private
-{
-    GdkScreen	*screen;
-    GdkWindow   *window;
-    
-    guint8       mapped_buttons;
-};
-
-enum
-{
-    XF86_BUTTON_PRESSED,
-    LAST_SIGNAL
-};
-
-#define DUPLICATE_SHUTDOWN_TIMEOUT 4.0f
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(XfpmButtonXf86, xfpm_button_xf86, G_TYPE_OBJECT)
-
-static guint
-xfpm_button_get_key (unsigned int keycode)
-{
-    XfpmButtonKey key = BUTTON_UNKNOWN;
-    guint i;
-    
-    for ( i = 0; i < G_N_ELEMENTS (xfpm_key_map); i++)
-    {
-	if ( xfpm_key_map [i].key_code == keycode )
-	    key = xfpm_key_map [i].key;
-    }
-    
-    return key;
-}
-
-static GdkFilterReturn
-xfpm_button_xf86_filter_x_events (GdkXEvent *xevent, GdkEvent *ev, gpointer data)
-{
-    XfpmButtonKey key;
-    XfpmButtonXf86 *button;
-    
-    XEvent *xev = (XEvent *) xevent;
-    
-    if ( xev->type != KeyPress )
-    	return GDK_FILTER_CONTINUE;
-    
-    key = xfpm_button_get_key (xev->xkey.keycode);
-    
-    if ( key != BUTTON_UNKNOWN )
-    {
-	button = (XfpmButtonXf86 *) data;
-    
-	XFPM_DEBUG_ENUM ("Key press", key, XFPM_TYPE_BUTTON_KEY);
-    
-	g_signal_emit (G_OBJECT(button), signals[XF86_BUTTON_PRESSED], 0, key);
-	return GDK_FILTER_REMOVE;
-    }
-    
-    return GDK_FILTER_CONTINUE;
-}
-
-static gboolean
-xfpm_button_xf86_grab_keystring (XfpmButtonXf86 *button, guint keycode)
-{
-    Display *display;
-    guint ret;
-    guint modmask = 0;
-    
-    display = GDK_DISPLAY ();
-    
-    gdk_error_trap_push ();
-
-    ret = XGrabKey (display, keycode, modmask,
-		    GDK_WINDOW_XID (button->priv->window), True,
-		    GrabModeAsync, GrabModeAsync);
-		    
-    if ( ret == BadAccess )
-    {
-	g_warning ("Failed to grab modmask=%u, keycode=%li",
-		    modmask, (long int) keycode);
-	return FALSE;
-    }
-	
-    ret = XGrabKey (display, keycode, LockMask | modmask,
-		    GDK_WINDOW_XID (button->priv->window), True,
-		    GrabModeAsync, GrabModeAsync);
-			
-    if (ret == BadAccess)
-    {
-	g_warning ("Failed to grab modmask=%u, keycode=%li",
-		   LockMask | modmask, (long int) keycode);
-	return FALSE;
-    }
-
-    gdk_flush ();
-    gdk_error_trap_pop ();
-    return TRUE;
-}
-
-
-static gboolean
-xfpm_button_xf86_xevent_key (XfpmButtonXf86 *button, guint keysym , XfpmButtonKey key)
-{
-    guint keycode = XKeysymToKeycode (GDK_DISPLAY(), keysym);
-
-    if ( keycode == 0 )
-    {
-	g_warning ("could not map keysym %x to keycode\n", keysym);
-	return FALSE;
-    }
-    
-    if ( !xfpm_button_xf86_grab_keystring(button, keycode)) 
-    {
-    	g_warning ("Failed to grab %i\n", keycode);
-	return FALSE;
-    }
-    
-    XFPM_DEBUG_ENUM_FULL (key, XFPM_TYPE_BUTTON_KEY, "Grabbed key %li ", (long int) keycode);
-    
-    xfpm_key_map [key].key_code = keycode;
-    xfpm_key_map [key].key = key;
-    
-    return TRUE;
-}
-
-static void
-xfpm_button_xf86_setup (XfpmButtonXf86 *button)
-{
-    button->priv->screen = gdk_screen_get_default ();
-    button->priv->window = gdk_screen_get_root_window (button->priv->screen);
-    
-    if ( xfpm_button_xf86_xevent_key (button, XF86XK_PowerOff, BUTTON_POWER_OFF) )
-	button->priv->mapped_buttons |= POWER_KEY;
-    
-#ifdef HAVE_XF86XK_HIBERNATE
-    if ( xfpm_button_xf86_xevent_key (button, XF86XK_Hibernate, BUTTON_HIBERNATE) )
-	button->priv->mapped_buttons |= HIBERNATE_KEY;
-#endif 
-
-#ifdef HAVE_XF86XK_SUSPEND
-    if ( xfpm_button_xf86_xevent_key (button, XF86XK_Suspend, BUTTON_HIBERNATE) )
-	button->priv->mapped_buttons |= HIBERNATE_KEY;
-#endif 
-
-    if ( xfpm_button_xf86_xevent_key (button, XF86XK_Sleep, BUTTON_SLEEP) )
-	button->priv->mapped_buttons |= SLEEP_KEY;
-	
-    if ( xfpm_button_xf86_xevent_key (button, XF86XK_MonBrightnessUp, BUTTON_MON_BRIGHTNESS_UP) &&
-	 xfpm_button_xf86_xevent_key (button, XF86XK_MonBrightnessDown, BUTTON_MON_BRIGHTNESS_DOWN) )
-	button->priv->mapped_buttons |= BRIGHTNESS_KEY;
-
-    gdk_window_add_filter (button->priv->window, 
-			   xfpm_button_xf86_filter_x_events, button);
-}
-
-static void
-xfpm_button_xf86_class_init(XfpmButtonXf86Class *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-    signals[XF86_BUTTON_PRESSED] = 
-        g_signal_new("xf86-button-pressed",
-                      XFPM_TYPE_BUTTON_XF86,
-                      G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET(XfpmButtonXf86Class, xf86_button_pressed),
-                      NULL, NULL,
-                      g_cclosure_marshal_VOID__ENUM,
-                      G_TYPE_NONE, 1, XFPM_TYPE_BUTTON_KEY);
-
-    object_class->finalize = xfpm_button_xf86_finalize;
-
-    g_type_class_add_private(klass,sizeof(XfpmButtonXf86Private));
-}
-
-static void
-xfpm_button_xf86_init(XfpmButtonXf86 *button)
-{
-    button->priv = XFPM_BUTTON_XF86_GET_PRIVATE(button);
-    
-    button->priv->mapped_buttons = 0;
-    button->priv->screen = NULL;
-    button->priv->window = NULL;
-    
-    xfpm_button_xf86_setup (button);
-}
-
-static void
-xfpm_button_xf86_finalize(GObject *object)
-{
-    XfpmButtonXf86 *button;
-
-    button = XFPM_BUTTON_XF86 (object);
-    
-    G_OBJECT_CLASS(xfpm_button_xf86_parent_class)->finalize(object);
-}
-
-XfpmButtonXf86 *
-xfpm_button_xf86_new(void)
-{
-    XfpmButtonXf86 *button = NULL;
-    button = g_object_new (XFPM_TYPE_BUTTON_XF86, NULL);
-    return button;
-}
-
-guint8 xfpm_button_xf86_get_mapped_buttons (XfpmButtonXf86 *button)
-{
-    g_return_val_if_fail (XFPM_IS_BUTTON_XF86 (button), 0);
-    
-    return button->priv->mapped_buttons;
-}
diff --git a/src/xfpm-button-xf86.h b/src/xfpm-button-xf86.h
deleted file mode 100644
index f9bc962..0000000
--- a/src/xfpm-button-xf86.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __XFPM_BUTTON_XF86_H
-#define __XFPM_BUTTON_XF86_H
-
-#include <glib-object.h>
-
-#include "xfpm-enum-glib.h"
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_BUTTON_XF86   (xfpm_button_xf86_get_type () )
-#define XFPM_BUTTON_XF86(o)     (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_BUTTON_XF86, XfpmButtonXf86))
-#define XFPM_IS_BUTTON_XF86(o)  (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_BUTTON_XF86))
-
-typedef struct XfpmButtonXf86Private XfpmButtonXf86Private;
-
-typedef struct
-{
-    GObject		  	parent;
-    XfpmButtonXf86Private      *priv;
-    
-} XfpmButtonXf86;
-
-typedef struct
-{
-    GObjectClass 		parent_class;
-     
-    void                 	(*xf86_button_pressed)		       (XfpmButtonXf86 *button,
-								        XfpmButtonKey type);
-    
-} XfpmButtonXf86Class;
-
-GType                 		xfpm_button_xf86_get_type               (void) G_GNUC_CONST;
-XfpmButtonXf86       	       *xfpm_button_xf86_new             	(void);
-
-guint8                		xfpm_button_xf86_get_mapped_buttons     (XfpmButtonXf86 *button) G_GNUC_PURE;
-
-G_END_DECLS
-
-#endif /* __XFPM_BUTTON_XF86_H */
diff --git a/src/xfpm-button.c b/src/xfpm-button.c
index 800e8ad..1c8fabb 100644
--- a/src/xfpm-button.c
+++ b/src/xfpm-button.c
@@ -1,5 +1,5 @@
 /*
- * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
  *
  * Licensed under the GNU General Public License Version 2
  *
@@ -18,6 +18,13 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+
+/*
+ * Based on code from gpm-button (gnome power manager)
+ * Copyright (C) 2006-2007 Richard Hughes <richard at hughsie.com>
+ * 
+ */
+
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -26,28 +33,46 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <X11/X.h>
+#include <X11/XF86keysym.h>
+
+#include <gdk/gdkx.h>
+#include <gtk/gtk.h>
+
 #include <glib.h>
 
+#include <libxfce4util/libxfce4util.h>
+
 #include "xfpm-button.h"
-#include "xfpm-button-xf86.h"
-#include "xfpm-button-hal.h"
-#include "xfpm-shutdown.h"
 #include "xfpm-enum.h"
 #include "xfpm-enum-types.h"
+#include "xfpm-debug.h"
+
+#ifdef WITH_HAL
+#include "libhal/hal-manager.h"
+#include "libhal/hal-device.h"
+#endif
 
 static void xfpm_button_finalize   (GObject *object);
 
 #define XFPM_BUTTON_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_BUTTON, XfpmButtonPrivate))
+(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_BUTTON, XfpmButtonPrivate))
 
-#define SLEEP_KEY_TIMEOUT 6.0f
+static struct
+{
+    XfpmButtonKey    key;
+    guint            key_code;
+} xfpm_key_map [NUMBER_OF_BUTTONS] = { {0, 0}, };
 
 struct XfpmButtonPrivate
 {
-    XfpmButtonXf86 *xf86;
-    XfpmButtonHal  *hal;
-    XfpmShutdown   *shutdown;
-    GTimer         *timer;
+    GdkScreen	*screen;
+    GdkWindow   *window;
+    
+    guint8       mapped_buttons;
+#ifdef WITH_HAL
+    GPtrArray  *array;
+#endif
 };
 
 enum
@@ -56,93 +81,322 @@ enum
     LAST_SIGNAL
 };
 
-static guint signals [LAST_SIGNAL] = { 0 };
+#define DUPLICATE_SHUTDOWN_TIMEOUT 4.0f
 
-G_DEFINE_TYPE (XfpmButton, xfpm_button, G_TYPE_OBJECT)
+static guint signals[LAST_SIGNAL] = { 0 };
 
-static void
-xfpm_button_xf86_emit_signal (XfpmButton *button, XfpmButtonKey key)
+G_DEFINE_TYPE(XfpmButton, xfpm_button, G_TYPE_OBJECT)
+
+static guint
+xfpm_button_get_key (unsigned int keycode)
 {
-    if ( key == BUTTON_POWER_OFF || key == BUTTON_SLEEP || key == BUTTON_HIBERNATE )
+    XfpmButtonKey key = BUTTON_UNKNOWN;
+    guint i;
+    
+    for ( i = 0; i < G_N_ELEMENTS (xfpm_key_map); i++)
     {
-	if ( g_timer_elapsed (button->priv->timer, NULL) > SLEEP_KEY_TIMEOUT )
-	{
-	    g_signal_emit (G_OBJECT (button), signals [BUTTON_PRESSED], 0, key);
-	    g_timer_reset (button->priv->timer);
-	}
+	if ( xfpm_key_map [i].key_code == keycode )
+	    key = xfpm_key_map [i].key;
     }
-    else
+    
+    return key;
+}
+
+static GdkFilterReturn
+xfpm_button_filter_x_events (GdkXEvent *xevent, GdkEvent *ev, gpointer data)
+{
+    XfpmButtonKey key;
+    XfpmButton *button;
+    
+    XEvent *xev = (XEvent *) xevent;
+    
+    if ( xev->type != KeyPress )
+    	return GDK_FILTER_CONTINUE;
+    
+    key = xfpm_button_get_key (xev->xkey.keycode);
+    
+    if ( key != BUTTON_UNKNOWN )
     {
-	g_signal_emit (G_OBJECT (button), signals [BUTTON_PRESSED], 0, key);
+	button = (XfpmButton *) data;
+    
+	XFPM_DEBUG_ENUM (key, XFPM_TYPE_BUTTON_KEY, "Key press");
+    
+	g_signal_emit (G_OBJECT(button), signals[BUTTON_PRESSED], 0, key);
+	return GDK_FILTER_REMOVE;
     }
+    
+    return GDK_FILTER_CONTINUE;
+}
+
+static gboolean
+xfpm_button_grab_keystring (XfpmButton *button, guint keycode)
+{
+    Display *display;
+    guint ret;
+    guint modmask = 0;
+    
+    display = GDK_DISPLAY ();
+    
+    gdk_error_trap_push ();
+
+    ret = XGrabKey (display, keycode, modmask,
+		    GDK_WINDOW_XID (button->priv->window), True,
+		    GrabModeAsync, GrabModeAsync);
+		    
+    if ( ret == BadAccess )
+    {
+	g_warning ("Failed to grab modmask=%u, keycode=%li",
+		    modmask, (long int) keycode);
+	return FALSE;
+    }
+	
+    ret = XGrabKey (display, keycode, LockMask | modmask,
+		    GDK_WINDOW_XID (button->priv->window), True,
+		    GrabModeAsync, GrabModeAsync);
+			
+    if (ret == BadAccess)
+    {
+	g_warning ("Failed to grab modmask=%u, keycode=%li",
+		   LockMask | modmask, (long int) keycode);
+	return FALSE;
+    }
+
+    gdk_flush ();
+    gdk_error_trap_pop ();
+    return TRUE;
+}
+
+
+static gboolean
+xfpm_button_xevent_key (XfpmButton *button, guint keysym , XfpmButtonKey key)
+{
+    guint keycode = XKeysymToKeycode (GDK_DISPLAY(), keysym);
+
+    if ( keycode == 0 )
+    {
+	g_warning ("could not map keysym %x to keycode\n", keysym);
+	return FALSE;
+    }
+    
+    if ( !xfpm_button_grab_keystring(button, keycode)) 
+    {
+    	g_warning ("Failed to grab %i\n", keycode);
+	return FALSE;
+    }
+    
+    XFPM_DEBUG_ENUM (key, XFPM_TYPE_BUTTON_KEY, "Grabbed key %li ", (long int) keycode);
+    
+    xfpm_key_map [key].key_code = keycode;
+    xfpm_key_map [key].key = key;
+    
+    return TRUE;
+}
+
+static void
+xfpm_button_setup (XfpmButton *button)
+{
+    button->priv->screen = gdk_screen_get_default ();
+    button->priv->window = gdk_screen_get_root_window (button->priv->screen);
+    
+    if ( xfpm_button_xevent_key (button, XF86XK_PowerOff, BUTTON_POWER_OFF) )
+	button->priv->mapped_buttons |= POWER_KEY;
+    
+#ifdef HAVE_XF86XK_HIBERNATE
+    if ( xfpm_button_xevent_key (button, XF86XK_Hibernate, BUTTON_HIBERNATE) )
+	button->priv->mapped_buttons |= HIBERNATE_KEY;
+#endif 
+
+#ifdef HAVE_XF86XK_SUSPEND
+    if ( xfpm_button_xevent_key (button, XF86XK_Suspend, BUTTON_HIBERNATE) )
+	button->priv->mapped_buttons |= HIBERNATE_KEY;
+#endif 
+
+    if ( xfpm_button_xevent_key (button, XF86XK_Sleep, BUTTON_SLEEP) )
+	button->priv->mapped_buttons |= SLEEP_KEY;
+	
+    if ( xfpm_button_xevent_key (button, XF86XK_MonBrightnessUp, BUTTON_MON_BRIGHTNESS_UP) )
+	button->priv->mapped_buttons |= BRIGHTNESS_KEY_UP;
+	
+    if (xfpm_button_xevent_key (button, XF86XK_MonBrightnessDown, BUTTON_MON_BRIGHTNESS_DOWN) )
+	button->priv->mapped_buttons |= BRIGHTNESS_KEY_DOWN;
+
+    gdk_window_add_filter (button->priv->window, 
+			   xfpm_button_filter_x_events, button);
 }
 
+#ifdef WITH_HAL
 static void
-xfpm_button_xf86_button_pressed_cb (XfpmButtonXf86 *xf86, XfpmButtonKey key, XfpmButton *button)
+xfpm_button_hal_emit_signals (XfpmButton *button, const gchar *condition, const gchar *detail)
 {
-    xfpm_button_xf86_emit_signal (button, key);
+    if ( g_strcmp0 (condition, "ButtonPressed") )
+	return;
+
+    XFPM_DEBUG ("Button press condition %s detail %s", condition, detail);
+
+    if ( !g_strcmp0 (detail, "power") )
+	g_signal_emit (G_OBJECT (button), signals [BUTTON_PRESSED], 0, BUTTON_POWER_OFF);
+    else if ( !g_strcmp0 (detail, "sleep")  || !g_strcmp0 (detail, "suspend") )
+	g_signal_emit (G_OBJECT (button), signals [BUTTON_PRESSED], 0, BUTTON_SLEEP);
+    else if ( !g_strcmp0 (detail, "hibernate"))
+	g_signal_emit (G_OBJECT (button), signals [BUTTON_PRESSED], 0, BUTTON_HIBERNATE);
+    else if ( !g_strcmp0 (detail, "brightness-up") )
+	g_signal_emit (G_OBJECT (button), signals [BUTTON_PRESSED], 0, BUTTON_MON_BRIGHTNESS_UP);
+    else if ( !g_strcmp0 (detail, "brightness-down") )
+	g_signal_emit (G_OBJECT (button), signals [BUTTON_PRESSED], 0, BUTTON_MON_BRIGHTNESS_DOWN);
 }
 
 static void
-xfpm_button_hal_button_pressed_cb (XfpmButtonHal *hal, XfpmButtonKey key, XfpmButton *button)
+xfpm_button_hal_condition_cb (HalDevice *device, const gchar *condition, 
+			      const gchar *detail, XfpmButton *button)
 {
-    xfpm_button_xf86_emit_signal (button, key);
+    xfpm_button_hal_emit_signals (button, condition, detail);
 }
 
 static void
-xfpm_button_waking_up_cb (XfpmShutdown *shutdown, XfpmButton *button)
+xfpm_button_add_button_hal (XfpmButton *button, const gchar *udi)
 {
-    g_timer_reset (button->priv->timer);
+    HalDevice *device;
+    gchar *button_type = NULL;
+    
+    device = hal_device_new ();
+    
+    hal_device_set_udi (device, udi);
+   
+    if ( hal_device_has_key (device, "button.type") )
+    {
+	button_type = hal_device_get_property_string (device, "button.type");
+	
+	if ( button_type == NULL ) 
+	{
+	    g_object_unref (device);
+	    return;
+	}
+	
+	if ( !g_strcmp0 (button_type, "sleep") && !(button->priv->mapped_buttons & SLEEP_KEY))
+	    button->priv->mapped_buttons |= SLEEP_KEY;
+	else if ( !g_strcmp0 (button_type, "suspend") && !(button->priv->mapped_buttons & SLEEP_KEY))
+	    button->priv->mapped_buttons |= SLEEP_KEY;
+	else if ( !g_strcmp0 (button_type, "hibernate") && !(button->priv->mapped_buttons & HIBERNATE_KEY))
+	    button->priv->mapped_buttons |= HIBERNATE_KEY;
+	else if ( !g_strcmp0 (button_type, "power") && !(button->priv->mapped_buttons & POWER_KEY))
+	    button->priv->mapped_buttons |= POWER_KEY;
+	else if ( !g_strcmp0 (button_type, "brightness-up") && !(button->priv->mapped_buttons & BRIGHTNESS_KEY_UP))
+	    button->priv->mapped_buttons |= BRIGHTNESS_KEY_UP;
+	else if ( !g_strcmp0 (button_type, "brightness-down") && !(button->priv->mapped_buttons & BRIGHTNESS_KEY_DOWN))
+	    button->priv->mapped_buttons |= BRIGHTNESS_KEY_DOWN;
+	else
+	{
+	    g_object_unref (device);
+	    if ( button_type )
+		g_free (button_type);
+	    return;
+	}
+	
+	if ( button_type )
+		g_free (button_type);
+    }
+    else
+    {
+	g_object_unref (device);
+	return;
+    }
+    
+    g_signal_connect (device, "device-condition",
+		      G_CALLBACK (xfpm_button_hal_condition_cb), button);
+		      
+    hal_device_watch_condition (device);
+   
+    if ( button->priv->array == NULL )
+    {
+	button->priv->array = g_ptr_array_new ();
+    }
+    g_ptr_array_add (button->priv->array, device);
+
 }
 
 static void
-xfpm_button_class_init (XfpmButtonClass *klass)
+xfpm_button_setup_failed_hal (XfpmButton *button)
 {
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+    HalManager *manager;
+    gchar     **udi;
+    int 	i;
+    
+    XFPM_DEBUG ("Getting missing buttons from HAL");
+    
+    manager = hal_manager_new ();
+    
+    udi = hal_manager_find_device_by_capability (manager, "button");
+    
+    g_object_unref (manager);
+    
+    if ( udi == NULL || udi[0] == NULL )
+	return;
+	
+    for ( i = 0; udi[i]; i++)
+    {
+	xfpm_button_add_button_hal (button, udi[i]);
+    }
+    
+    hal_manager_free_string_array (udi);
+    if ( button->priv->array )
+	XFPM_DEBUG ("Mapped HAL buttons : %u", button->priv->array->len);
+}
+#endif /* WITH_HAL*/
+
+static void
+xfpm_button_class_init(XfpmButtonClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS(klass);
 
-    signals[BUTTON_PRESSED] = 
-        g_signal_new("button-pressed",
+    signals [BUTTON_PRESSED] = 
+        g_signal_new ("button-pressed",
                       XFPM_TYPE_BUTTON,
                       G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET(XfpmButtonClass, button_pressed),
+                      G_STRUCT_OFFSET (XfpmButtonClass, button_pressed),
                       NULL, NULL,
                       g_cclosure_marshal_VOID__ENUM,
                       G_TYPE_NONE, 1, XFPM_TYPE_BUTTON_KEY);
 
     object_class->finalize = xfpm_button_finalize;
+
     g_type_class_add_private (klass, sizeof (XfpmButtonPrivate));
 }
 
 static void
 xfpm_button_init (XfpmButton *button)
 {
-    guint8 xf86_mapped;
-    gboolean only_lid = FALSE;
-    
     button->priv = XFPM_BUTTON_GET_PRIVATE (button);
-    button->priv->xf86 = xfpm_button_xf86_new ();
-    button->priv->timer = g_timer_new ();
-    button->priv->shutdown = xfpm_shutdown_new ();
     
-    xf86_mapped = xfpm_button_xf86_get_mapped_buttons (button->priv->xf86);
-
-    button->priv->hal = xfpm_button_hal_get ();
+    button->priv->mapped_buttons = 0;
+    button->priv->screen = NULL;
+    button->priv->window = NULL;
     
-    if ( xf86_mapped & SLEEP_KEY && xf86_mapped & POWER_KEY && 
-	 xf86_mapped & BRIGHTNESS_KEY && xf86_mapped & HIBERNATE_KEY )
-	only_lid = TRUE;
+    xfpm_button_setup (button);
+#ifdef WITH_HAL
+    if ( !(button->priv->mapped_buttons & BRIGHTNESS_KEY_DOWN ) ||
+         !(button->priv->mapped_buttons & BRIGHTNESS_KEY_UP )   ||
+	 !(button->priv->mapped_buttons & SLEEP_KEY )   ||
+	 !(button->priv->mapped_buttons & HIBERNATE_KEY)   ||
+	 !(button->priv->mapped_buttons & POWER_KEY )  )
+	xfpm_button_setup_failed_hal (button);
+#endif
+    
+}
 
-    xfpm_button_hal_get_keys (button->priv->hal, only_lid, xf86_mapped);
+#ifdef WITH_HAL
+static void
+xfpm_button_free_device_array (XfpmButton *button)
+{
+    HalDevice *device;
+    guint i;
     
-    g_signal_connect (button->priv->xf86, "xf86-button-pressed",
-		      G_CALLBACK (xfpm_button_xf86_button_pressed_cb), button);
-		      
-    g_signal_connect (button->priv->hal, "hal-button-pressed",
-		      G_CALLBACK (xfpm_button_hal_button_pressed_cb), button);
-		      
-    g_signal_connect (button->priv->shutdown, "waking-up",
-		      G_CALLBACK (xfpm_button_waking_up_cb), button);
+    for ( i = 0 ; i<button->priv->array->len; i++)
+    {
+	device = g_ptr_array_index (button->priv->array, i);
+	g_object_unref (device);
+    }
 }
+#endif
 
 static void
 xfpm_button_finalize (GObject *object)
@@ -151,13 +405,15 @@ xfpm_button_finalize (GObject *object)
 
     button = XFPM_BUTTON (object);
     
-    g_object_unref (button->priv->hal);
-    g_object_unref (button->priv->xf86);
-    g_object_unref (button->priv->shutdown);
+#ifdef WITH_HAL
+    if ( button->priv->array )
+    {
+	xfpm_button_free_device_array (button);
+	g_ptr_array_free (button->priv->array, TRUE);
+    }
+#endif
     
-    g_timer_destroy (button->priv->timer);
-
-    G_OBJECT_CLASS (xfpm_button_parent_class)->finalize (object);
+    G_OBJECT_CLASS(xfpm_button_parent_class)->finalize(object);
 }
 
 XfpmButton *
@@ -167,28 +423,20 @@ xfpm_button_new (void)
     
     if ( G_LIKELY (xfpm_button_object != NULL) )
     {
-	g_object_ref (xfpm_button_object);
+        g_object_ref (xfpm_button_object);
     }
     else
     {
-	xfpm_button_object = g_object_new (XFPM_TYPE_BUTTON, NULL);
-	g_object_add_weak_pointer (xfpm_button_object, &xfpm_button_object);
+        xfpm_button_object = g_object_new (XFPM_TYPE_BUTTON, NULL);
+        g_object_add_weak_pointer (xfpm_button_object, &xfpm_button_object);
     }
+    
     return XFPM_BUTTON (xfpm_button_object);
 }
 
 guint8 xfpm_button_get_mapped (XfpmButton *button)
 {
-    guint8 mapped_keys = 0;
-    guint8 hal_mapped;
-    guint8 xf86_mapped;
-    
     g_return_val_if_fail (XFPM_IS_BUTTON (button), 0);
     
-    hal_mapped  = xfpm_button_hal_get_mapped_keys (button->priv->hal);
-    xf86_mapped = xfpm_button_xf86_get_mapped_buttons (button->priv->xf86);
-    
-    mapped_keys = hal_mapped | xf86_mapped;
-    
-    return mapped_keys;
+    return button->priv->mapped_buttons;
 }
diff --git a/src/xfpm-button.h b/src/xfpm-button.h
index 7243c20..6ce5309 100644
--- a/src/xfpm-button.h
+++ b/src/xfpm-button.h
@@ -1,5 +1,5 @@
 /*
- * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
  *
  * Licensed under the GNU General Public License Version 2
  *
@@ -27,31 +27,33 @@
 
 G_BEGIN_DECLS
 
-#define XFPM_TYPE_BUTTON        (xfpm_button_get_type () )
-#define XFPM_BUTTON(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_BUTTON, XfpmButton))
-#define XFPM_IS_BUTTON(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_BUTTON))
+#define XFPM_TYPE_BUTTON   (xfpm_button_get_type () )
+#define XFPM_BUTTON(o)     (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_BUTTON, XfpmButton))
+#define XFPM_IS_BUTTON(o)  (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_BUTTON))
 
 typedef struct XfpmButtonPrivate XfpmButtonPrivate;
 
 typedef struct
 {
-    GObject         		 parent;
-    XfpmButtonPrivate     	*priv;
+    GObject		  	parent;
+    XfpmButtonPrivate          *priv;
     
 } XfpmButton;
 
 typedef struct
 {
-    GObjectClass 		 parent_class;
-    void                         (*button_pressed)	     (XfpmButton *button,
-							      XfpmButtonKey key);
+    GObjectClass 		parent_class;
+     
+    void                 	(*button_pressed)		        (XfpmButton *button,
+								         XfpmButtonKey type);
     
 } XfpmButtonClass;
 
-GType        			 xfpm_button_get_type        (void) G_GNUC_CONST;
-XfpmButton       		*xfpm_button_new             (void);
+GType                 		xfpm_button_get_type               	(void) G_GNUC_CONST;
 
-guint8                           xfpm_button_get_mapped      (XfpmButton *button);
+XfpmButton       	       *xfpm_button_new             		(void);
+
+guint8                		xfpm_button_get_mapped		     	(XfpmButton *button) G_GNUC_PURE;
 
 G_END_DECLS
 
diff --git a/src/xfpm-config.h b/src/xfpm-config.h
index 226402c..39b5a75 100644
--- a/src/xfpm-config.h
+++ b/src/xfpm-config.h
@@ -28,10 +28,6 @@
 
 #include <glib.h>
 
-#if defined(__linux__)
-#define SYSTEM_IS_LINUX 1
-#endif
-
 G_BEGIN_DECLS
 
 #define 	XFPM_CHANNEL_CFG             	"xfce4-power-manager"
@@ -39,43 +35,49 @@ G_BEGIN_DECLS
 /*
  * Backward compatibility with old version.
  */
-#define 	PROPERTIES_PREFIX		        "/xfce4-power-manager/"
+#define 	PROPERTIES_PREFIX		"/xfce4-power-manager/"
 
 
 #define 	POWER_SAVE_ON_BATTERY        	"power-save-on-battery"
-#define     CPU_FREQ_CONTROL             	"enable-cpu-freq-control"
-#define     LOCK_SCREEN_ON_SLEEP         	"lock-screen-suspend-hibernate"
+#define     	CPU_FREQ_CONTROL             	"enable-cpu-freq-control"
+#define     	LOCK_SCREEN_ON_SLEEP         	"lock-screen-suspend-hibernate"
 
 #define 	DPMS_ENABLED_CFG             	"dpms-enabled" 
-#define 	ON_AC_DPMS_SLEEP 	     	    "dpms-on-ac-sleep"
+#define 	ON_AC_DPMS_SLEEP 	     	"dpms-on-ac-sleep"
 #define 	ON_AC_DPMS_OFF	     	     	"dpms-on-ac-off"
-#define 	ON_BATT_DPMS_SLEEP 	     	    "dpms-on-battery-sleep"
-#define 	ON_BATT_DPMS_OFF	     	    "dpms-on-battery-off"
-#define     DPMS_SLEEP_MODE		     	    "dpms-sleep-mode"		
+#define 	ON_BATT_DPMS_SLEEP 	     	"dpms-on-battery-sleep"
+#define 	ON_BATT_DPMS_OFF	     	"dpms-on-battery-off"
+#define     	DPMS_SLEEP_MODE		     	"dpms-sleep-mode"		
 
 #define 	GENERAL_NOTIFICATION_CFG     	"general-notification"
 
-#define     ON_AC_INACTIVITY_TIMEOUT     	"inactivity-on-ac"
-#define     ON_BATTERY_INACTIVITY_TIMEOUT 	"inactivity-on-battery"
-#define     INACTIVITY_SLEEP_MODE        	"inactivity-sleep-mode"
+#define     	ON_AC_INACTIVITY_TIMEOUT     	"inactivity-on-ac"
+#define     	ON_BATTERY_INACTIVITY_TIMEOUT 	"inactivity-on-battery"
+#define     	INACTIVITY_SLEEP_MODE        	"inactivity-sleep-mode"
 
-#define     BRIGHTNESS_ON_AC             	"brightness-on-ac"
-#define     BRIGHTNESS_ON_BATTERY        	"brightness-on-battery"
+#define     	BRIGHTNESS_ON_AC             	"brightness-on-ac"
+#define     	BRIGHTNESS_ON_BATTERY        	"brightness-on-battery"
 
-#define     CRITICAL_POWER_LEVEL        	"critical-power-level"
-#define     SHOW_BRIGHTNESS_POPUP        	"show-brightness-popup"
-#define     ENABLE_BRIGHTNESS_CONTROL       "change-brightness-on-key-events"
+#define     	CRITICAL_POWER_LEVEL        	"critical-power-level"
+#define     	SHOW_BRIGHTNESS_POPUP        	"show-brightness-popup"
+#define     	ENABLE_BRIGHTNESS_CONTROL       "change-brightness-on-key-events"
 
 #define 	SHOW_TRAY_ICON_CFG          	"show-tray-icon"
 #define 	CRITICAL_BATT_ACTION_CFG    	"critical-power-action"
 
 #define 	POWER_SWITCH_CFG            	"power-button-action"
-#define     HIBERNATE_SWITCH_CFG        	"hibernate-button-action"
+#define     	HIBERNATE_SWITCH_CFG        	"hibernate-button-action"
 #define 	SLEEP_SWITCH_CFG            	"sleep-button-action"
 
 #define 	LID_SWITCH_ON_AC_CFG        	"lid-action-on-ac"
 #define 	LID_SWITCH_ON_BATTERY_CFG   	"lid-action-on-battery"
 
+#define         SPIN_DOWN_ON_AC			"spin-down-on-ac"
+#define         SPIN_DOWN_ON_BATTERY		"spin-down-on-battery"
+
+#define         SPIN_DOWN_ON_AC_TIMEOUT		"spin-down-on-ac-timeout"
+#define         SPIN_DOWN_ON_BATTERY_TIMEOUT	"spin-down-on-battery-timeout"
+
 G_END_DECLS
 
 #endif /* __XFPM_CONFIG_H */
diff --git a/src/xfpm-console-kit.c b/src/xfpm-console-kit.c
new file mode 100644
index 0000000..cffc8b5
--- /dev/null
+++ b/src/xfpm-console-kit.c
@@ -0,0 +1,235 @@
+/*
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <dbus/dbus-glib.h>
+
+#include "xfpm-console-kit.h"
+#include "xfpm-dbus-monitor.h"
+
+
+static void xfpm_console_kit_finalize   (GObject *object);
+
+static void xfpm_console_kit_get_property (GObject *object,
+					   guint prop_id,
+					   GValue *value,
+					   GParamSpec *pspec);
+	    
+#define XFPM_CONSOLE_KIT_GET_PRIVATE(o) \
+(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_CONSOLE_KIT, XfpmConsoleKitPrivate))
+
+struct XfpmConsoleKitPrivate
+{
+    DBusGConnection *bus;
+    DBusGProxy      *proxy;
+    
+    XfpmDBusMonitor *monitor;
+    
+    gboolean	     can_shutdown;
+    gboolean	     can_restart;
+};
+
+enum
+{
+    PROP_0,
+    PROP_CAN_RESTART,
+    PROP_CAN_SHUTDOWN
+};
+
+G_DEFINE_TYPE (XfpmConsoleKit, xfpm_console_kit, G_TYPE_OBJECT)
+
+static void
+xfpm_console_kit_get_info (XfpmConsoleKit *console)
+{
+    GError *error = NULL;
+    
+    dbus_g_proxy_call (console->priv->proxy, "CanStop", &error,
+		       G_TYPE_INVALID,
+		       G_TYPE_BOOLEAN, &console->priv->can_shutdown,
+		       G_TYPE_INVALID);
+		       
+    if ( error )
+    {
+	g_warning ("'CanStop' method failed : %s", error->message);
+	g_error_free (error);
+	error = NULL;
+    }
+    
+    dbus_g_proxy_call (console->priv->proxy, "CanRestart", &error,
+		       G_TYPE_INVALID,
+		       G_TYPE_BOOLEAN, &console->priv->can_restart,
+		       G_TYPE_INVALID);
+		       
+    if ( error )
+    {
+	g_warning ("'CanRestart' method failed : %s", error->message);
+	g_error_free (error);
+	error = NULL;
+    }
+    
+}
+
+static void
+xfpm_console_kit_class_init (XfpmConsoleKitClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    object_class->finalize = xfpm_console_kit_finalize;
+
+    object_class->get_property = xfpm_console_kit_get_property;
+    
+    g_object_class_install_property (object_class,
+                                     PROP_CAN_RESTART,
+                                     g_param_spec_boolean ("can-restart",
+                                                           NULL, NULL,
+                                                           FALSE,
+                                                           G_PARAM_READABLE));
+
+    g_object_class_install_property (object_class,
+                                     PROP_CAN_SHUTDOWN,
+                                     g_param_spec_boolean ("can-shutdown",
+                                                           NULL, NULL,
+                                                           FALSE,
+                                                           G_PARAM_READABLE));
+
+    g_type_class_add_private (klass, sizeof (XfpmConsoleKitPrivate));
+}
+
+static void
+xfpm_console_kit_init (XfpmConsoleKit *console)
+{
+    GError *error = NULL;
+    
+    console->priv = XFPM_CONSOLE_KIT_GET_PRIVATE (console);
+    console->priv->can_shutdown = FALSE;
+    console->priv->can_restart  = FALSE;
+    
+    console->priv->bus   = NULL;
+    console->priv->proxy = NULL;
+    
+    console->priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+    
+    if ( error )
+    {
+	g_critical ("Unable to get system bus connection : %s", error->message);
+	g_error_free (error);
+	goto out;
+    }
+    
+    console->priv->proxy = dbus_g_proxy_new_for_name (console->priv->bus,
+						      "org.freedesktop.ConsoleKit",
+						      "/org/freedesktop/ConsoleKit/Manager",
+						      "org.freedesktop.ConsoleKit.Manager");
+						      
+    if ( !console->priv->proxy )
+    {
+	g_warning ("Unable to create proxy for 'org.freedesktop.ConsoleKit'");
+	goto out;
+    }
+    
+    xfpm_console_kit_get_info (console);
+    
+out:
+    ;
+}
+
+static void xfpm_console_kit_get_property (GObject *object,
+					   guint prop_id,
+					   GValue *value,
+					   GParamSpec *pspec)
+{
+    XfpmConsoleKit *console;
+    console = XFPM_CONSOLE_KIT (object);
+
+    switch (prop_id)
+    {
+	case PROP_CAN_SHUTDOWN:
+	    g_value_set_boolean (value, console->priv->can_shutdown);
+	    break;
+	case PROP_CAN_RESTART:
+	    g_value_set_boolean (value, console->priv->can_restart);
+	    break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+            break;
+    }
+}
+
+static void
+xfpm_console_kit_finalize (GObject *object)
+{
+    XfpmConsoleKit *console;
+
+    console = XFPM_CONSOLE_KIT (object);
+    
+    if ( console->priv->bus )
+	dbus_g_connection_unref (console->priv->bus);
+	
+    if ( console->priv->proxy )
+	g_object_unref (console->priv->proxy);
+
+    G_OBJECT_CLASS (xfpm_console_kit_parent_class)->finalize (object);
+}
+
+XfpmConsoleKit *
+xfpm_console_kit_new (void)
+{
+    static gpointer console_obj = NULL;
+    
+    if ( G_LIKELY (console_obj != NULL ) )
+    {
+	g_object_ref (console_obj);
+    }
+    else
+    {
+	console_obj = g_object_new (XFPM_TYPE_CONSOLE_KIT, NULL);
+	g_object_add_weak_pointer (console_obj, &console_obj);
+    }
+    
+    return XFPM_CONSOLE_KIT (console_obj);
+}
+
+void xfpm_console_kit_shutdown (XfpmConsoleKit *console, GError **error)
+{
+    g_return_if_fail (console->priv->proxy != NULL );
+    
+    dbus_g_proxy_call (console->priv->proxy, "Stop", error,
+		       G_TYPE_INVALID,
+		       G_TYPE_BOOLEAN, &console->priv->can_shutdown,
+		       G_TYPE_INVALID);
+}
+
+void xfpm_console_kit_reboot (XfpmConsoleKit *console, GError **error)
+{
+    g_return_if_fail (console->priv->proxy != NULL );
+    
+    dbus_g_proxy_call (console->priv->proxy, "Restart", error,
+		       G_TYPE_INVALID,
+		       G_TYPE_BOOLEAN, &console->priv->can_shutdown,
+		       G_TYPE_INVALID);
+    
+}
diff --git a/src/xfpm-console-kit.h b/src/xfpm-console-kit.h
new file mode 100644
index 0000000..5d5bc1d
--- /dev/null
+++ b/src/xfpm-console-kit.h
@@ -0,0 +1,59 @@
+/*
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __XFPM_CONSOLE_KIT_H
+#define __XFPM_CONSOLE_KIT_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define XFPM_TYPE_CONSOLE_KIT        (xfpm_console_kit_get_type () )
+#define XFPM_CONSOLE_KIT(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_CONSOLE_KIT, XfpmConsoleKit))
+#define XFPM_IS_CONSOLE_KIT(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_CONSOLE_KIT))
+
+typedef struct XfpmConsoleKitPrivate XfpmConsoleKitPrivate;
+
+typedef struct
+{
+    GObject         		parent;
+    XfpmConsoleKitPrivate      *priv;
+    
+} XfpmConsoleKit;
+
+typedef struct
+{
+    GObjectClass 		parent_class;
+    
+} XfpmConsoleKitClass;
+
+GType        			xfpm_console_kit_get_type        (void) G_GNUC_CONST;
+
+XfpmConsoleKit       	       *xfpm_console_kit_new             (void);
+
+void				xfpm_console_kit_shutdown	 (XfpmConsoleKit *console,
+								  GError **error);
+
+void				xfpm_console_kit_reboot		 (XfpmConsoleKit *console,
+								  GError **error);
+
+G_END_DECLS
+
+#endif /* __XFPM_CONSOLE_KIT_H */
diff --git a/src/xfpm-cpu.c b/src/xfpm-cpu.c
deleted file mode 100644
index 80d536e..0000000
--- a/src/xfpm-cpu.c
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include <libxfce4util/libxfce4util.h>
-
-#include "libxfpm/hal-manager.h"
-#include "libxfpm/xfpm-string.h"
-
-#include "xfpm-cpu.h"
-#include "xfpm-adapter.h"
-#include "xfpm-xfconf.h"
-#include "xfpm-config.h"
-#include "xfpm-enum.h"
-
-#ifdef SYSTEM_IS_LINUX /* the end if at the end of the file */
-
-static void xfpm_cpu_finalize   (GObject *object);
-
-#define XFPM_CPU_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_CPU, XfpmCpuPrivate))
-
-struct XfpmCpuPrivate
-{
-    DBusGConnection *bus;
-    XfpmAdapter     *adapter;
-    XfpmXfconf      *conf;
-    
-    gboolean 	     on_battery;
-    guint8           cpu_governors;
-};
-
-G_DEFINE_TYPE(XfpmCpu, xfpm_cpu, G_TYPE_OBJECT)
-
-static gboolean
-xfpm_cpu_check_interface (XfpmCpu *cpu)
-{
-    DBusMessage *message;
-    DBusMessage *reply;
-    DBusError error ;
-    
-    message = dbus_message_new_method_call ("org.freedesktop.Hal",
-					    "/org/freedesktop/Hal",
-					    "org.freedesktop.Hal.Device.CPUFreq",
-					    "JustToCheck");
-    
-    if (!message)
-    	return FALSE;
-    
-    dbus_error_init (&error);
-    
-    reply = 
-    	dbus_connection_send_with_reply_and_block (dbus_g_connection_get_connection(cpu->priv->bus),
-						   message, 2000, &error);
-    dbus_message_unref (message);
-    
-    if ( reply ) dbus_message_unref (reply);
-    
-    if ( dbus_error_is_set(&error) )
-    {
-	if ( !g_strcmp0 (error.name, "org.freedesktop.DBus.Error.UnknownMethod") )
-        {
-            dbus_error_free(&error);
-	    return TRUE;
-        }
-    }
-    return FALSE;
-}
-
-static gchar **
-xfpm_cpu_get_hal_available_governors (XfpmCpu *cpu)
-{
-    gchar **governors = NULL;
-    GError *error = NULL;
-    DBusGProxy *proxy = dbus_g_proxy_new_for_name (cpu->priv->bus,
-						   "org.freedesktop.Hal",
-						   "/org/freedesktop/Hal/devices/computer",
-						   "org.freedesktop.Hal.Device.CPUFreq");
-    if ( !proxy )
-    {
-	g_critical ("Failed to create proxy");
-	goto out;
-    }
-    
-    dbus_g_proxy_call (proxy, "GetCPUFreqAvailableGovernors", &error,
-		       G_TYPE_INVALID,
-		       G_TYPE_STRV, &governors,
-		       G_TYPE_INVALID);
-		       
-    if ( error )
-    {
-	g_warning ("Failed to get cpu governors: %s", error->message);
-	g_error_free (error);
-    }
-    
-    g_object_unref (proxy);
-out:
-    return governors;
-}
-
-static gchar *
-xfpm_cpu_get_hal_current_governor (XfpmCpu *cpu)
-{
-    gchar *governor = NULL;
-    GError *error = NULL;
-    
-    DBusGProxy *proxy = dbus_g_proxy_new_for_name (cpu->priv->bus,
-						   "org.freedesktop.Hal",
-						   "/org/freedesktop/Hal/devices/computer",
-						   "org.freedesktop.Hal.Device.CPUFreq");
-    if ( !proxy )
-    {
-	g_critical ("Failed to create proxy");
-	goto out;
-    }
-    
-    dbus_g_proxy_call (proxy, "GetCPUFreqGovernor", &error,
-		       G_TYPE_INVALID,
-		       G_TYPE_STRING, &governor,
-		       G_TYPE_INVALID);
-    
-    if ( error )
-    {
-	g_warning ("Failed to get cpu governor: %s", error->message);
-	g_error_free (error);
-    }
-    
-    g_object_unref (proxy);
-out:
-    return governor;
-}
-
-static gboolean
-xfpm_cpu_set_hal_governor (XfpmCpu *cpu, const gchar *governor)
-{
-    gboolean ret = FALSE;
-    GError *error = NULL;
-    
-    DBusGProxy *proxy = dbus_g_proxy_new_for_name (cpu->priv->bus,
-						   "org.freedesktop.Hal",
-						   "/org/freedesktop/Hal/devices/computer",
-						   "org.freedesktop.Hal.Device.CPUFreq");
-    if ( !proxy )
-    {
-	g_critical ("Failed to create proxy");
-	goto out;
-    }
-    
-    ret = dbus_g_proxy_call (proxy, "SetCPUFreqGovernor", &error,
-	  		     G_TYPE_STRING, governor,
-			     G_TYPE_INVALID,
-			     G_TYPE_INVALID);
-			     
-    if ( error )
-    {
-	g_warning ("Failed to set cpu governor: %s", error->message);
-	g_error_free (error);
-    }
-    		     
-    g_object_unref (proxy);
-out:
-    return ret;
-}
-
-static void
-xfpm_cpu_set_governor (XfpmCpu *cpu, const gchar *governor)
-{
-    TRACE("Settings cpu governor to %s", governor);
-    
-    if (! xfpm_cpu_set_hal_governor(cpu, governor))
-    {
-    	g_critical ("Unable to set CPU governor to %s", governor);
-    }
-}
-
-static XfpmCpuGovernor 
-_governor_name_to_enum (const gchar *governor)
-{
-    if ( xfpm_strequal(governor, "ondemand") )
-    	return CPU_ONDEMAND;
-    else if ( xfpm_strequal(governor, "powersave") )
-    	return CPU_POWERSAVE;
-    else if ( xfpm_strequal (governor, "performance") )
-    	return CPU_PERFORMANCE;
-    
-    return CPU_UNKNOWN;
-}
-
-static XfpmCpuGovernor
-xfpm_cpu_get_current_governor (XfpmCpu *cpu)
-{
-    gchar *current_governor = NULL;
-    XfpmCpuGovernor governor_enum;
-    
-    current_governor = xfpm_cpu_get_hal_current_governor (cpu);
-    
-    if ( !current_governor )
-    {
-	g_warning ("Unable to get current governor");
-	return CPU_UNKNOWN;
-    }
-    governor_enum = _governor_name_to_enum (current_governor);
-    g_free (current_governor);
-    return governor_enum;
-}
-
-/*
- * Get the available CPU governors on the system
- */
-static void
-xfpm_cpu_get_available_governors (XfpmCpu *cpu)
-{
-    int i;
-    gchar **governors = NULL;
-    governors = xfpm_cpu_get_hal_available_governors (cpu);
-	
-    if ( !governors || !governors[0])
-    {
-    	g_critical ("Unable to get CPU governors\n");
-	return;
-    }
-    
-    for ( i = 0; governors[i]; i++)
-    {
-    	TRACE("found CPU governor %s", governors[i]);
-	if (xfpm_strequal(governors[i], "powersave") )
-	    cpu->priv->cpu_governors |= CPU_POWERSAVE;
-	else if ( xfpm_strequal(governors[i], "ondemand") )
-	    cpu->priv->cpu_governors |= CPU_ONDEMAND;
-	else if ( xfpm_strequal(governors[i], "performance") )
-	    cpu->priv->cpu_governors |= CPU_PERFORMANCE;
-    }
-    hal_manager_free_string_array (governors);
-}
-
-static gboolean
-xfpm_cpu_check_iface (XfpmCpu *cpu)
-{
-    gboolean cpu_freq_iface;
-    
-    cpu_freq_iface = xfpm_cpu_check_interface (cpu);
-		  
-    if (!cpu_freq_iface)
-    {
-	g_warning ("CPU FREQ interface cannot be used");
-	return FALSE;
-    }
-    
-    xfpm_cpu_get_available_governors (cpu);
-    
-    if ( (cpu->priv->cpu_governors & CPU_ONDEMAND || cpu->priv->cpu_governors & CPU_PERFORMANCE)
-	 && (cpu->priv->cpu_governors & CPU_POWERSAVE) )
-	return TRUE;
-    
-    g_warning ("No convenient cpu governors found on the system, cpu frequency control will be disabled");
-    return FALSE;
-}
-
-static void
-xfpm_cpu_set_power_save (XfpmCpu *cpu)
-{
-    if ( xfpm_cpu_get_current_governor (cpu) != CPU_POWERSAVE && cpu->priv->cpu_governors & CPU_POWERSAVE )
-	xfpm_cpu_set_governor (cpu, "powersave");
-}
-
-static void
-xfpm_cpu_set_performance_ondemand (XfpmCpu *cpu)
-{
-    XfpmCpuGovernor gov;
-    
-    gov = xfpm_cpu_get_current_governor (cpu);
-    
-    if ( gov == CPU_ONDEMAND )
-	return;
-	
-    if ( (gov != CPU_ONDEMAND) && (cpu->priv->cpu_governors & CPU_ONDEMAND) )
-	xfpm_cpu_set_governor (cpu, "ondemand");
-    else if ( (gov != CPU_PERFORMANCE) && (cpu->priv->cpu_governors & CPU_PERFORMANCE) )
-	xfpm_cpu_set_governor (cpu, "performance");
-}
-
-static void
-xfpm_cpu_refresh (XfpmCpu *cpu)
-{
-    gboolean power_save;
-    gboolean enable_cpu_freq;
-
-    TRACE ("start");
-    
-    g_object_get (G_OBJECT (cpu->priv->conf),
-		  POWER_SAVE_ON_BATTERY, &power_save,
-		  CPU_FREQ_CONTROL, &enable_cpu_freq,
-		  NULL);
-    
-    if ( enable_cpu_freq == FALSE )
-	return;
-    
-    if (power_save == FALSE)
-    {
-	xfpm_cpu_set_performance_ondemand (cpu);
-	return;
-    }
-	
-    if ( cpu->priv->on_battery )
-	xfpm_cpu_set_power_save (cpu);
-    else 
-	xfpm_cpu_set_performance_ondemand (cpu);
-}
-
-static void
-xfpm_cpu_adapter_changed_cb (XfpmAdapter *adapter, gboolean is_present, XfpmCpu *cpu)
-{
-    cpu->priv->on_battery = !is_present;
-    xfpm_cpu_refresh (cpu);
-}
-
-static void
-xfpm_cpu_settings_changed (GObject *obj, GParamSpec *spec, XfpmCpu *cpu)
-{
-    if ( !g_strcmp0 (spec->name, CPU_FREQ_CONTROL) || !g_strcmp0 (spec->name, POWER_SAVE_ON_BATTERY))
-	xfpm_cpu_refresh (cpu);
-}
-
-static void
-xfpm_cpu_class_init(XfpmCpuClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-    object_class->finalize = xfpm_cpu_finalize;
-
-    g_type_class_add_private(klass,sizeof(XfpmCpuPrivate));
-}
-
-static void
-xfpm_cpu_init(XfpmCpu *cpu)
-{
-    cpu->priv = XFPM_CPU_GET_PRIVATE(cpu);
-    cpu->priv->cpu_governors = 0;
-    
-    cpu->priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
-    
-    if (!cpu->priv->bus)
-	goto out;
-    
-    if ( xfpm_cpu_check_iface (cpu))
-    {
-	cpu->priv->adapter       = xfpm_adapter_new ();
-	cpu->priv->conf 	 = xfpm_xfconf_new ();
-	
-	g_signal_connect (cpu->priv->adapter, "adapter-changed",
-			  G_CALLBACK(xfpm_cpu_adapter_changed_cb), cpu);
-	
-	g_signal_connect (cpu->priv->conf, "notify",
-			  G_CALLBACK (xfpm_cpu_settings_changed), cpu);
-	
-	cpu->priv->on_battery = !xfpm_adapter_get_present (cpu->priv->adapter);
-	xfpm_cpu_refresh (cpu);
-    }
-    
-out:
-    ;
-}
-
-static void
-xfpm_cpu_finalize(GObject *object)
-{
-    XfpmCpu *cpu;
-
-    cpu = XFPM_CPU(object);
-
-    if ( cpu->priv->conf )
-	g_object_unref (cpu->priv->conf);
-    
-    if ( cpu->priv->conf )
-	g_object_unref (cpu->priv->adapter);
-	
-    if ( cpu->priv->bus )
-	dbus_g_connection_unref (cpu->priv->bus);
-
-    G_OBJECT_CLASS(xfpm_cpu_parent_class)->finalize(object);
-}
-
-XfpmCpu *
-xfpm_cpu_new (void)
-{
-    XfpmCpu *cpu = NULL;
-    cpu = g_object_new (XFPM_TYPE_CPU, NULL);
-    return cpu;
-}
-
-void xfpm_cpu_reload (XfpmCpu *cpu)
-{
-    g_return_if_fail (XFPM_IS_CPU (cpu));
-    
-    cpu->priv->cpu_governors = 0;
-    xfpm_cpu_check_iface (cpu);
-}
-
-#endif /*SYSTEM_IS_LINUX*/
diff --git a/src/xfpm-cpu.h b/src/xfpm-cpu.h
deleted file mode 100644
index 2eda193..0000000
--- a/src/xfpm-cpu.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __XFPM_CPU_H
-#define __XFPM_CPU_H
-
-#include <glib-object.h>
-
-#include "xfpm-config.h"
-
-G_BEGIN_DECLS
-
-#ifdef SYSTEM_IS_LINUX
-
-#define XFPM_TYPE_CPU        (xfpm_cpu_get_type () )
-#define XFPM_CPU(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_CPU, XfpmCpu))
-#define XFPM_IS_CPU(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_CPU))
-
-typedef struct XfpmCpuPrivate XfpmCpuPrivate;
-
-typedef struct
-{
-    GObject		 parent;
-    XfpmCpuPrivate	 *priv;
-    
-} XfpmCpu;
-
-typedef struct
-{
-    GObjectClass parent_class;
-    
-} XfpmCpuClass;
-
-GType          xfpm_cpu_get_type        (void) G_GNUC_CONST;
-XfpmCpu       *xfpm_cpu_new             (void);
-void           xfpm_cpu_reload          (XfpmCpu *cpu);
-
-#endif /*SYSTEM_IS_LINUX*/
-
-G_END_DECLS
-
-#endif /* __XFPM_CPU_H */
diff --git a/src/xfpm-dbus-monitor.c b/src/xfpm-dbus-monitor.c
deleted file mode 100644
index b77b21d..0000000
--- a/src/xfpm-dbus-monitor.c
+++ /dev/null
@@ -1,485 +0,0 @@
-/* * * Copyright (C) 2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <glib.h>
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include <dbus/dbus-glib.h>
-
-#include <libxfce4util/libxfce4util.h>
-
-#include "libxfpm/xfpm-string.h"
-#include "libxfpm/xfpm-dbus.h"
-
-#include "xfpm-dbus-monitor.h"
-#include "xfpm-marshal.h"
-
-static void xfpm_dbus_monitor_finalize   (GObject *object);
-
-#define XFPM_DBUS_MONITOR_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_DBUS_MONITOR, XfpmDBusMonitorPrivate))
-
-struct XfpmDBusMonitorPrivate
-{
-    DBusGConnection *system_bus;
-    DBusGConnection *session_bus;
-
-    DBusGProxy      *system_proxy;
-    DBusGProxy      *session_proxy;
-    
-    GPtrArray       *names_array;
-    GPtrArray 	    *services_array;
-    
-    gboolean	     hal_connected;
-};
-
-typedef struct
-{
-    gchar 	*name;
-    DBusBusType  bus_type;
-    
-} XfpmWatchData;
-
-enum
-{
-    UNIQUE_NAME_LOST,
-    SERVICE_CONNECTION_CHANGED,
-    HAL_CONNECTION_CHANGED,
-    SYSTEM_BUS_CONNECTION_CHANGED,
-    LAST_SIGNAL
-};
-
-static guint signals [LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE (XfpmDBusMonitor, xfpm_dbus_monitor, G_TYPE_OBJECT)
-
-static void
-xfpm_dbus_monitor_free_watch_data (XfpmWatchData *data)
-{
-    g_free (data->name);
-    g_free (data);
-}
-
-static XfpmWatchData *
-xfpm_dbus_monitor_get_watch_data (GPtrArray *array, const gchar *name, DBusBusType bus_type)
-{
-    XfpmWatchData *data;
-    guint i;
-    
-    for ( i = 0; i < array->len; i++)
-    {
-	data = g_ptr_array_index (array, i);
-	if ( !g_strcmp0 (data->name, name) && data->bus_type == bus_type )
-	    return data;
-    }
-    return NULL;
-}
-
-static void
-xfpm_dbus_monitor_unique_connection_name_lost (XfpmDBusMonitor *monitor, DBusBusType bus_type, const gchar *name)
-{
-    XfpmWatchData *watch;
-    guint i = 0;
-    
-    for ( i = 0; i < monitor->priv->names_array->len; i++ )
-    {
-	watch = g_ptr_array_index (monitor->priv->names_array, i);
-	
-	if ( !g_strcmp0 (watch->name, name) && bus_type == watch->bus_type )
-	{
-	    TRACE ("Unique name %s disconnected ", name);
-	    g_signal_emit (G_OBJECT(monitor), signals [UNIQUE_NAME_LOST], 0, 
-			   watch->name, bus_type == DBUS_BUS_SESSION ? TRUE : FALSE);
-	    g_ptr_array_remove (monitor->priv->names_array, watch);
-	    xfpm_dbus_monitor_free_watch_data (watch);
-	}
-    }
-}
-
-static void
-xfpm_dbus_monitor_service_connection_changed (XfpmDBusMonitor *monitor, DBusBusType bus_type, 
-					      const gchar *name, gboolean connected)
-{
-    XfpmWatchData *watch;
-    guint i;
-    
-    /* Simplify things for HAL */
-    if ( !g_strcmp0 (name, "org.freedesktop.Hal") && bus_type == DBUS_BUS_SYSTEM )
-    {
-	monitor->priv->hal_connected = connected;
-	g_signal_emit (G_OBJECT (monitor), signals [HAL_CONNECTION_CHANGED], 0, connected);
-	return;
-    }
-    
-    for ( i = 0; i < monitor->priv->services_array->len; i++)
-    {
-	watch = g_ptr_array_index (monitor->priv->services_array, i);
-	
-	if ( !g_strcmp0 (watch->name, name) && watch->bus_type == bus_type)
-	{
-	    TRACE ("Service %s connection changed %s", name, xfpm_bool_to_string (connected));
-	    g_signal_emit (G_OBJECT (monitor), signals [SERVICE_CONNECTION_CHANGED], 0,
-			   name, connected, bus_type == DBUS_BUS_SESSION ? TRUE : FALSE);
-	}
-    }
-}
-
-static void
-xfpm_dbus_monitor_name_owner_changed (XfpmDBusMonitor *monitor, const gchar *name,
-				      const gchar *prev, const gchar *new, DBusBusType bus_type)
-{
-    if ( strlen (prev) != 0 )
-    {
-	xfpm_dbus_monitor_unique_connection_name_lost (monitor, bus_type, prev);
-	
-	/* Connection has name */
-	if ( strlen (name) != 0 )
-	    xfpm_dbus_monitor_service_connection_changed (monitor, bus_type, name, FALSE);
-    }
-    else if ( strlen (name) != 0 && strlen (new) != 0)
-    {
-	xfpm_dbus_monitor_service_connection_changed (monitor, bus_type, name, TRUE);
-    }
-}
-
-static void
-xfpm_dbus_monitor_session_name_owner_changed_cb (DBusGProxy *proxy, const gchar *name,
-						 const gchar *prev, const gchar *new,
-						 XfpmDBusMonitor *monitor)
-{
-    xfpm_dbus_monitor_name_owner_changed (monitor, name, prev, new, DBUS_BUS_SESSION);
-}
-
-static void
-xfpm_dbus_monitor_system_name_owner_changed_cb  (DBusGProxy *proxy, const gchar *name,
-						 const gchar *prev, const gchar *new,
-						 XfpmDBusMonitor *monitor)
-{
-    xfpm_dbus_monitor_name_owner_changed (monitor, name, prev, new, DBUS_BUS_SYSTEM);
-}
-
-static gboolean
-xfpm_dbus_monitor_query_system_bus_idle (gpointer data)
-{
-    XfpmDBusMonitor *monitor;
-    DBusGConnection *bus;
-    GError *error = NULL;
-
-    bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
-    
-    if ( error )
-    {
-	TRACE ("System bus is not connected  %s:", error->message);
-	g_error_free (error);
-	return TRUE;
-    }
-    
-    /*
-     * This message is catched by xfpm manager then it simply
-     * restarts all the power manager
-     */
-    monitor = XFPM_DBUS_MONITOR (data);
-    g_signal_emit (G_OBJECT (monitor), signals [SYSTEM_BUS_CONNECTION_CHANGED], 0, TRUE);
-    
-    return FALSE;
-}
-
-static void
-xfpm_dbus_monitor_setup_system_watch (XfpmDBusMonitor *monitor)
-{
-    g_timeout_add_seconds (5, (GSourceFunc) xfpm_dbus_monitor_query_system_bus_idle, monitor);
-}
-
-static DBusHandlerResult
-xfpm_dbus_monitor_system_bus_filter (DBusConnection *bus, DBusMessage *message, void *data)
-{
-    XfpmDBusMonitor *monitor;
-    
-    if ( dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected") )
-    {
-	TRACE ("System bus is disconnected");
-	monitor = XFPM_DBUS_MONITOR (data);
-	g_signal_emit (G_OBJECT (monitor), signals [SYSTEM_BUS_CONNECTION_CHANGED], 0, FALSE);
-	
-	xfpm_dbus_monitor_setup_system_watch (monitor);
-	
-	return DBUS_HANDLER_RESULT_HANDLED;
-    }
-    
-    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-}
-
-static void
-xfpm_dbus_monitor_session (XfpmDBusMonitor *monitor)
-{
-    monitor->priv->session_proxy = dbus_g_proxy_new_for_name_owner (monitor->priv->session_bus,
-								    "org.freedesktop.DBus",
-								    "/org/freedesktop/DBus",
-								    "org.freedesktop.DBus",
-								    NULL);
-    if ( !monitor->priv->session_proxy )
-    {
-	g_critical ("Unable to create proxy on /org/freedesktop/DBus");
-	return;
-    }
-    
-    dbus_g_proxy_add_signal (monitor->priv->session_proxy, "NameOwnerChanged", 
-			     G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
-			     
-    dbus_g_proxy_connect_signal (monitor->priv->session_proxy, "NameOwnerChanged",
-				 G_CALLBACK (xfpm_dbus_monitor_session_name_owner_changed_cb), monitor, NULL);
-}
-
-static void
-xfpm_dbus_monitor_system (XfpmDBusMonitor *monitor)
-{
-    monitor->priv->system_proxy = dbus_g_proxy_new_for_name_owner (monitor->priv->system_bus,
-								   "org.freedesktop.DBus",
-								   "/org/freedesktop/DBus",
-								   "org.freedesktop.DBus",
-								   NULL);
-    if ( !monitor->priv->system_proxy )
-    {
-	g_critical ("Unable to create proxy on /org/freedesktop/DBus");
-	return;
-    }
-    
-    dbus_g_proxy_add_signal (monitor->priv->system_proxy, "NameOwnerChanged", 
-			     G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
-			     
-    dbus_g_proxy_connect_signal (monitor->priv->system_proxy, "NameOwnerChanged",
-				 G_CALLBACK (xfpm_dbus_monitor_system_name_owner_changed_cb), monitor, NULL);
-}
-
-static void
-xfpm_dbus_monitor_class_init (XfpmDBusMonitorClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-    signals [UNIQUE_NAME_LOST] =
-    	g_signal_new ("unique-name-lost",
-		      XFPM_TYPE_DBUS_MONITOR,
-		      G_SIGNAL_RUN_LAST,
-		      G_STRUCT_OFFSET (XfpmDBusMonitorClass, unique_name_lost),
-		      NULL, NULL,
-		      _xfpm_marshal_VOID__STRING_BOOLEAN,
-		      G_TYPE_NONE, 2, 
-		      G_TYPE_STRING, G_TYPE_BOOLEAN);
-		     
-    signals [HAL_CONNECTION_CHANGED] =
-    	g_signal_new ("hal-connection-changed",
-		      XFPM_TYPE_DBUS_MONITOR,
-		      G_SIGNAL_RUN_LAST,
-		      G_STRUCT_OFFSET (XfpmDBusMonitorClass, hal_connection_changed),
-		      NULL, NULL,
-		      g_cclosure_marshal_VOID__BOOLEAN,
-		      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
-		      
-    signals [SERVICE_CONNECTION_CHANGED] =
-    	g_signal_new ("service-connection-changed",
-		      XFPM_TYPE_DBUS_MONITOR,
-		      G_SIGNAL_RUN_LAST,
-		      G_STRUCT_OFFSET (XfpmDBusMonitorClass, service_connection_changed),
-		      NULL, NULL,
-		      _xfpm_marshal_VOID__STRING_BOOLEAN_BOOLEAN,
-		      G_TYPE_NONE, 3, G_TYPE_STRING,
-		      G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
-		      
-    signals [SYSTEM_BUS_CONNECTION_CHANGED] =
-    	g_signal_new ("system-bus-connection-changed",
-		      XFPM_TYPE_DBUS_MONITOR,
-		      G_SIGNAL_RUN_LAST,
-		      G_STRUCT_OFFSET (XfpmDBusMonitorClass, system_bus_connection_changed),
-		      NULL, NULL,
-		      g_cclosure_marshal_VOID__BOOLEAN,
-		      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
-		     
-    object_class->finalize = xfpm_dbus_monitor_finalize;
-
-    g_type_class_add_private (klass, sizeof (XfpmDBusMonitorPrivate));
-}
-
-static void
-xfpm_dbus_monitor_init (XfpmDBusMonitor *monitor)
-{
-    monitor->priv = XFPM_DBUS_MONITOR_GET_PRIVATE (monitor);
-    
-    monitor->priv->session_proxy = NULL;
-    monitor->priv->system_proxy  = NULL;
-    
-    monitor->priv->names_array = g_ptr_array_new ();
-    monitor->priv->services_array = g_ptr_array_new ();
-         
-    monitor->priv->session_bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
-    monitor->priv->system_bus  = dbus_g_bus_get (DBUS_BUS_SYSTEM,  NULL);
-    
-    xfpm_dbus_monitor_session (monitor);
-    xfpm_dbus_monitor_system  (monitor);
-    
-    dbus_connection_set_exit_on_disconnect (dbus_g_connection_get_connection (monitor->priv->system_bus), 
-					    FALSE);
-    
-    dbus_connection_add_filter (dbus_g_connection_get_connection (monitor->priv->system_bus),
-			        xfpm_dbus_monitor_system_bus_filter,
-				monitor, 
-				NULL);
-				
-    monitor->priv->hal_connected  = xfpm_dbus_name_has_owner (dbus_g_connection_get_connection (monitor->priv->system_bus), 
-							      "org.freedesktop.Hal");
-							      
-    xfpm_dbus_monitor_add_service (monitor, DBUS_BUS_SESSION, "org.freedesktop.Hal");
-}
-
-static void
-xfpm_dbus_monitor_finalize (GObject *object)
-{
-    XfpmDBusMonitor *monitor;
-
-    monitor = XFPM_DBUS_MONITOR (object);
-    
-    if ( monitor->priv->session_proxy )
-    {
-	dbus_g_proxy_disconnect_signal (monitor->priv->session_proxy, "NameOwnerChanged",
-					G_CALLBACK (xfpm_dbus_monitor_session_name_owner_changed_cb), monitor);
-	g_object_unref (monitor->priv->session_proxy);
-    }
-
-    if ( monitor->priv->system_proxy )
-    {
-	dbus_g_proxy_disconnect_signal (monitor->priv->system_proxy, "NameOwnerChanged",
-				        G_CALLBACK (xfpm_dbus_monitor_system_name_owner_changed_cb), monitor);
-	g_object_unref (monitor->priv->system_proxy);
-    }
-
-    dbus_connection_remove_filter (dbus_g_connection_get_connection (monitor->priv->system_bus),
-				   xfpm_dbus_monitor_system_bus_filter,
-				   monitor);
-
-    dbus_g_connection_unref (monitor->priv->system_bus);
-    dbus_g_connection_unref (monitor->priv->session_bus);
-
-    g_ptr_array_foreach (monitor->priv->names_array, (GFunc) xfpm_dbus_monitor_free_watch_data, NULL);
-    g_ptr_array_foreach (monitor->priv->services_array, (GFunc) xfpm_dbus_monitor_free_watch_data, NULL);
-
-    g_ptr_array_free (monitor->priv->names_array, TRUE);
-    g_ptr_array_free (monitor->priv->services_array, TRUE);
-
-    G_OBJECT_CLASS (xfpm_dbus_monitor_parent_class)->finalize (object);
-}
-
-XfpmDBusMonitor *
-xfpm_dbus_monitor_new (void)
-{
-    static gpointer xfpm_dbus_monitor_object = NULL;
-    
-    if ( G_LIKELY (xfpm_dbus_monitor_object != NULL) )
-    {
-	g_object_ref (xfpm_dbus_monitor_object);
-    }
-    else
-    {
-	xfpm_dbus_monitor_object = g_object_new (XFPM_TYPE_DBUS_MONITOR, NULL);
-	g_object_add_weak_pointer (xfpm_dbus_monitor_object, &xfpm_dbus_monitor_object);
-    }
-    
-    return XFPM_DBUS_MONITOR (xfpm_dbus_monitor_object);
-}
-
-gboolean xfpm_dbus_monitor_add_unique_name (XfpmDBusMonitor *monitor, DBusBusType bus_type, const gchar *unique_name)
-{
-    XfpmWatchData *watch;
-    
-    g_return_val_if_fail (XFPM_IS_DBUS_MONITOR (monitor), FALSE);
-    g_return_val_if_fail (unique_name != NULL, FALSE);
-    
-    /* We have it already */
-    if ( xfpm_dbus_monitor_get_watch_data (monitor->priv->names_array, unique_name, bus_type) )
-	return FALSE;
-	
-    TRACE ("Monitoring application with unique_name %s", unique_name);
-    
-    watch = g_new0 (XfpmWatchData , 1);
-    watch->name = g_strdup (unique_name);
-    watch->bus_type = bus_type;
-    
-    g_ptr_array_add (monitor->priv->names_array, watch);
-    return TRUE;
-}
-
-void xfpm_dbus_monitor_remove_unique_name (XfpmDBusMonitor *monitor, DBusBusType bus_type, const gchar *unique_name)
-{
-    XfpmWatchData *watch;
-    
-    g_return_if_fail (XFPM_IS_DBUS_MONITOR (monitor));
-
-    watch = xfpm_dbus_monitor_get_watch_data (monitor->priv->names_array, unique_name, bus_type);
-    
-    if ( watch )
-    {
-	g_ptr_array_remove (monitor->priv->names_array, watch);
-	xfpm_dbus_monitor_free_watch_data (watch);
-    }
-}
-
-gboolean xfpm_dbus_monitor_add_service (XfpmDBusMonitor *monitor, DBusBusType bus_type, const gchar *service_name)
-{
-    XfpmWatchData *watch;
-    
-    g_return_val_if_fail (XFPM_IS_DBUS_MONITOR (monitor), FALSE);
-    
-    if ( xfpm_dbus_monitor_get_watch_data (monitor->priv->services_array, service_name, bus_type ) )
-	return FALSE;
-	
-    watch = g_new0 (XfpmWatchData , 1);
-    watch->name = g_strdup (service_name);
-    watch->bus_type = bus_type;
-    
-    g_ptr_array_add (monitor->priv->services_array, watch);
-    
-    return TRUE;
-}
-
-void xfpm_dbus_monitor_remove_service (XfpmDBusMonitor *monitor, DBusBusType bus_type, const gchar *service_name)
-{
-    XfpmWatchData *watch;
-    
-    g_return_if_fail (XFPM_IS_DBUS_MONITOR (monitor));
-    
-    watch = xfpm_dbus_monitor_get_watch_data (monitor->priv->services_array, service_name, bus_type);
-    
-    if ( watch )
-    {
-	g_ptr_array_remove (monitor->priv->services_array, watch);
-	xfpm_dbus_monitor_free_watch_data (watch);
-    }
-}
-
-gboolean xfpm_dbus_monitor_hal_connected (XfpmDBusMonitor *monitor)
-{
-    return monitor->priv->hal_connected;
-}
diff --git a/src/xfpm-dbus-monitor.h b/src/xfpm-dbus-monitor.h
deleted file mode 100644
index 8488990..0000000
--- a/src/xfpm-dbus-monitor.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* * 
- *  Copyright (C) 2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __XFPM_DBUS_MONITOR_H
-#define __XFPM_DBUS_MONITOR_H
-
-#include <glib-object.h>
-#include <dbus/dbus.h>
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_DBUS_MONITOR        (xfpm_dbus_monitor_get_type () )
-#define XFPM_DBUS_MONITOR(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_DBUS_MONITOR, XfpmDBusMonitor))
-#define XFPM_IS_DBUS_MONITOR(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_DBUS_MONITOR))
-
-typedef struct XfpmDBusMonitorPrivate XfpmDBusMonitorPrivate;
-
-typedef struct
-{
-    GObject        	 	parent;
-    XfpmDBusMonitorPrivate     *priv;
-    
-} XfpmDBusMonitor;
-
-typedef struct
-{
-    GObjectClass 	parent_class;
-    
-    /*
-     * Unique name connection lost.
-     */
-    void                (*unique_name_lost)			(XfpmDBusMonitor *monitor,
-								 gchar *unique_name,
-								 gboolean on_session);
-								 
-    /*
-     * A Service connection changed.
-     */
-    void                (*service_connection_changed)		(XfpmDBusMonitor *monitor,
-								 gchar *service_name,
-							         gboolean connected,
-								 gboolean on_session);
-								 
-    /*
-     * Hal Connection
-     */
-    void		(*hal_connection_changed)		(XfpmDBusMonitor *monitor,
-								 gboolean connected);
-      
-    /*
-     * DBus: system bus disconnected
-     */
-    void		(*system_bus_connection_changed)  	(XfpmDBusMonitor *monitor,
-								 gboolean connected);
-    
-} XfpmDBusMonitorClass;
-
-GType        		xfpm_dbus_monitor_get_type        	(void) G_GNUC_CONST;
-
-XfpmDBusMonitor        *xfpm_dbus_monitor_new             	(void);
-
-gboolean                xfpm_dbus_monitor_add_unique_name     	(XfpmDBusMonitor *monitor,
-								 DBusBusType bus_type,
-								 const gchar *unique_name);
-								   
-void                    xfpm_dbus_monitor_remove_unique_name    (XfpmDBusMonitor *monitor,
-								 DBusBusType bus_type,
-								 const gchar *unique_name);
-
-gboolean		xfpm_dbus_monitor_add_service	  	(XfpmDBusMonitor *monitor,
-								 DBusBusType bus_type,
-								 const gchar *service_name);
-
-void			xfpm_dbus_monitor_remove_service  	(XfpmDBusMonitor *monitor,
-								 DBusBusType bus_type,
-								 const gchar *service_name);
-
-gboolean		xfpm_dbus_monitor_hal_connected		(XfpmDBusMonitor *monitor);
-
-G_END_DECLS
-
-#endif /* __XFPM_DBUS_MONITOR_H */
diff --git a/src/xfpm-debug.c b/src/xfpm-debug.c
deleted file mode 100644
index 7228926..0000000
--- a/src/xfpm-debug.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib.h>
-#include <glib-object.h>
-#include <glib/gprintf.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-
-#include "xfpm-debug.h"
-
-#if defined(DEBUG) && defined(G_HAVE_ISO_VARARGS)
-
-void xfpm_debug_enum (const gchar *func, const gchar *file, gint line, 
-		      const gchar *text, gint v_enum, GType type)
-{
-    gchar *content = NULL;
-    GValue __value__ = { 0, };
-
-    g_value_init (&__value__, type);
-    g_value_set_enum (&__value__, v_enum);
-    
-    content = g_strdup_value_contents (&__value__);
-    
-    fprintf(stdout, "TRACE[%s:%d] %s(): %s : %s", file, line , func, text, content);
-    fprintf(stdout, "\n");
-    
-    g_value_unset (&__value__);						
-    g_free (content);
-}
-
-void xfpm_debug_enum_full (const gchar *func, const gchar *file, gint line,
-			   gint v_enum, GType type, const gchar *format, ...)
-{
-    va_list args;
-    gchar *buffer;
-    
-    gchar *content = NULL;
-    GValue __value__ = { 0, };
-    
-    g_value_init (&__value__, type);
-    g_value_set_enum (&__value__, v_enum);
-    
-    content = g_strdup_value_contents (&__value__);
-    
-    va_start (args, format);
-    g_vasprintf (&buffer, format, args);
-    va_end (args);
-	
-    fprintf(stdout, "TRACE[%s:%d] %s(): ", file, line, func);
-    fprintf(stdout, "%s: %s", buffer, content);
-    fprintf(stdout, "\n");
-    
-    g_value_unset (&__value__);	
-    g_free (content);
-    g_free (buffer);
-}
-
-#endif /* #ifdef DEBUG && defined(G_HAVE_ISO_VARARGS)*/
diff --git a/src/xfpm-debug.h b/src/xfpm-debug.h
deleted file mode 100644
index ff4cace..0000000
--- a/src/xfpm-debug.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __XFPM_DEBUG_H
-#define __XFPM_DEBUG_H
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdarg.h>
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-#if defined(DEBUG) && defined(G_HAVE_ISO_VARARGS)
-
-#define XFPM_DEBUG_ENUM(_text, _value, _type)\
-    xfpm_debug_enum (__func__, __FILE__, __LINE__, _text, _value, _type)
-
-#define XFPM_DEBUG_ENUM_FULL(_value, _type, ...)\
-    xfpm_debug_enum_full (__func__, __FILE__, __LINE__, _value, _type, __VA_ARGS__)
-
-void		xfpm_debug_enum 	(const gchar *func,
-					 const gchar *file,
-					 gint line,
-					 const gchar *text,
-					 gint v_enum, 
-					 GType type);
-					 
-void		xfpm_debug_enum_full    (const gchar *func,
-					 const gchar *file,
-					 gint line,
-					 gint v_enum,
-					 GType type,
-					 const gchar *format,
-					 ...);
-
-#else
-
-#define XFPM_DEBUG_ENUM(_text, _value, _type)
-#define XFPM_DEBUG_ENUM_FULL(_value, _type, ...)
-
-#endif
-
-G_END_DECLS
-
-#endif /* __XFPM_DEBUG_H */
diff --git a/src/xfpm-disks.c b/src/xfpm-disks.c
new file mode 100644
index 0000000..bde079f
--- /dev/null
+++ b/src/xfpm-disks.c
@@ -0,0 +1,279 @@
+/*
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <dbus/dbus-glib.h>
+
+#include "xfpm-disks.h"
+#include "xfpm-polkit.h"
+#include "xfpm-xfconf.h"
+#include "xfpm-power.h"
+#include "xfpm-config.h"
+#include "xfpm-debug.h"
+
+static void xfpm_disks_finalize   (GObject *object);
+
+#define XFPM_DISKS_GET_PRIVATE(o) \
+(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_DISKS, XfpmDisksPrivate))
+
+struct XfpmDisksPrivate
+{
+    XfpmXfconf      *conf;
+    XfpmPower       *power;
+    XfpmPolkit      *polkit;
+    
+    DBusGConnection *bus;
+    DBusGProxy      *proxy;
+    gchar           *cookie;
+    gboolean         set;
+    gboolean         can_spin;
+};
+
+G_DEFINE_TYPE (XfpmDisks, xfpm_disks, G_TYPE_OBJECT)
+
+static void
+xfpm_disks_class_init (XfpmDisksClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    object_class->finalize = xfpm_disks_finalize;
+
+    g_type_class_add_private (klass, sizeof (XfpmDisksPrivate));
+}
+
+static void
+xfpm_disks_disable_spin_down_timeouts (XfpmDisks *disks)
+{
+    GError *error = NULL;
+    
+    disks->priv->set = FALSE;
+    
+    XFPM_DEBUG ("Clearing spin down timeout");
+    
+    dbus_g_proxy_call (disks->priv->proxy, "DriveUnsetAllSpindownTimeouts", &error,
+		       G_TYPE_STRING, disks->priv->cookie,
+		       G_TYPE_INVALID,
+		       G_TYPE_INVALID);
+		       
+    if ( error )
+    {
+	g_warning ("Failed to unset spindown timeouts : %s", error->message);
+	g_error_free (error);
+	disks->priv->set = TRUE;
+    }
+    
+    g_free (disks->priv->cookie);
+    disks->priv->cookie = NULL;
+}
+
+static void
+xfpm_disks_enable_spin_down_timeouts (XfpmDisks *disks, gint timeout)
+{
+    GError *error = NULL;
+    const gchar **options = { NULL };
+    
+    disks->priv->set = TRUE;
+    
+    XFPM_DEBUG ("Setting spin down timeout %d", timeout);
+    
+    dbus_g_proxy_call (disks->priv->proxy, "DriveSetAllSpindownTimeouts", &error,
+		       G_TYPE_INT, timeout,
+		       G_TYPE_STRV, options,
+		       G_TYPE_INVALID,
+		       G_TYPE_STRING, &disks->priv->cookie,
+		       G_TYPE_INVALID);
+		       
+    if ( error )
+    {
+	g_warning ("Failed to set spindown timeouts : %s", error->message);
+	g_error_free (error);
+	disks->priv->set = FALSE;
+    }
+}
+
+static void
+xfpm_disks_set_spin_timeouts (XfpmDisks *disks)
+{
+    gboolean enabled;
+    gboolean on_battery;
+    gint timeout = 0;
+    
+    if (!disks->priv->can_spin )
+	return;
+    
+    g_object_get (G_OBJECT (disks->priv->power),
+		  "on-battery", &on_battery,
+		  NULL);
+
+    if ( !on_battery )
+    {
+	g_object_get (G_OBJECT (disks->priv->conf),
+		      SPIN_DOWN_ON_AC, &enabled,
+		      SPIN_DOWN_ON_AC_TIMEOUT, &timeout,
+		      NULL);
+    }
+    else
+    {
+	g_object_get (G_OBJECT (disks->priv->conf),
+		      SPIN_DOWN_ON_BATTERY, &enabled,
+		      SPIN_DOWN_ON_BATTERY_TIMEOUT, &timeout,
+		      NULL);
+    }
+    
+    XFPM_DEBUG ("On Battery=%d spin_down_enabled=%d timeout=%d\n", on_battery, enabled, timeout);
+    
+    if ( !enabled )
+    {
+	if ( disks->priv->set && disks->priv->cookie )
+	    xfpm_disks_disable_spin_down_timeouts (disks);
+    }
+    else if ( timeout != 0 && timeout > 120 && !disks->priv->set)
+    {
+	xfpm_disks_enable_spin_down_timeouts (disks, timeout);
+    }
+}
+
+static void
+xfpm_disks_get_is_auth_to_spin (XfpmDisks *disks)
+{
+    disks->priv->can_spin = xfpm_polkit_check_auth (disks->priv->polkit, 
+						    "org.freedesktop.devicekit.disks.drive-set-spindown");
+						    
+    XFPM_DEBUG ("Is auth to spin down disks : %d", disks->priv->can_spin);
+}
+
+static void
+xfpm_disks_init (XfpmDisks *disks)
+{
+    GError *error = NULL;
+    
+    disks->priv = XFPM_DISKS_GET_PRIVATE (disks);
+    
+    disks->priv->can_spin = FALSE;
+    disks->priv->bus    = NULL;
+    disks->priv->proxy  = NULL;
+    disks->priv->conf   = NULL;
+    disks->priv->power    = NULL;
+    disks->priv->cookie = NULL;
+    disks->priv->polkit = NULL;
+    
+    disks->priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+    
+    if ( error )
+    {
+	g_critical ("Unable to get system bus connection : %s", error->message);
+	g_error_free (error);
+	goto out;
+    }
+    
+    disks->priv->proxy = dbus_g_proxy_new_for_name (disks->priv->bus,
+						    "org.freedesktop.DeviceKit.Disks",
+						    "/org/freedesktop/DeviceKit/Disks",
+						    "org.freedesktop.DeviceKit.Disks");
+						      
+    if ( !disks->priv->proxy )
+    {
+	g_warning ("Unable to create proxy for 'org.freedesktop.DeviceKit.Disks'");
+	goto out;
+    }
+
+    disks->priv->conf = xfpm_xfconf_new ();
+    disks->priv->power  = xfpm_power_get    ();
+    disks->priv->polkit = xfpm_polkit_get ();
+
+    xfpm_disks_get_is_auth_to_spin (disks);
+    
+    g_signal_connect_swapped (disks->priv->polkit, "auth-changed",
+			      G_CALLBACK (xfpm_disks_get_is_auth_to_spin), disks);
+
+    g_signal_connect_swapped (disks->priv->power, "on-battery-changed",
+			      G_CALLBACK (xfpm_disks_set_spin_timeouts), disks);
+
+    g_signal_connect_swapped (disks->priv->conf, "notify::" SPIN_DOWN_ON_AC,
+			      G_CALLBACK (xfpm_disks_set_spin_timeouts), disks);
+			
+    g_signal_connect_swapped (disks->priv->conf, "notify::" SPIN_DOWN_ON_AC_TIMEOUT,
+			      G_CALLBACK (xfpm_disks_set_spin_timeouts), disks);
+			      
+    g_signal_connect_swapped (disks->priv->conf, "notify::" SPIN_DOWN_ON_BATTERY,
+			      G_CALLBACK (xfpm_disks_set_spin_timeouts), disks);
+    
+    g_signal_connect_swapped (disks->priv->conf, "notify::" SPIN_DOWN_ON_BATTERY_TIMEOUT,
+			      G_CALLBACK (xfpm_disks_set_spin_timeouts), disks);
+			      
+    xfpm_disks_set_spin_timeouts (disks);
+    
+out:
+    ;
+
+}
+
+static void
+xfpm_disks_finalize (GObject *object)
+{
+    XfpmDisks *disks;
+
+    disks = XFPM_DISKS (object);
+
+    if (disks->priv->can_spin && disks->priv->set )
+	xfpm_disks_disable_spin_down_timeouts (disks);
+    
+    if ( disks->priv->bus )
+	dbus_g_connection_unref (disks->priv->bus);
+	
+    if ( disks->priv->proxy )
+	g_object_unref (disks->priv->proxy);
+	
+    if ( disks->priv->polkit )
+	g_object_unref (disks->priv->polkit);
+	
+    if ( disks->priv->conf )
+	g_object_unref (disks->priv->conf);
+	
+    if ( disks->priv->power )
+	g_object_unref (disks->priv->power );
+
+    G_OBJECT_CLASS (xfpm_disks_parent_class)->finalize (object);
+}
+
+XfpmDisks *
+xfpm_disks_new (void)
+{
+    XfpmDisks *disks = NULL;
+    disks = g_object_new (XFPM_TYPE_DISKS, NULL);
+    return disks;
+}
+
+gboolean xfpm_disks_get_can_spin (XfpmDisks *disks)
+{
+    return disks->priv->can_spin;
+}
+
+gboolean xfpm_disks_kit_is_running (XfpmDisks *disks)
+{
+    return disks->priv->proxy != NULL ? TRUE : FALSE;
+}
diff --git a/src/xfpm-disks.h b/src/xfpm-disks.h
new file mode 100644
index 0000000..61a8080
--- /dev/null
+++ b/src/xfpm-disks.h
@@ -0,0 +1,57 @@
+/*
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __XFPM_DISKS_H
+#define __XFPM_DISKS_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define XFPM_TYPE_DISKS        (xfpm_disks_get_type () )
+#define XFPM_DISKS(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_DISKS, XfpmDisks))
+#define XFPM_IS_DISKS(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_DISKS))
+
+typedef struct XfpmDisksPrivate XfpmDisksPrivate;
+
+typedef struct
+{
+    GObject         	  parent;
+    XfpmDisksPrivate     *priv;
+    
+} XfpmDisks;
+
+typedef struct
+{
+    GObjectClass 	  parent_class;
+    
+} XfpmDisksClass;
+
+GType        		  xfpm_disks_get_type        (void) G_GNUC_CONST;
+
+XfpmDisks                *xfpm_disks_new             (void);
+
+gboolean		  xfpm_disks_get_can_spin    (XfpmDisks *disks);
+
+gboolean		  xfpm_disks_kit_is_running  (XfpmDisks *disks);
+
+G_END_DECLS
+
+#endif /* __XFPM_DISKS_H */
diff --git a/src/xfpm-dpms.c b/src/xfpm-dpms.c
index 8118815..0b306e8 100644
--- a/src/xfpm-dpms.c
+++ b/src/xfpm-dpms.c
@@ -31,14 +31,13 @@
 
 #include <libxfce4util/libxfce4util.h>
 
-#include "libxfpm/xfpm-string.h"
-#include "libxfpm/xfpm-common.h"
+#include "xfpm-common.h"
 
 #include "xfpm-dpms.h"
-#include "xfpm-adapter.h"
+#include "xfpm-power.h"
 #include "xfpm-xfconf.h"
-#include "xfpm-screen-saver.h"
 #include "xfpm-config.h"
+#include "xfpm-debug.h"
 
 #ifdef HAVE_DPMS
 
@@ -50,18 +49,18 @@ static void xfpm_dpms_finalize   (GObject *object);
 struct XfpmDpmsPrivate
 {
     XfpmXfconf      *conf;
-    XfpmAdapter     *adapter;
-    XfpmScreenSaver *saver;
+    XfpmPower         *power;
     
-    gboolean       dpms_capable;
-    gboolean       inhibited;
-    gboolean       on_battery;
+    gboolean         dpms_capable;
+    gboolean         inhibited;
     
-    gulong	   switch_off_timeout_id;
-    gulong	   switch_on_timeout_id;
+    gboolean         on_battery;
+    
+    gulong	     switch_off_timeout_id;
+    gulong	     switch_on_timeout_id;
 };
 
-G_DEFINE_TYPE(XfpmDpms, xfpm_dpms, G_TYPE_OBJECT)
+G_DEFINE_TYPE (XfpmDpms, xfpm_dpms, G_TYPE_OBJECT)
 
 static void
 xfpm_dpms_set_timeouts (XfpmDpms *dpms, guint16 standby, guint16 suspend, guint off)
@@ -72,7 +71,7 @@ xfpm_dpms_set_timeouts (XfpmDpms *dpms, guint16 standby, guint16 suspend, guint
     
     if ( standby != x_standby || suspend != x_suspend || off != x_off )
     {
-	TRACE ("Settings dpms: standby=%d suspend=%d off=%d\n", standby, suspend, off);
+	XFPM_DEBUG ("Settings dpms: standby=%d suspend=%d off=%d\n", standby, suspend, off);
 	DPMSSetTimeouts (GDK_DISPLAY(), standby,
 					suspend,
 					off );
@@ -92,10 +91,7 @@ xfpm_dpms_disable (XfpmDpms *dpms)
 	g_warning ("Cannot get DPMSInfo");
 	
     if ( state )
-    {
-	xfpm_dpms_set_timeouts (dpms, 0, 0, 0);
 	DPMSDisable (GDK_DISPLAY());
-    }
 }
 
 /*
@@ -200,24 +196,15 @@ xfpm_dpms_settings_changed_cb (GObject *obj, GParamSpec *spec, XfpmDpms *dpms)
 {
     if ( g_str_has_prefix (spec->name, "dpms"))
     {
-	TRACE ("Configuration changed");
+	XFPM_DEBUG ("Configuration changed");
 	xfpm_dpms_refresh (dpms);
     }
 }
 
 static void
-xfpm_dpms_adapter_changed_cb (XfpmAdapter *adapter, gboolean present, XfpmDpms *dpms)
+xfpm_dpms_on_battery_changed_cb (XfpmPower *power, gboolean on_battery, XfpmDpms *dpms)
 {
-    dpms->priv->on_battery = !present;
-    xfpm_dpms_refresh (dpms);
-}
-
-static void
-xfpm_dpms_inhibit_changed_cb (XfpmScreenSaver *saver, gboolean inhibited, XfpmDpms *dpms)
-{
-    dpms->priv->inhibited = inhibited;
-    TRACE ("Inhibit changed %s", xfpm_bool_to_string (inhibited));
-    
+    dpms->priv->on_battery = on_battery;
     xfpm_dpms_refresh (dpms);
 }
 
@@ -245,20 +232,19 @@ xfpm_dpms_init(XfpmDpms *dpms)
 
     if ( dpms->priv->dpms_capable )
     {
-	dpms->priv->adapter = xfpm_adapter_new ();
-	dpms->priv->saver   = xfpm_screen_saver_new ();
+	dpms->priv->power     = xfpm_power_get ();
 	dpms->priv->conf    = xfpm_xfconf_new  ();
     
-	g_signal_connect (dpms->priv->saver, "screen-saver-inhibited",
-			  G_CALLBACK(xfpm_dpms_inhibit_changed_cb), dpms);
-    
-	g_signal_connect (dpms->priv->adapter, "adapter-changed",
-			  G_CALLBACK(xfpm_dpms_adapter_changed_cb), dpms);
+	g_signal_connect (dpms->priv->power, "on-battery-changed",
+			  G_CALLBACK(xfpm_dpms_on_battery_changed_cb), dpms);
 			  
 	g_signal_connect (dpms->priv->conf, "notify",
 			  G_CALLBACK (xfpm_dpms_settings_changed_cb), dpms);
 			  
-	dpms->priv->on_battery = !xfpm_adapter_get_present (dpms->priv->adapter);
+	g_object_get (G_OBJECT (dpms->priv->power),
+		      "on-battery", &dpms->priv->on_battery,
+		      NULL);
+	
 	xfpm_dpms_refresh (dpms);
     }
     else
@@ -275,8 +261,7 @@ xfpm_dpms_finalize(GObject *object)
     dpms = XFPM_DPMS (object);
     
     g_object_unref (dpms->priv->conf);
-    g_object_unref (dpms->priv->adapter);
-    g_object_unref ( dpms->priv->saver);
+    g_object_unref (dpms->priv->power);
 
     G_OBJECT_CLASS(xfpm_dpms_parent_class)->finalize(object);
 }
@@ -301,7 +286,7 @@ void xfpm_dpms_force_level (XfpmDpms *dpms, CARD16 level)
     CARD16 current_level;
     BOOL current_state;
     
-    TRACE ("start");
+    XFPM_DEBUG ("start");
     
     if ( !dpms->priv->dpms_capable )
 	goto out;
@@ -314,13 +299,13 @@ void xfpm_dpms_force_level (XfpmDpms *dpms, CARD16 level)
 
     if ( !current_state )
     {
-	TRACE ("DPMS is disabled");
+	XFPM_DEBUG ("DPMS is disabled");
 	goto out;
     }
 
     if ( current_level != level )
     {
-	TRACE ("Forcing DPMS mode %d", level);
+	XFPM_DEBUG ("Forcing DPMS mode %d", level);
 	
 	if ( !DPMSForceLevel (GDK_DISPLAY (), level ) )
 	{
@@ -333,7 +318,7 @@ void xfpm_dpms_force_level (XfpmDpms *dpms, CARD16 level)
     }
     else
     {
-	TRACE ("No need to change DPMS mode, current_level=%d requested_level=%d", current_level, level);
+	XFPM_DEBUG ("No need to change DPMS mode, current_level=%d requested_level=%d", current_level, level);
     }
     
     out:
diff --git a/src/xfpm-engine.c b/src/xfpm-engine.c
deleted file mode 100644
index e31cd60..0000000
--- a/src/xfpm-engine.c
+++ /dev/null
@@ -1,957 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <glib.h>
-
-#include <libxfce4util/libxfce4util.h>
-
-#include "libxfpm/hal-manager.h"
-#include "libxfpm/xfpm-string.h"
-#include "libxfpm/xfpm-common.h"
-#include "libxfpm/xfpm-notify.h"
-
-#ifdef HAVE_DPMS
-#include "xfpm-dpms.h"
-#endif
-
-#include "xfpm-engine.h"
-#include "xfpm-supply.h"
-#include "xfpm-adapter.h"
-#include "xfpm-xfconf.h"
-#include "xfpm-cpu.h"
-#include "xfpm-button.h"
-#include "xfpm-inhibit.h"
-#include "xfpm-backlight.h"
-#include "xfpm-screen-saver.h"
-#include "xfpm-shutdown.h"
-#include "xfpm-button-hal.h"
-#include "egg-idletime.h"
-#include "xfpm-errors.h"
-#include "xfpm-config.h"
-#include "xfpm-enum-types.h"
-#include "xfpm-debug.h"
-
-static void xfpm_engine_finalize (GObject * object);
-
-static void xfpm_engine_dbus_class_init (XfpmEngineClass * klass);
-static void xfpm_engine_dbus_init (XfpmEngine * engine);
-
-#define XFPM_ENGINE_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_ENGINE, XfpmEnginePrivate))
-
-struct XfpmEnginePrivate
-{
-    XfpmXfconf 		*conf;
-    XfpmSupply 		*supply;
-    XfpmNotify 		*notify;
-#ifdef SYSTEM_IS_LINUX
-    XfpmCpu 		*cpu;
-#endif
-    XfpmBacklight 	*bk;
-    XfpmAdapter 	*adapter;
-    XfpmInhibit 	*inhibit;
-    XfpmShutdown        *shutdown;
-    XfpmButton          *button;
-    XfpmButtonHal       *bt_hal;
-    EggIdletime         *idle;
-    XfpmScreenSaver     *srv;
-#ifdef HAVE_DPMS
-    XfpmDpms *dpms;
-#endif
-    gboolean inhibited;
-
-    guint8 power_management;
-    gboolean on_battery;
-    gboolean is_laptop;
-
-    gboolean has_lcd_brightness;
-    
-};
-
-enum
-{
-    ON_BATTERY_CHANGED,
-    LOW_BATTERY_CHANGED,
-    LAST_SIGNAL
-};
-
-static guint signals [LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE (XfpmEngine, xfpm_engine, G_TYPE_OBJECT)
-
-static gboolean xfpm_engine_do_suspend (XfpmEngine * engine)
-{
-    GError *error = NULL;
-
-    xfpm_suspend (engine->priv->shutdown, &error);
-
-    if (error)
-    {
-	g_warning ("%s", error->message);
-	g_error_free (error);
-    }
-    return FALSE;
-}
-
-static gboolean
-xfpm_engine_do_hibernate (XfpmEngine * engine)
-{
-    GError *error = NULL;
-
-    xfpm_hibernate (engine->priv->shutdown, &error);
-
-    if (error)
-    {
-	g_warning ("%s", error->message);
-	g_error_free (error);
-    }
-    return FALSE;
-}
-
-static gboolean
-xfpm_engine_do_shutdown (XfpmEngine * engine)
-{
-    GError *error = NULL;
-
-    xfpm_shutdown (engine->priv->shutdown, &error);
-
-    if (error)
-    {
-	g_warning ("%s", error->message);
-	g_error_free (error);
-    }
-    return FALSE;
-}
-
-/*
- * Map of int to strings shutdown values
- */
-static const gchar * G_GNUC_PURE
-xfpm_int_to_shutdown_string (gint val)
-{
-    if ( val == XFPM_DO_NOTHING )
-	return "Nothing";
-    else if ( val == XFPM_DO_SUSPEND)
-	return "Suspend";
-    else if ( val == XFPM_DO_HIBERNATE)
-	return "Hibernate";
-    else if ( val == XFPM_DO_SHUTDOWN)
-	return "Shutdown";
-    else if ( val == XFPM_ASK)
-	return "Ask";
-    
-    return "Invalid";
-}
-
-static void
-xfpm_engine_shutdown_request (XfpmEngine * engine,
-			      XfpmShutdownRequest shutdown, gboolean critical)
-{
-    gboolean lock_screen;
-    const gchar *action = xfpm_int_to_shutdown_string (shutdown);
-
-    g_object_get (G_OBJECT (engine->priv->conf),
-		  LOCK_SCREEN_ON_SLEEP, &lock_screen,
-		  NULL);
-
-    if (xfpm_strequal (action, "Nothing"))
-    {
-	TRACE ("Button is disabled in configuration");
-	return;
-    }
-    else if ( xfpm_strequal (action, "Ask") && xfpm_strequal (action, "Invalid"))
-    {
-	g_warning ("Invalid configuration action %s", action);
-	return;
-    }
-    else if ( engine->priv->inhibited == TRUE && critical == FALSE )
-    {
-	return;
-    }
-    else
-    {
-	TRACE ("Going to do %s\n", action);
-
-	if (shutdown == XFPM_DO_SHUTDOWN)
-	{
-	    xfpm_engine_do_shutdown (engine);
-	}
-	else if (shutdown == XFPM_DO_HIBERNATE)
-	{
-	    xfpm_shutdown_add_callback (engine->priv->shutdown, 
-					(GSourceFunc) xfpm_engine_do_hibernate,
-					lock_screen,
-					engine);
-	}
-	else if (shutdown == XFPM_DO_SUSPEND)
-	{
-	    xfpm_shutdown_add_callback (engine->priv->shutdown, 
-					(GSourceFunc) xfpm_engine_do_suspend,
-					lock_screen,
-					engine);
-	}
-
-    }
-}
-
-static void
-xfpm_engine_shutdown_request_battery_cb (XfpmSupply * supply,
-					 gboolean critical,
-					 XfpmShutdownRequest action,
-					 XfpmEngine * engine)
-{
-    if ( engine->priv->inhibited && critical == FALSE ) /* We can ignore the request here */
-	return;
-	
-    xfpm_engine_shutdown_request (engine, action, critical);
-}
-
-static void
-xfpm_engine_lid_event (XfpmButtonHal *bt_hal, gboolean pressed, XfpmEngine *engine)
-{
-    XfpmLidTriggerAction action;
-    
-    g_object_get (G_OBJECT (engine->priv->conf),
-		      engine->priv->on_battery ? LID_SWITCH_ON_BATTERY_CFG : LID_SWITCH_ON_AC_CFG, &action,
-		      NULL);
-
-    if ( pressed )
-    {
-	XFPM_DEBUG_ENUM ("LID close event", action, XFPM_TYPE_LID_TRIGGER_ACTION);
-	
-	if ( action == LID_TRIGGER_NOTHING )
-	{
-	    if ( !xfpm_is_multihead_connected () )
-		xfpm_dpms_force_level (engine->priv->dpms, DPMSModeOff);
-	}
-	else if ( action == LID_TRIGGER_LOCK_SCREEN )
-	{
-	    if ( !xfpm_is_multihead_connected () )
-		xfpm_lock_screen ();
-	}
-	else 
-	    xfpm_engine_shutdown_request (engine, action, FALSE);
-    }
-    else
-    {
-	XFPM_DEBUG_ENUM ("LID opened", action, XFPM_TYPE_LID_TRIGGER_ACTION);
-	xfpm_dpms_force_level (engine->priv->dpms, DPMSModeOn);
-    }
-}
-
-static void
-xfpm_engine_button_pressed_cb (XfpmButton *button,
-			       XfpmButtonKey type, XfpmEngine * engine)
-{
-    XfpmShutdownRequest req = XFPM_DO_NOTHING;
-    
-    XFPM_DEBUG_ENUM ("Received button press event", type, XFPM_TYPE_BUTTON_KEY);
-  
-    if ( engine->priv->inhibited )
-    {
-	TRACE("Power manager automatic sleep is currently disabled");
-	return;
-    }
-    
-    if ( type == BUTTON_MON_BRIGHTNESS_DOWN || type == BUTTON_MON_BRIGHTNESS_UP )
-	return;
-    
-    if ( type == BUTTON_POWER_OFF )
-    {
-	g_object_get (G_OBJECT (engine->priv->conf),
-		      POWER_SWITCH_CFG, &req,
-		      NULL);
-    }
-    else if ( type == BUTTON_SLEEP )
-    {
-	g_object_get (G_OBJECT (engine->priv->conf),
-		      SLEEP_SWITCH_CFG, &req,
-		      NULL);
-    }
-    else if ( type == BUTTON_HIBERNATE )
-    {
-	g_object_get (G_OBJECT (engine->priv->conf),
-		      HIBERNATE_SWITCH_CFG, &req,
-		      NULL);
-    }
-    else
-    {
-	g_return_if_reached ();
-    }
-
-    XFPM_DEBUG_ENUM ("Shutdown request : ", req, XFPM_TYPE_SHUTDOWN_REQUEST);
-	
-    if ( req == XFPM_ASK )
-	xfpm_shutdown_ask (engine->priv->shutdown);
-    else
-	xfpm_engine_shutdown_request (engine, req, FALSE);
-}
-
-static void
-xfpm_engine_check_hal_iface (XfpmEngine * engine)
-{
-    gboolean can_suspend, can_hibernate, caller;
-
-    g_object_get (G_OBJECT (engine->priv->shutdown),
-		  "caller-privilege", &caller,
-		  "can-suspend", &can_suspend,
-		  "can-hibernate", &can_hibernate,
-		  NULL);
-
-    if ( caller )
-    {
-	if (can_hibernate)
-	    engine->priv->power_management |= SYSTEM_CAN_HIBERNATE;
-	if (can_suspend)
-	    engine->priv->power_management |= SYSTEM_CAN_SUSPEND;
-    }
-
-  //FIXME: Show errors here
-}
-
-static void
-xfpm_engine_supply_notify_cb (GObject *object, GParamSpec *spec, XfpmEngine *engine)
-{
-    gboolean low_power;
-    
-    if ( xfpm_strequal (spec->name, "on-low-battery") )
-    {
-	g_object_get (object, "on-low-battery", &low_power, NULL);
-	TRACE ("On low battery changed %s", xfpm_bool_to_string (low_power));
-	g_signal_emit (G_OBJECT (engine), signals [LOW_BATTERY_CHANGED], 0, low_power);
-    }
-}
-
-static gboolean
-xfpm_engine_load_all (gpointer data)
-{
-    XfpmEngine *engine;
-    HalManager *manager;
-
-    engine = XFPM_ENGINE (data);
-
-    xfpm_engine_check_hal_iface (engine);
-    
-    manager = hal_manager_new ();
-
-    if ( hal_manager_get_is_laptop (manager))
-	engine->priv->is_laptop = TRUE;
-    else
-	engine->priv->is_laptop = FALSE;
-
-    g_object_unref (manager);
-
-#ifdef HAVE_DPMS
-    engine->priv->dpms = xfpm_dpms_new ();
-#endif
-
-#ifdef SYSTEM_IS_LINUX
-    if (engine->priv->is_laptop)
-	engine->priv->cpu = xfpm_cpu_new ();
-#endif
-
-    engine->priv->supply = xfpm_supply_new (engine->priv->power_management);
-    g_signal_connect (G_OBJECT (engine->priv->supply), "shutdown-request",
-		      G_CALLBACK (xfpm_engine_shutdown_request_battery_cb),
-		      engine);
-		      
-    g_signal_connect (G_OBJECT (engine->priv->supply), "notify",
-		      G_CALLBACK (xfpm_engine_supply_notify_cb), engine);
-		      
-    xfpm_supply_monitor (engine->priv->supply);
-
-    engine->priv->button = xfpm_button_new ();
-
-    g_signal_connect (engine->priv->button, "button-pressed",
-		      G_CALLBACK (xfpm_engine_button_pressed_cb), engine);
-
-    engine->priv->bt_hal = xfpm_button_hal_get ();
-    g_signal_connect (engine->priv->bt_hal, "lid_event",
-		      G_CALLBACK (xfpm_engine_lid_event), engine);
-  /*
-   * Brightness HAL
-   */
-    if (engine->priv->is_laptop)
-    {
-	engine->priv->bk = xfpm_backlight_new ();
-	engine->priv->has_lcd_brightness =
-	xfpm_backlight_has_hw (engine->priv->bk);
-    }
-    return FALSE;
-}
-
-static void
-xfpm_engine_adapter_changed_cb (XfpmAdapter * adapter, gboolean present,
-				XfpmEngine * engine)
-{
-    engine->priv->on_battery = !present;
-    g_signal_emit (G_OBJECT (engine), signals [ON_BATTERY_CHANGED], 0, engine->priv->on_battery);
-    egg_idletime_alarm_reset_all (engine->priv->idle);
-}
-
-static void
-xfpm_engine_inhibit_changed_cb (XfpmInhibit * inhibit, gboolean inhibited,
-				XfpmEngine * engine)
-{
-    engine->priv->inhibited = inhibited;
-}
-
-static void
-xfpm_engine_set_inactivity_timeouts (XfpmEngine *engine)
-{
-    guint on_ac, on_battery;
-    
-    g_object_get (G_OBJECT (engine->priv->conf),
-		  ON_AC_INACTIVITY_TIMEOUT, &on_ac,
-		  ON_BATTERY_INACTIVITY_TIMEOUT, &on_battery,
-		  NULL);
-    
-#ifdef DEBUG
-    if ( on_ac == 14 )
-	TRACE ("setting inactivity sleep timeout on ac to never");
-    else
-	TRACE ("setting inactivity sleep timeout on ac to %d", on_ac);
-    if ( on_battery == 14 )
-	TRACE ("setting inactivity sleep timeout on battery to never");
-    else
-	TRACE ("setting inactivity sleep timeout on battery to %d", on_battery);
-#endif
-    
-    if ( on_ac == 14 )
-    {
-	egg_idletime_alarm_remove (engine->priv->idle, TIMEOUT_INACTIVITY_ON_AC );
-    }
-    else
-    {
-	egg_idletime_alarm_set (engine->priv->idle, TIMEOUT_INACTIVITY_ON_AC, on_ac * 1000 * 60);
-    }
-    
-    if ( on_battery == 14 )
-    {
-	egg_idletime_alarm_remove (engine->priv->idle, TIMEOUT_INACTIVITY_ON_BATTERY );
-    }
-    else
-    {
-	egg_idletime_alarm_set (engine->priv->idle, TIMEOUT_INACTIVITY_ON_BATTERY, on_battery * 1000 * 60);
-    }
-}
-
-static void
-xfpm_engine_alarm_timeout_cb (EggIdletime *idle, guint id, XfpmEngine *engine)
-{
-    XfpmShutdownRequest req = XFPM_DO_NOTHING;
-    gchar *sleep_mode;
-    gboolean saver;
-    
-    TRACE ("Alarm inactivity timeout id %d", id);
-    
-    if ( engine->priv->inhibited )
-    {
-	TRACE ("Power manager is currently inhibited");
-	return;
-    }
-    
-    saver = xfpm_screen_saver_get_inhibit (engine->priv->srv);
-    
-    if ( saver )
-    {
-	TRACE ("User disabled sleep on the context menu");
-	return;
-    }
-    
-    g_object_get (G_OBJECT (engine->priv->conf),
-		  INACTIVITY_SLEEP_MODE, &sleep_mode,
-		  NULL);
-		  
-    if ( !g_strcmp0 (sleep_mode, "Suspend") )
-	req = XFPM_DO_SUSPEND;
-    else
-	req = XFPM_DO_HIBERNATE;
-	
-    g_free (sleep_mode);
-
-    if ( id == TIMEOUT_INACTIVITY_ON_AC && engine->priv->on_battery == FALSE )
-	xfpm_engine_shutdown_request (engine, req, FALSE);
-    else if ( id ==  TIMEOUT_INACTIVITY_ON_BATTERY && engine->priv->is_laptop && engine->priv->on_battery  )
-	xfpm_engine_shutdown_request (engine, req, FALSE);
-    
-}
-
-static void
-xfpm_engine_settings_changed_cb (GObject *obj, GParamSpec *spec, XfpmEngine *engine)
-{
-    if ( g_str_has_prefix (spec->name, "inactivity") )
-	xfpm_engine_set_inactivity_timeouts (engine);
-}
-
-static void
-xfpm_engine_class_init (XfpmEngineClass * klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-    signals [ON_BATTERY_CHANGED] = 
-        g_signal_new("on-battery-changed",
-                      XFPM_TYPE_ENGINE,
-                      G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET(XfpmEngineClass, on_battery_changed),
-                      NULL, NULL,
-                      g_cclosure_marshal_VOID__BOOLEAN,
-                      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
-
-    signals [LOW_BATTERY_CHANGED] = 
-        g_signal_new("low-battery-changed",
-                      XFPM_TYPE_ENGINE,
-                      G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET(XfpmEngineClass, low_battery_changed),
-                      NULL, NULL,
-                      g_cclosure_marshal_VOID__BOOLEAN,
-                      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
-
-    object_class->finalize = xfpm_engine_finalize;
-
-    g_type_class_add_private (klass, sizeof (XfpmEnginePrivate));
-
-    xfpm_engine_dbus_class_init (klass);
-}
-
-static void
-xfpm_engine_init (XfpmEngine * engine)
-{
-    engine->priv = XFPM_ENGINE_GET_PRIVATE (engine);
-
-    engine->priv->shutdown = xfpm_shutdown_new ();
-    engine->priv->adapter = xfpm_adapter_new ();
-    engine->priv->notify = xfpm_notify_new ();
-    engine->priv->srv    = xfpm_screen_saver_new ();
-    engine->priv->inhibit = xfpm_inhibit_new ();
-    engine->priv->inhibited = FALSE;
-
-    g_signal_connect (engine->priv->inhibit, "has-inhibit-changed",
-		      G_CALLBACK (xfpm_engine_inhibit_changed_cb), engine);
-
-    engine->priv->conf = NULL;
-    engine->priv->supply = NULL;
-#ifdef HAVE_DPMS
-    engine->priv->dpms = NULL;
-#endif
-
-#ifdef SYSTEM_IS_LINUX
-    engine->priv->cpu = NULL;
-#endif
-
-    engine->priv->button = NULL;
-    engine->priv->bk = NULL;
-
-    engine->priv->power_management = 0;
-
-    xfpm_engine_dbus_init (engine);
-
-    engine->priv->conf = xfpm_xfconf_new ();
-
-    engine->priv->on_battery =
-	!xfpm_adapter_get_present (engine->priv->adapter);
-
-    g_signal_connect (engine->priv->adapter, "adapter-changed",
-		      G_CALLBACK (xfpm_engine_adapter_changed_cb), engine);
-
-    engine->priv->idle    = egg_idletime_new ();
-
-    g_signal_connect (engine->priv->idle, "alarm-expired",
-		      G_CALLBACK (xfpm_engine_alarm_timeout_cb), engine);
-		      
-    g_signal_connect (engine->priv->conf, "notify",
-		      G_CALLBACK (xfpm_engine_settings_changed_cb), engine);
-		    
-    xfpm_engine_set_inactivity_timeouts (engine);
-    
-    g_idle_add ((GSourceFunc)xfpm_engine_load_all, engine);
-}
-
-static void
-xfpm_engine_finalize (GObject * object)
-{
-    XfpmEngine *engine;
-
-    engine = XFPM_ENGINE (object);
-
-    g_object_unref (engine->priv->conf);
-
-    g_object_unref (engine->priv->supply);
-    
-    g_object_unref (engine->priv->button);
-    
-    g_object_unref (engine->priv->idle);
-    g_object_unref (engine->priv->bt_hal);
-
-#ifdef HAVE_DPMS
-    if (engine->priv->dpms)
-	g_object_unref (engine->priv->dpms);
-#endif
-
-#ifdef SYSTEM_IS_LINUX
-    if (engine->priv->cpu)
-	g_object_unref (engine->priv->cpu);
-#endif
-
-    g_object_unref (engine->priv->shutdown);
-
-    g_object_unref (engine->priv->adapter);
-    
-    g_object_unref (engine->priv->srv);
-
-    if (engine->priv->bk)
-	g_object_unref (engine->priv->bk);
-
-    g_object_unref (engine->priv->notify);
-
-    G_OBJECT_CLASS (xfpm_engine_parent_class)->finalize (object);
-}
-
-XfpmEngine *
-xfpm_engine_new (void)
-{
-    XfpmEngine *engine = NULL;
-    engine = g_object_new (XFPM_TYPE_ENGINE, NULL);
-
-    return engine;
-}
-
-void
-xfpm_engine_get_info (XfpmEngine * engine, GHashTable *hash)
-{
-    guint8 mapped_buttons;
-    gboolean user_privilege = FALSE;
-    gboolean can_suspend = FALSE;
-    gboolean can_hibernate = FALSE;
-    gboolean has_sleep_button = FALSE;
-    gboolean has_hibernate_button = FALSE;
-    gboolean has_power_button = FALSE;
-    
-    g_return_if_fail (XFPM_IS_ENGINE (engine));
-
-    g_object_get (G_OBJECT (engine->priv->shutdown),
-		  "caller-privilege", &user_privilege,
-		  "can-suspend", &can_suspend,
-		  "can-hibernate", &can_hibernate, NULL);
-		  
-   
-    mapped_buttons = xfpm_button_get_mapped (engine->priv->button);
-    
-    if ( mapped_buttons & SLEEP_KEY )
-	has_sleep_button = TRUE;
-    if ( mapped_buttons & HIBERNATE_KEY )
-	has_hibernate_button = TRUE;
-    if ( mapped_buttons & POWER_KEY )
-	has_power_button = TRUE;
-	
-    g_hash_table_insert (hash, g_strdup ("caller-privilege"), g_strdup (xfpm_bool_to_string (user_privilege)));
-    g_hash_table_insert (hash, g_strdup ("can-suspend"), g_strdup (xfpm_bool_to_string (can_suspend)));
-    g_hash_table_insert (hash, g_strdup ("can-hibernate"), g_strdup (xfpm_bool_to_string (can_hibernate)));
-    g_hash_table_insert (hash, g_strdup ("system-laptop"), g_strdup (xfpm_bool_to_string (engine->priv->is_laptop)));
-    g_hash_table_insert (hash, g_strdup ("has-brightness"), g_strdup (xfpm_bool_to_string (engine->priv->has_lcd_brightness)));
-    g_hash_table_insert (hash, g_strdup ("sleep-button"), g_strdup (xfpm_bool_to_string (has_sleep_button)));
-    g_hash_table_insert (hash, g_strdup ("power-button"), g_strdup (xfpm_bool_to_string (has_power_button)));
-    g_hash_table_insert (hash, g_strdup ("hibernate-button"), g_strdup (xfpm_bool_to_string (has_hibernate_button)));
-}
-
-void xfpm_engine_reload_hal_objects (XfpmEngine *engine)
-{
-    g_return_if_fail (XFPM_IS_ENGINE (engine));
-    
-    xfpm_adapter_reload (engine->priv->adapter);
-    xfpm_supply_reload  (engine->priv->supply);
-    
-    
-    xfpm_shutdown_reload (engine->priv->shutdown);
-    
-    if ( engine->priv->is_laptop )
-    {
-	xfpm_backlight_reload (engine->priv->bk);
-#ifdef SYSTEM_IS_LINUX
-	xfpm_cpu_reload       (engine->priv->cpu);
-#endif
-    }
-}
-
-/*
- * 
- * DBus server implementation for org.freedesktop.PowerManagement
- * 
- */
-static gboolean xfpm_engine_dbus_shutdown (XfpmEngine *engine,
-					   GError **error);
-
-static gboolean xfpm_engine_dbus_reboot   (XfpmEngine *engine,
-					   GError **error);
-					   
-static gboolean xfpm_engine_dbus_hibernate (XfpmEngine * engine,
-					    GError **error);
-
-static gboolean xfpm_engine_dbus_suspend (XfpmEngine * engine,
-					  GError ** error);
-
-static gboolean xfpm_engine_dbus_can_reboot (XfpmEngine * engine,
-					     gboolean * OUT_can_reboot, 
-					     GError ** error);
-
-static gboolean xfpm_engine_dbus_can_shutdown (XfpmEngine * engine,
-					       gboolean * OUT_can_reboot, 
-					       GError ** error);
-
-static gboolean xfpm_engine_dbus_can_hibernate (XfpmEngine * engine,
-						gboolean * OUT_can_hibernate,
-						GError ** error);
-
-static gboolean xfpm_engine_dbus_can_suspend (XfpmEngine * engine,
-					      gboolean * OUT_can_suspend,
-					      GError ** error);
-
-static gboolean xfpm_engine_dbus_get_power_save_status (XfpmEngine * engine,
-						        gboolean * OUT_save_power,
-						        GError ** error);
-
-static gboolean xfpm_engine_dbus_get_on_battery (XfpmEngine * engine,
-						 gboolean * OUT_on_battery,
-						 GError ** error);
-
-static gboolean xfpm_engine_dbus_get_low_battery (XfpmEngine * engine,
-						  gboolean * OUT_low_battery,
-						  GError ** error);
-
-#include "org.freedesktop.PowerManagement.h"
-
-static void
-xfpm_engine_dbus_class_init (XfpmEngineClass * klass)
-{
-    dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass),
-				     &dbus_glib_xfpm_engine_object_info);
-}
-
-static void
-xfpm_engine_dbus_init (XfpmEngine * engine)
-{
-    DBusGConnection *bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
-
-    dbus_g_connection_register_g_object (bus,
-				         "/org/freedesktop/PowerManagement",
-				         G_OBJECT (engine));
-}
-
-static gboolean xfpm_engine_dbus_shutdown (XfpmEngine *engine,
-					   GError **error)
-{
-    gboolean caller_privilege, can_hibernate;
-    
-    TRACE ("Hibernate message received");
-
-    g_object_get (G_OBJECT (engine->priv->shutdown),
-		  "caller-privilege", &caller_privilege,
-		  "can-hibernate", &can_hibernate, NULL);
-
-    if (!caller_privilege)
-    {
-	g_set_error (error, XFPM_ERROR, XFPM_ERROR_PERMISSION_DENIED,
-		    _("Permission denied"));
-	return FALSE;
-    }
-
-    if ( engine->priv->inhibited )
-	return TRUE;
-
-    xfpm_shutdown (engine->priv->shutdown, NULL);
-    
-    return TRUE;
-}
-
-static gboolean xfpm_engine_dbus_reboot   (XfpmEngine *engine,
-					   GError **error)
-{
-    gboolean caller_privilege;
-    
-    TRACE ("Reboot message received");
-
-    g_object_get (G_OBJECT (engine->priv->shutdown),
-		  "caller-privilege", &caller_privilege,
-		  NULL);
-
-    if (!caller_privilege)
-    {
-	g_set_error (error, XFPM_ERROR, XFPM_ERROR_PERMISSION_DENIED,
-		    _("Permission denied"));
-	return FALSE;
-    }
-
-    if ( engine->priv->inhibited )
-	return TRUE;
-
-    xfpm_reboot (engine->priv->shutdown, NULL);
-    
-    return TRUE;
-}
-
-static gboolean
-xfpm_engine_dbus_hibernate (XfpmEngine * engine, GError ** error)
-{
-    gboolean caller_privilege, can_hibernate;
-    
-    TRACE ("Hibernate message received");
-
-    g_object_get (G_OBJECT (engine->priv->shutdown),
-		  "caller-privilege", &caller_privilege,
-		  "can-hibernate", &can_hibernate, NULL);
-
-    if (!caller_privilege)
-    {
-	g_set_error (error, XFPM_ERROR, XFPM_ERROR_PERMISSION_DENIED,
-		    _("Permission denied"));
-	return FALSE;
-    }
-
-    if (!can_hibernate)
-    {
-	g_set_error (error, XFPM_ERROR, XFPM_ERROR_NO_HARDWARE_SUPPORT,
-		    _("Hibernate not supported"));
-	return FALSE;
-    }
-
-    xfpm_engine_shutdown_request (engine, XFPM_DO_HIBERNATE, FALSE);
-
-    return TRUE;
-}
-
-static gboolean
-xfpm_engine_dbus_suspend (XfpmEngine * engine, GError ** error)
-{
-    gboolean caller_privilege, can_suspend;
-    TRACE ("Suspend message received");
-
-    g_object_get (G_OBJECT (engine->priv->shutdown),
-		  "caller-privilege", &caller_privilege,
-		  "can-suspend", &can_suspend, NULL);
-
-    if (!caller_privilege)
-    {
-	g_set_error (error, XFPM_ERROR, XFPM_ERROR_PERMISSION_DENIED,
-		    _("Permission denied"));
-	return FALSE;
-    }
-
-    if (!can_suspend)
-    {
-	g_set_error (error, XFPM_ERROR, XFPM_ERROR_NO_HARDWARE_SUPPORT,
-		    _("Suspend not supported"));
-	return FALSE;
-    }
-
-    xfpm_engine_shutdown_request (engine, XFPM_DO_SUSPEND, FALSE);
-
-    return TRUE;
-}
-
-static gboolean
-xfpm_engine_dbus_can_shutdown (XfpmEngine * engine,
-			       gboolean * OUT_can_shutdown, GError ** error)
-{
-    TRACE ("Can shutdown message received");
-    
-    g_object_get (G_OBJECT (engine->priv->shutdown),
-		  "caller-privilege", OUT_can_shutdown, NULL);
-
-    return TRUE;
-}
-
-static gboolean
-xfpm_engine_dbus_can_reboot (XfpmEngine * engine,
-			     gboolean * OUT_can_reboot, GError ** error)
-{
-    TRACE ("Can reboot message received");
-    
-    g_object_get (G_OBJECT (engine->priv->shutdown),
-		  "caller-privilege", OUT_can_reboot, NULL);
-
-    return TRUE;
-}
-
-static gboolean
-xfpm_engine_dbus_can_hibernate (XfpmEngine * engine,
-				gboolean * OUT_can_hibernate, GError ** error)
-{
-    TRACE ("Can hibernate message received");
-    g_object_get (G_OBJECT (engine->priv->shutdown),
-		    "can-hibernate", OUT_can_hibernate, NULL);
-
-    return TRUE;
-}
-
-static gboolean
-xfpm_engine_dbus_can_suspend (XfpmEngine * engine,
-			      gboolean * OUT_can_suspend, GError ** error)
-{
-    TRACE ("Can suspend message received");
-    g_object_get (G_OBJECT (engine->priv->shutdown),
-		  "can-suspend", OUT_can_suspend, NULL);
-
-    return TRUE;
-}
-
-static gboolean xfpm_engine_dbus_get_power_save_status (XfpmEngine * engine,
-						        gboolean * OUT_save_power,
-						        GError ** error)
-{
-    gboolean save_power;
-    
-    TRACE ("Can power save message received");
-    
-    g_object_get (G_OBJECT (engine->priv->conf),
-		  POWER_SAVE_ON_BATTERY, &save_power,
-		  NULL);
-		  
-    *OUT_save_power = save_power && engine->priv->on_battery;
-    
-    return TRUE;
-}
-
-static gboolean
-xfpm_engine_dbus_get_on_battery (XfpmEngine * engine,
-				 gboolean * OUT_on_battery, GError ** error)
-{
-    TRACE ("On battery message received");
-    *OUT_on_battery = engine->priv->on_battery;
-
-    return TRUE;
-}
-
-static gboolean
-xfpm_engine_dbus_get_low_battery (XfpmEngine * engine,
-				  gboolean * OUT_low_battery, GError ** error)
-{
-    TRACE ("On low battery message received");
-    *OUT_low_battery = xfpm_supply_on_low_battery (engine->priv->supply);
-
-    return TRUE;
-}
diff --git a/src/xfpm-engine.h b/src/xfpm-engine.h
deleted file mode 100644
index 3c98c16..0000000
--- a/src/xfpm-engine.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __XFPM_ENGINE_H
-#define __XFPM_ENGINE_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_ENGINE        (xfpm_engine_get_type () )
-#define XFPM_ENGINE(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_ENGINE, XfpmEngine))
-#define XFPM_IS_ENGINE(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_ENGINE))
-
-typedef struct XfpmEnginePrivate XfpmEnginePrivate;
-
-typedef struct
-{
-    GObject		  parent;
-    XfpmEnginePrivate	 *priv;
-    
-} XfpmEngine;
-
-typedef struct
-{
-    GObjectClass 	  parent_class;
-    
-    void                  (*on_battery_changed)       	(XfpmEngine *engine,
-							 gboolean    on_battery);
-    
-    void                  (*low_battery_changed)       	(XfpmEngine *engine,
-							 gboolean    low_battery);
-							 
-} XfpmEngineClass;
-
-GType        	  	  xfpm_engine_get_type        	(void) G_GNUC_CONST;
-XfpmEngine       	 *xfpm_engine_new             	(void);
-
-void              	  xfpm_engine_get_info        	(XfpmEngine *engine,
-							 GHashTable *hash);
-							 						       
-void                     xfpm_engine_reload_hal_objects (XfpmEngine *engine);
-G_END_DECLS
-
-#endif /* __XFPM_ENGINE_H */
diff --git a/src/xfpm-enum-glib.h b/src/xfpm-enum-glib.h
index 41989c6..9a5c3ff 100644
--- a/src/xfpm-enum-glib.h
+++ b/src/xfpm-enum-glib.h
@@ -29,6 +29,44 @@ G_BEGIN_DECLS
 
 typedef enum
 {
+    XFPM_DEVICE_TYPE_UNKNOWN,
+    XFPM_DEVICE_TYPE_LINE_POWER,
+    XFPM_DEVICE_TYPE_BATTERY,
+    XFPM_DEVICE_TYPE_UPS,
+    XFPM_DEVICE_TYPE_MONITOR,
+    XFPM_DEVICE_TYPE_MOUSE,
+    XFPM_DEVICE_TYPE_KBD,
+    XFPM_DEVICE_TYPE_PDA,
+    XFPM_DEVICE_TYPE_PHONE
+    
+} XfpmDeviceType;
+  
+typedef enum
+{
+    XFPM_DEVICE_STATE_UNKNOWN,
+    XFPM_DEVICE_STATE_CHARGING,
+    XFPM_DEVICE_STATE_DISCHARGING,
+    XFPM_DEVICE_STATE_EMPTY,
+    XFPM_DEVICE_STATE_FULLY_CHARGED,
+    XFPM_DEVICE_STATE_PENDING_CHARGING,
+    XFPM_DEVICE_STATE_PENDING_DISCHARGING
+    
+} XfpmDeviceState;
+
+/*
+ * Order matters
+ */
+typedef enum
+{
+    XFPM_BATTERY_CHARGE_UNKNOWN,
+    XFPM_BATTERY_CHARGE_CRITICAL,
+    XFPM_BATTERY_CHARGE_LOW,
+    XFPM_BATTERY_CHARGE_OK
+    
+} XfpmBatteryCharge;
+
+typedef enum
+{
     XFPM_DO_NOTHING,
     XFPM_DO_SUSPEND,
     XFPM_DO_HIBERNATE,
@@ -48,19 +86,6 @@ typedef enum
 
 typedef enum
 {
-    BATTERY_FULLY_CHARGED,
-    BATTERY_NOT_FULLY_CHARGED,
-    BATTERY_IS_CHARGING,
-    BATTERY_IS_DISCHARGING,
-    BATTERY_CHARGE_LOW,
-    BATTERY_CHARGE_CRITICAL,
-    BATTERY_NOT_PRESENT,
-    BATTERY_STATE_UNKNOWN
-    
-} XfpmBatteryState;
-
-typedef enum
-{
     BUTTON_UNKNOWN = 0,
     BUTTON_POWER_OFF,
     BUTTON_HIBERNATE,
@@ -81,7 +106,6 @@ typedef enum
     
 } XfpmShowIcon;
 
-
 G_END_DECLS
 
 #endif /* __XFPM_ENUM_GLIB_H */
diff --git a/src/xfpm-enum.h b/src/xfpm-enum.h
index 283c980..7eccb49 100644
--- a/src/xfpm-enum.h
+++ b/src/xfpm-enum.h
@@ -41,10 +41,11 @@ typedef enum
 typedef enum
 {
     LID_KEY   		= (1 << 0),
-    BRIGHTNESS_KEY	= (1 << 1),
-    SLEEP_KEY 		= (1 << 2),
-    HIBERNATE_KEY	= (1 << 3),
-    POWER_KEY 		= (1 << 4)
+    BRIGHTNESS_KEY_UP	= (1 << 1),
+    BRIGHTNESS_KEY_DOWN	= (1 << 2),
+    SLEEP_KEY 		= (1 << 3),
+    HIBERNATE_KEY	= (1 << 4),
+    POWER_KEY 		= (1 << 5)
     
 } XfpmKeys;
 
diff --git a/src/xfpm-inhibit.c b/src/xfpm-inhibit.c
index aac461b..5de6e09 100644
--- a/src/xfpm-inhibit.c
+++ b/src/xfpm-inhibit.c
@@ -36,6 +36,7 @@
 #include "xfpm-inhibit.h"
 #include "xfpm-dbus-monitor.h"
 #include "xfpm-errors.h"
+#include "xfpm-debug.h"
 
 static void xfpm_inhibit_finalize   (GObject *object);
 
@@ -87,13 +88,13 @@ xfpm_inhibit_has_inhibit_changed (XfpmInhibit *inhibit)
 {
     if ( inhibit->priv->array->len == 0 && inhibit->priv->inhibited == TRUE )
     {
-	TRACE("Inhibit removed");
+	XFPM_DEBUG("Inhibit removed");
 	inhibit->priv->inhibited = FALSE;
 	g_signal_emit (G_OBJECT(inhibit), signals[HAS_INHIBIT_CHANGED], 0, inhibit->priv->inhibited);
     }
     else if ( inhibit->priv->array->len != 0 && inhibit->priv->inhibited == FALSE )
     {
-	TRACE("Inhibit added");
+	XFPM_DEBUG("Inhibit added");
 	inhibit->priv->inhibited = TRUE;
 	g_signal_emit (G_OBJECT(inhibit), signals[HAS_INHIBIT_CHANGED], 0, inhibit->priv->inhibited);
     }
@@ -196,7 +197,7 @@ xfpm_inhibit_connection_lost_cb (XfpmDBusMonitor *monitor, gchar *unique_name,
     
     if ( inhibitor )
     {
-	TRACE ("Application=%s with unique connection name=%s disconnected", inhibitor->app_name, inhibitor->unique_name);
+	XFPM_DEBUG ("Application=%s with unique connection name=%s disconnected", inhibitor->app_name, inhibitor->unique_name);
 	xfpm_inhibit_free_inhibitor (inhibit, inhibitor);
 	xfpm_inhibit_has_inhibit_changed (inhibit);
     }
@@ -335,7 +336,7 @@ static void xfpm_inhibit_inhibit  	(XfpmInhibit *inhibit,
     sender = dbus_g_method_get_sender (context);
     cookie = xfpm_inhibit_add_application (inhibit, IN_appname, sender);
      
-    TRACE("Inhibit send application name=%s reason=%s sender=%s", IN_appname, IN_reason ,sender);
+    XFPM_DEBUG("Inhibit send application name=%s reason=%s sender=%s", IN_appname, IN_reason ,sender);
     
     xfpm_inhibit_has_inhibit_changed (inhibit);
     
@@ -349,7 +350,7 @@ static gboolean xfpm_inhibit_un_inhibit    (XfpmInhibit *inhibit,
 					    guint        IN_cookie,
 					    GError     **error)
 {
-    TRACE("UnHibit message received");
+    XFPM_DEBUG("UnHibit message received");
     
     if (!xfpm_inhibit_remove_application_by_cookie (inhibit, IN_cookie))
     {
@@ -366,7 +367,7 @@ static gboolean xfpm_inhibit_has_inhibit   (XfpmInhibit *inhibit,
 					    gboolean    *OUT_has_inhibit,
 					    GError     **error)
 {
-    TRACE("Has Inhibit message received");
+    XFPM_DEBUG("Has Inhibit message received");
 
     *OUT_has_inhibit = inhibit->priv->inhibited;
 
@@ -380,7 +381,7 @@ static gboolean xfpm_inhibit_get_inhibitors (XfpmInhibit *inhibit,
     guint i;
     Inhibitor *inhibitor;
 
-    TRACE ("Get Inhibitors message received");
+    XFPM_DEBUG ("Get Inhibitors message received");
     
     *OUT_inhibitors = g_new (gchar *, inhibit->priv->array->len + 1);
     
diff --git a/src/xfpm-main.c b/src/xfpm-main.c
index 3004567..766a001 100644
--- a/src/xfpm-main.c
+++ b/src/xfpm-main.c
@@ -26,26 +26,26 @@
 #include <stdlib.h>
 #include <string.h>
 
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <signal.h>
 
 #include <gtk/gtk.h>
 #include <glib.h>
 
 #include <libxfce4util/libxfce4util.h>
+#include <libxfce4ui/libxfce4ui.h>
 
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
 
-#include "libxfpm/xfpm-dbus.h"
-#include "libxfpm/xfpm-popups.h"
+#include "xfpm-dbus.h"
+#include "xfpm-debug.h"
+#include "xfpm-common.h"
 
 #include "xfce-power-manager-dbus-client.h"
 #include "xfpm-manager.h"
-#include "xfpm-session.h"
-
-static gchar    *client_id = NULL;
-static gboolean no_daemon  = FALSE;
 
 static void G_GNUC_NORETURN
 show_version (void)
@@ -64,58 +64,190 @@ xfpm_quit_signal (gint sig, gpointer data)
 {
     XfpmManager *manager = (XfpmManager *) data;
     
-    TRACE ("sig %d", sig);
+    XFPM_DEBUG ("sig %d", sig);
     
     if ( sig != SIGHUP )
 	xfpm_manager_stop (manager);
 }
 
+static const gchar *
+xfpm_bool_to_local_string (gboolean value)
+{
+    return value == TRUE ? _("True") : _("False");
+}
+
+static void
+xfpm_dump (GHashTable *hash)
+{
+    gboolean has_battery;
+    gboolean auth_suspend;
+    gboolean auth_hibernate;
+    gboolean can_suspend;
+    gboolean can_hibernate;
+    gboolean can_shutdown;
+    gboolean has_lcd_brightness;
+    gboolean has_sleep_button;
+    gboolean has_hibernate_button;
+    gboolean has_power_button;
+    gboolean has_lid;
+    gboolean can_spin_down;
+    gboolean devkit_disk;
+    
+    has_battery = xfpm_string_to_bool (g_hash_table_lookup (hash, "has-battery"));
+    has_lid = xfpm_string_to_bool (g_hash_table_lookup (hash, "has-lid"));
+    can_suspend = xfpm_string_to_bool (g_hash_table_lookup (hash, "can-suspend"));
+    can_hibernate = xfpm_string_to_bool (g_hash_table_lookup (hash, "can-hibernate"));
+    auth_suspend = xfpm_string_to_bool (g_hash_table_lookup (hash, "auth-suspend"));
+    auth_hibernate = xfpm_string_to_bool (g_hash_table_lookup (hash, "auth-hibernate"));
+    has_lcd_brightness = xfpm_string_to_bool (g_hash_table_lookup (hash, "has-brightness"));
+    has_sleep_button = xfpm_string_to_bool (g_hash_table_lookup (hash, "sleep-button"));
+    has_power_button = xfpm_string_to_bool (g_hash_table_lookup (hash, "power-button"));
+    has_hibernate_button = xfpm_string_to_bool (g_hash_table_lookup (hash, "hibernate-button"));
+    can_shutdown = xfpm_string_to_bool (g_hash_table_lookup (hash, "can-shutdown"));
+    can_spin_down = xfpm_string_to_bool (g_hash_table_lookup (hash, "can-spin"));
+    devkit_disk = xfpm_string_to_bool (g_hash_table_lookup (hash, "devkit-disk"));
+	
+    g_print ("---------------------------------------------------\n");
+    g_print ("       Xfce power manager version %s\n", VERSION);
+#ifdef WITH_HAL
+    g_print (_("With HAL support\n"));
+#else
+    g_print (_("Without HAL support\n"));
+#endif
+#ifdef HAVE_POLKIT
+    g_print (_("With policykit support\n"));
+#else
+    g_print (_("Without policykit support\n"));
+#endif
+#ifdef WITH_NETWORK_MANAGER
+    g_print (_("With network manager support\n"));
+#else
+    g_print (_("Without network manager support\n"));
+#endif
+#ifdef HAVE_DPMS
+    g_print (_("With DPMS support\n"));
+#else
+    g_print (_("Without DPMS support\n"));
+#endif
+    g_print ("---------------------------------------------------\n");
+    g_print ( "%s: %s\n"
+	      "%s: %s\n"
+	      "%s: %s\n"
+	      "%s: %s\n"
+	      "%s: %s\n"
+	      "%s: %s\n"
+	      "%s: %s\n"
+	      "%s: %s\n"
+	      "%s: %s\n"
+	      "%s: %s\n"
+	      "%s: %s\n"
+	      "%s: %s\n"
+	      "%s: %s\n",
+	     _("Has LID"),
+	     xfpm_bool_to_local_string (has_lid),
+	     _("Can suspend"),
+	     xfpm_bool_to_local_string (can_suspend),
+	     _("Can hibernate"),
+	     xfpm_bool_to_local_string (can_hibernate),
+	     _("Can spin down hard disks"),
+	     xfpm_bool_to_local_string (devkit_disk),
+	     _("Authorized to suspend"),
+	     xfpm_bool_to_local_string (auth_suspend),
+	     _("Authorized to hibernate"),
+	     xfpm_bool_to_local_string (auth_hibernate),
+	     _("Authorized to shutdown"),
+	     xfpm_bool_to_local_string (can_shutdown),
+	     _("Authorized to spin down hard disks"),
+	     xfpm_bool_to_local_string (can_spin_down),
+	     _("Has brightness panel"),
+	     xfpm_bool_to_local_string (has_lcd_brightness),
+	     _("Has power button"),
+	     xfpm_bool_to_local_string (has_power_button),
+	     _("Has hibernate button"),
+	     xfpm_bool_to_local_string (has_hibernate_button),
+	     _("Has sleep button"),
+	      xfpm_bool_to_local_string (has_sleep_button),
+	     _("Has LID"),
+	      xfpm_bool_to_local_string (has_lid));
+}
+
+static void
+xfpm_dump_remote (DBusGConnection *bus)
+{
+    DBusGProxy *proxy;
+    GError *error = NULL;
+    GHashTable *hash;
+    
+    proxy = dbus_g_proxy_new_for_name (bus,
+				       "org.xfce.PowerManager",
+				       "/org/xfce/PowerManager",
+				       "org.xfce.Power.Manager");
+	
+    xfpm_manager_dbus_client_get_config (proxy, 
+					 &hash,
+					 &error);
+					     
+    g_object_unref (proxy);
+    
+    if ( error )
+    {
+	g_error ("%s", error->message);
+	exit (EXIT_FAILURE);
+    }
+    
+    xfpm_dump (hash);
+    g_hash_table_destroy (hash);
+}
+
 static void G_GNUC_NORETURN
-xfpm_start (DBusGConnection *bus)
+xfpm_start (DBusGConnection *bus, const gchar *client_id, gboolean dump)
 {
     XfpmManager *manager;
-    XfpmSession *session;
     GError *error = NULL;
     
-    TRACE ("Starting the power manager");
-    session = xfpm_session_new ();
-    
-    if ( client_id != NULL )
-	xfpm_session_set_client_id (session, client_id);
-	
-    xfpm_session_real_init (session);
+    XFPM_DEBUG ("Starting the power manager");
     
-    manager = xfpm_manager_new (bus);
+    manager = xfpm_manager_new (bus, client_id);
     
     if ( xfce_posix_signal_handler_init (&error)) 
     {
-        xfce_posix_signal_handler_set_handler(SIGHUP,
-                                              xfpm_quit_signal,
-                                              manager, NULL);
+        xfce_posix_signal_handler_set_handler (SIGHUP,
+                                               xfpm_quit_signal,
+                                               manager, NULL);
 
-        xfce_posix_signal_handler_set_handler(SIGINT,
-                                              xfpm_quit_signal,
-					      manager, NULL);
+        xfce_posix_signal_handler_set_handler (SIGINT,
+                                               xfpm_quit_signal,
+					       manager, NULL);
 
-        xfce_posix_signal_handler_set_handler(SIGTERM,
-                                              xfpm_quit_signal,
-                                              manager, NULL);
+        xfce_posix_signal_handler_set_handler (SIGTERM,
+                                               xfpm_quit_signal,
+                                               manager, NULL);
     } 
     else 
     {
         g_warning ("Unable to set up POSIX signal handlers: %s", error->message);
-        g_error_free(error);
+        g_error_free (error);
     }
 
     xfpm_manager_start (manager);
+    
+    if ( dump )
+    {
+	GHashTable *hash;
+	hash = xfpm_manager_get_config (manager);
+	xfpm_dump (hash);
+	g_hash_table_destroy (hash);
+    }
+
+    
     gtk_main ();
     
-    g_object_unref (session);
+    g_object_unref (manager);
     
     exit (EXIT_SUCCESS);
 }
 
-int main(int argc, char **argv)
+int main (int argc, char **argv)
 {
     DBusGConnection *bus;
     GError *error = NULL;
@@ -126,11 +258,17 @@ int main(int argc, char **argv)
     gboolean config     = FALSE;
     gboolean version    = FALSE;
     gboolean reload     = FALSE;
+    gboolean no_daemon  = FALSE;
+    gboolean debug      = FALSE;
+    gboolean dump       = FALSE;
+    gchar   *client_id  = NULL;
     
     GOptionEntry option_entries[] = 
     {
 	{ "run",'r', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &run, NULL, NULL },
 	{ "no-daemon",'\0' , G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &no_daemon, N_("Do not daemonize"), NULL },
+	{ "debug",'\0' , G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &debug, N_("Enable debugging"), NULL },
+	{ "dump",'\0' , G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &dump, N_("Dump all information"), NULL },
 	{ "restart", '\0', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &reload, N_("Restart the running instance of Xfce power manager"), NULL},
 	{ "customize", 'c', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &config, N_("Show the configuration dialog"), NULL },
 	{ "quit", 'q', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &quit, N_("Quit any running xfce power manager"), NULL },
@@ -145,19 +283,21 @@ int main(int argc, char **argv)
     dbus_g_thread_init ();
 
     xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8");
-
+    
+    g_set_application_name (PACKAGE_NAME);
+    
     if (!gtk_init_with_args (&argc, &argv, (gchar *)"", option_entries, (gchar *)PACKAGE, &error)) 
     {
-        if(G_LIKELY(error)) 
+        if (G_LIKELY (error)) 
         {
-            g_printerr("%s: %s.\n", G_LOG_DOMAIN, error->message);
-            g_printerr(_("Type '%s --help' for usage."), G_LOG_DOMAIN);
-            g_printerr("\n");
-            g_error_free(error);
+            g_printerr ("%s: %s.\n", G_LOG_DOMAIN, error->message);
+            g_printerr (_("Type '%s --help' for usage."), G_LOG_DOMAIN);
+            g_printerr ("\n");
+            g_error_free (error);
         }
         else
         {
-            g_error("Unable to open display.");
+            g_error ("Unable to open display.");
 	}
 
         return EXIT_FAILURE;
@@ -165,58 +305,49 @@ int main(int argc, char **argv)
     
     if ( version )    
     {
-	show_version();
+	show_version ();
     }
     
-    if ( run + quit + config + version > 1 )
-    {
-	g_printerr(_("Too many arguments"));
-	g_printerr("\n");
-	g_printerr(_("Type '%s --help' for usage."), G_LOG_DOMAIN);
-	g_printerr("\n");
-	return EXIT_FAILURE;
-    }
+    xfpm_debug_init (debug);
 
-    if ( no_daemon == FALSE && daemon(0,0) )
+    if ( dump == FALSE && debug == FALSE && no_daemon == FALSE && daemon(0,0) )
     {
 	g_critical ("Could not daemonize");
     }
     
-    bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+    bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
             
     if ( error )
     {
-	gchar *message = g_strdup(_("Unable to get connection to the message bus session"));
-	message = g_strdup_printf("%s: ",error->message);
-	
-	xfpm_error (_("Xfce Power Manager"),
-		    message );
-			   
-	g_error ("%s: \n", message);
+	xfce_dialog_show_error (NULL, 
+				error, 
+				"%s",
+				_("Unable to get connection to the message bus session"));
+	g_error ("%s: \n", error->message);
     }
     
     if ( quit )
     {
-	if (!xfpm_dbus_name_has_owner(dbus_g_connection_get_connection(bus), 
-				      "org.xfce.PowerManager") )
+	if (!xfpm_dbus_name_has_owner (dbus_g_connection_get_connection(bus), 
+				       "org.xfce.PowerManager") )
         {
-            g_print(_("Xfce power manager is not running"));
-	    g_print("\n");
+            g_print (_("Xfce power manager is not running"));
+	    g_print ("\n");
             return EXIT_SUCCESS;
         }
 	else
 	{
-	    proxy = dbus_g_proxy_new_for_name(bus, 
-			                      "org.xfce.PowerManager",
-					      "/org/xfce/PowerManager",
-					      "org.xfce.Power.Manager");
+	    proxy = dbus_g_proxy_new_for_name (bus, 
+			                       "org.xfce.PowerManager",
+					       "/org/xfce/PowerManager",
+					       "org.xfce.Power.Manager");
 	    if ( !proxy ) 
 	    {
 		g_critical ("Failed to get proxy");
 		dbus_g_connection_unref(bus);
             	return EXIT_FAILURE;
 	    }
-	    xfpm_manager_dbus_client_quit(proxy , &error);
+	    xfpm_manager_dbus_client_quit (proxy , &error);
 	    g_object_unref (proxy);
 	    
 	    if ( error)
@@ -243,20 +374,21 @@ int main(int argc, char **argv)
     
     if ( reload )
     {
-	if (!xfpm_dbus_name_has_owner(dbus_g_connection_get_connection (bus), "org.xfce.PowerManager") &&
-	    !xfpm_dbus_name_has_owner (dbus_g_connection_get_connection(bus), "org.freedesktop.PowerManagement"))
+	if (!xfpm_dbus_name_has_owner (dbus_g_connection_get_connection (bus), "org.xfce.PowerManager") &&
+	    !xfpm_dbus_name_has_owner (dbus_g_connection_get_connection (bus), "org.freedesktop.PowerManagement"))
 	{
 	    g_print ("Xfce power manager is not running\n");
-	    xfpm_start (bus);
+	    xfpm_start (bus, client_id, dump);
 	}
-	proxy = dbus_g_proxy_new_for_name(bus, 
-			                      "org.xfce.PowerManager",
-					      "/org/xfce/PowerManager",
-					      "org.xfce.Power.Manager");
+	
+	proxy = dbus_g_proxy_new_for_name (bus, 
+			                   "org.xfce.PowerManager",
+					   "/org/xfce/PowerManager",
+					   "org.xfce.Power.Manager");
 	if ( !proxy ) 
 	{
 	    g_critical ("Failed to get proxy");
-	    dbus_g_connection_unref(bus);
+	    dbus_g_connection_unref (bus);
 	    return EXIT_FAILURE;
 	}
 	    
@@ -270,15 +402,25 @@ int main(int argc, char **argv)
 	return EXIT_SUCCESS;
     }
     
-    if (xfpm_dbus_name_has_owner (dbus_g_connection_get_connection(bus), "org.freedesktop.PowerManagement") )
+    if (dump)
+    {
+	if (xfpm_dbus_name_has_owner (dbus_g_connection_get_connection (bus), 
+				      "org.xfce.PowerManager"))
+	{
+	    xfpm_dump_remote (bus);
+	    return EXIT_SUCCESS;
+	}
+    }
+    
+    if (xfpm_dbus_name_has_owner (dbus_g_connection_get_connection (bus), "org.freedesktop.PowerManagement") )
     {
 	g_print ("%s: %s\n", 
 		 _("Xfce Power Manager"),
 		 _("Another power manager is already running"));
 		  
     }
-    else if (xfpm_dbus_name_has_owner(dbus_g_connection_get_connection(bus), 
-				      "org.xfce.PowerManager"))
+    else if (xfpm_dbus_name_has_owner (dbus_g_connection_get_connection(bus), 
+				       "org.xfce.PowerManager"))
     {
 	g_print (_("Xfce power manager is already running"));
 	g_print ("\n");
@@ -286,7 +428,7 @@ int main(int argc, char **argv)
     }
     else
     {	
-	xfpm_start (bus);
+	xfpm_start (bus, client_id, dump);
     }
     
     return EXIT_SUCCESS;
diff --git a/src/xfpm-manager.c b/src/xfpm-manager.c
index 5c65221..b9c157a 100644
--- a/src/xfpm-manager.c
+++ b/src/xfpm-manager.c
@@ -30,6 +30,7 @@
 #include <glib.h>
 
 #include <libxfce4util/libxfce4util.h>
+#include <libxfce4ui/libxfce4ui.h>
 #include <xfconf/xfconf.h>
 
 #include <dbus/dbus-glib.h>
@@ -37,15 +38,25 @@
 
 #include <libnotify/notify.h>
 
-#include "libxfpm/xfpm-string.h"
-#include "libxfpm/xfpm-dbus.h"
-#include "libxfpm/xfpm-popups.h"
-
+#include "xfpm-power.h"
+#include "xfpm-dbus.h"
+#include "xfpm-disks.h"
+#include "xfpm-dpms.h"
 #include "xfpm-manager.h"
-#include "xfpm-engine.h"
-#include "xfpm-session.h"
-#include "xfpm-dbus-monitor.h"
+#include "xfpm-console-kit.h"
+#include "xfpm-button.h"
+#include "xfpm-backlight.h"
+#include "xfpm-inhibit.h"
+#include "egg-idletime.h"
+#include "xfpm-config.h"
+#include "xfpm-debug.h"
+#include "xfpm-xfconf.h"
 #include "xfpm-errors.h"
+#include "xfpm-common.h"
+#include "xfpm-enum.h"
+#include "xfpm-enum-glib.h"
+#include "xfpm-enum-types.h"
+#include "xfpm-dbus-monitor.h"
 
 static void xfpm_manager_finalize   (GObject *object);
 
@@ -57,53 +68,34 @@ static gboolean xfpm_manager_quit (XfpmManager *manager);
 #define XFPM_MANAGER_GET_PRIVATE(o) \
 (G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_MANAGER, XfpmManagerPrivate))
 
+#define SLEEP_KEY_TIMEOUT 6.0f
+
 struct XfpmManagerPrivate
 {
-    XfpmSession     *session;
-    XfpmEngine 	    *engine;
+    DBusGConnection *session_bus;
     
-    XfpmDBusMonitor *monitor;
+    XfceSMClient    *client;
     
-    DBusGConnection *session_bus;
-};
-
-G_DEFINE_TYPE(XfpmManager, xfpm_manager, G_TYPE_OBJECT)
+    XfpmPower       *power;
+    XfpmButton      *button;
+    XfpmXfconf      *conf;
+    XfpmBacklight   *backlight;
+    XfpmConsoleKit  *console;
+    XfpmDBusMonitor *monitor;
+    XfpmDisks       *disks;
+    XfpmInhibit     *inhibit;
+    EggIdletime     *idle;
+#ifdef HAVE_DPMS
+    XfpmDpms        *dpms;
+#endif
 
-static void
-xfpm_manager_hal_connection_changed_cb (XfpmDBusMonitor *monitor, gboolean connected, XfpmManager *manager)
-{
-    TRACE("connected = %s", xfpm_bool_to_string (connected));
+    GTimer	    *timer;
     
-    if ( connected  == TRUE )
-    {
-	if ( manager->priv->engine == NULL)
-	{
-	    manager->priv->engine = xfpm_engine_new ();
-	}
-	else
-	{
-	    xfpm_engine_reload_hal_objects (manager->priv->engine);
-	}
-    }
-}
-
-static void
-xfpm_manager_system_bus_connection_changed_cb (XfpmDBusMonitor *monitor, gboolean connected, XfpmManager *manager)
-{
-    if ( connected == TRUE )
-    {
-	TRACE ("System bus connection changed to TRUE, restarting the power manager");
-	xfpm_manager_quit (manager);
-	g_spawn_command_line_async ("xfce4-power-manager", NULL);
-    }
-}
+    gboolean	     inhibited;
+    gboolean	     session_managed;
+};
 
-static void
-xfpm_manager_session_die_cb (XfpmSession *session, XfpmManager *manager)
-{
-    TRACE ("Session die signal, exiting");
-    xfpm_manager_quit (manager);
-}
+G_DEFINE_TYPE (XfpmManager, xfpm_manager, G_TYPE_OBJECT)
 
 static void
 xfpm_manager_class_init (XfpmManagerClass *klass)
@@ -112,33 +104,20 @@ xfpm_manager_class_init (XfpmManagerClass *klass)
 
     object_class->finalize = xfpm_manager_finalize;
 
-    g_type_class_add_private(klass,sizeof(XfpmManagerPrivate));
+    g_type_class_add_private (klass, sizeof (XfpmManagerPrivate));
 }
 
 static void
-xfpm_manager_init(XfpmManager *manager)
+xfpm_manager_init (XfpmManager *manager)
 {
     manager->priv = XFPM_MANAGER_GET_PRIVATE(manager);
-
-    manager->priv->engine        = NULL;
-    
-    manager->priv->session = xfpm_session_new ();
-    manager->priv->monitor = xfpm_dbus_monitor_new ();
+    manager->priv->timer = g_timer_new ();
     
-    g_signal_connect (manager->priv->monitor, "hal-connection-changed",
-		      G_CALLBACK(xfpm_manager_hal_connection_changed_cb), manager);
-		      
-    g_signal_connect (G_OBJECT (manager->priv->monitor), "system_bus_connection_changed",
-		      G_CALLBACK (xfpm_manager_system_bus_connection_changed_cb), manager);
-
-    g_signal_connect (manager->priv->session, "session-die",
-		      G_CALLBACK (xfpm_manager_session_die_cb), manager);
-		      
     notify_init ("xfce4-power-manager");
 }
 
 static void
-xfpm_manager_finalize(GObject *object)
+xfpm_manager_finalize (GObject *object)
 {
     XfpmManager *manager;
 
@@ -147,13 +126,24 @@ xfpm_manager_finalize(GObject *object)
     if ( manager->priv->session_bus )
 	dbus_g_connection_unref (manager->priv->session_bus);
 	
-    if ( manager->priv->engine )
-    	g_object_unref (manager->priv->engine);
-	
-    g_object_unref (manager->priv->session);
-
+    g_object_unref (manager->priv->power);
+    g_object_unref (manager->priv->button);
+    g_object_unref (manager->priv->conf);
+    g_object_unref (manager->priv->client);
+    g_object_unref (manager->priv->console);
     g_object_unref (manager->priv->monitor);
+    g_object_unref (manager->priv->disks);
+    g_object_unref (manager->priv->inhibit);
+    g_object_unref (manager->priv->idle);
     
+    g_timer_destroy (manager->priv->timer);
+    
+#ifdef HAVE_DPMS
+    g_object_unref (manager->priv->dpms);
+#endif
+    
+    g_object_unref (manager->priv->backlight);
+	
     G_OBJECT_CLASS (xfpm_manager_parent_class)->finalize (object);
 }
 
@@ -170,17 +160,24 @@ xfpm_manager_release_names (XfpmManager *manager)
 static gboolean
 xfpm_manager_quit (XfpmManager *manager)
 {
-    TRACE ("Exiting");
+    XFPM_DEBUG ("Exiting");
     
     xfpm_manager_release_names (manager);
-    xfpm_session_quit (manager->priv->session);
-    
-    g_object_unref (G_OBJECT (manager));
-    
     gtk_main_quit ();
     return TRUE;
 }
 
+static void
+xfpm_manager_system_bus_connection_changed_cb (XfpmDBusMonitor *monitor, gboolean connected, XfpmManager *manager)
+{
+    if ( connected == TRUE )
+    {
+        XFPM_DEBUG ("System bus connection changed to TRUE, restarting the power manager");
+        xfpm_manager_quit (manager);
+        g_spawn_command_line_async ("xfce4-power-manager", NULL);
+    }
+}
+
 static gboolean
 xfpm_manager_reserve_names (XfpmManager *manager)
 {
@@ -190,23 +187,315 @@ xfpm_manager_reserve_names (XfpmManager *manager)
 				  "org.freedesktop.PowerManagement") )
     {
 	g_warning ("Unable to reserve bus name: Maybe any already running instance?\n");
-	xfpm_session_quit (manager->priv->session);
+	
 	g_object_unref (G_OBJECT (manager));
 	gtk_main_quit ();
+	
 	return FALSE;
     }
     return TRUE;
 }
 
+static void
+xfpm_manager_shutdown (XfpmManager *manager)
+{
+    GError *error = NULL;
+    xfpm_console_kit_shutdown (manager->priv->console, &error );
+    
+    if ( error )
+    {
+	g_warning ("Failed to shutdown the system : %s", error->message);
+	g_error_free (error);
+	/* Try with the session then */
+	if ( manager->priv->session_managed )
+	    xfce_sm_client_request_shutdown (manager->priv->client, XFCE_SM_CLIENT_SHUTDOWN_HINT_HALT);
+    }
+}
+
+static void
+xfpm_manager_ask_shutdown (XfpmManager *manager)
+{
+    if ( manager->priv->session_managed )
+	xfce_sm_client_request_shutdown (manager->priv->client, XFCE_SM_CLIENT_SHUTDOWN_HINT_ASK);
+}
+
+static void
+xfpm_manager_sleep_request (XfpmManager *manager, XfpmShutdownRequest req, gboolean force)
+{
+    switch (req)
+    {
+	case XFPM_DO_NOTHING:
+	    break;
+	case XFPM_DO_SUSPEND:
+	    xfpm_power_suspend (manager->priv->power, force);
+	    break;
+	case XFPM_DO_HIBERNATE:
+	    xfpm_power_hibernate (manager->priv->power, force);
+	    break;
+	case XFPM_DO_SHUTDOWN:
+	    xfpm_manager_shutdown (manager);
+	    break;
+	case XFPM_ASK:
+	    xfpm_manager_ask_shutdown (manager);
+	    break;
+	default:
+	    g_warn_if_reached ();
+	    break;
+    }
+}
+
+static void
+xfpm_manager_reset_sleep_timer (XfpmManager *manager)
+{
+    g_timer_reset (manager->priv->timer);
+}
+
+static void
+xfpm_manager_button_pressed_cb (XfpmButton *bt, XfpmButtonKey type, XfpmManager *manager)
+{
+    XfpmShutdownRequest req = XFPM_DO_NOTHING;
+    
+    XFPM_DEBUG_ENUM (type, XFPM_TYPE_BUTTON_KEY, "Received button press event");
+  
+    if ( type == BUTTON_MON_BRIGHTNESS_DOWN || type == BUTTON_MON_BRIGHTNESS_UP )
+        return;
+	
+    if ( type == BUTTON_POWER_OFF )
+    {
+        g_object_get (G_OBJECT (manager->priv->conf),
+                      POWER_SWITCH_CFG, &req,
+                      NULL);
+    }
+    else if ( type == BUTTON_SLEEP )
+    {
+        g_object_get (G_OBJECT (manager->priv->conf),
+                      SLEEP_SWITCH_CFG, &req,
+                      NULL);
+    }
+    else if ( type == BUTTON_HIBERNATE )
+    {
+        g_object_get (G_OBJECT (manager->priv->conf),
+                      HIBERNATE_SWITCH_CFG, &req,
+                      NULL);
+    }
+    else
+    {
+        g_return_if_reached ();
+    }
+
+    XFPM_DEBUG_ENUM (req, XFPM_TYPE_SHUTDOWN_REQUEST, "Shutdown request : ");
+        
+    if ( req == XFPM_ASK )
+	xfpm_manager_ask_shutdown (manager);
+    else
+    {
+	if ( g_timer_elapsed (manager->priv->timer, NULL) > SLEEP_KEY_TIMEOUT )
+	{
+	    g_timer_reset (manager->priv->timer);
+	    xfpm_manager_sleep_request (manager, req, FALSE);
+	}
+    }
+}
+
+static void
+xfpm_manager_lid_changed_cb (XfpmPower *power, gboolean lid_is_closed, XfpmManager *manager)
+{
+    XfpmLidTriggerAction action;
+    gboolean on_battery;
+    
+    g_object_get (G_OBJECT (power),
+		  "on-battery", &on_battery,
+		  NULL);
+    
+    g_object_get (G_OBJECT (manager->priv->conf),
+		  on_battery ? LID_SWITCH_ON_BATTERY_CFG : LID_SWITCH_ON_AC_CFG, &action,
+		  NULL);
+
+    if ( lid_is_closed )
+    {
+	XFPM_DEBUG_ENUM (action, XFPM_TYPE_LID_TRIGGER_ACTION, "LID close event");
+	
+	if ( action == LID_TRIGGER_NOTHING )
+	{
+	    if ( !xfpm_is_multihead_connected () )
+		xfpm_dpms_force_level (manager->priv->dpms, DPMSModeOff);
+	}
+	else if ( action == LID_TRIGGER_LOCK_SCREEN )
+	{
+	    if ( !xfpm_is_multihead_connected () )
+		xfpm_lock_screen ();
+	}
+	else 
+	{
+	    /*
+	     * Force sleep here as lid is closed and no point of asking the
+	     * user for confirmation in case of an application is inhibiting
+	     * the power manager. 
+	     */
+	    xfpm_manager_sleep_request (manager, action, TRUE);
+	}
+	
+    }
+    else
+    {
+	XFPM_DEBUG_ENUM (action, XFPM_TYPE_LID_TRIGGER_ACTION, "LID opened");
+	xfpm_dpms_force_level (manager->priv->dpms, DPMSModeOn);
+    }
+}
+
+static void
+xfpm_manager_inhibit_changed_cb (XfpmInhibit *inhibit, gboolean inhibited, XfpmManager *manager)
+{
+    manager->priv->inhibited = inhibited;
+}
+
+static void
+xfpm_manager_alarm_timeout_cb (EggIdletime *idle, guint id, XfpmManager *manager)
+{
+    XFPM_DEBUG ("Alarm inactivity timeout id %d", id);
+    
+    if ( id == TIMEOUT_INACTIVITY_ON_AC || id == TIMEOUT_INACTIVITY_ON_BATTERY )
+    {
+	XfpmShutdownRequest req = XFPM_DO_NOTHING;
+	gchar *sleep_mode;
+	gboolean on_battery;
+	
+	if ( manager->priv->inhibited )
+	{
+	    XFPM_DEBUG ("Idle sleep alarm timeout, but power manager is currently inhibited, action ignored");
+	    return;
+	}
+    
+	g_object_get (G_OBJECT (manager->priv->conf),
+		      INACTIVITY_SLEEP_MODE, &sleep_mode,
+		      NULL);
+	
+	g_object_get (G_OBJECT (manager->priv->power),
+		      "on-battery", &on_battery,
+		      NULL);
+		  
+	if ( !g_strcmp0 (sleep_mode, "Suspend") )
+	    req = XFPM_DO_SUSPEND;
+	else
+	    req = XFPM_DO_HIBERNATE;
+	
+	g_free (sleep_mode);
+
+	if ( id == TIMEOUT_INACTIVITY_ON_AC && on_battery == FALSE )
+	    xfpm_manager_sleep_request (manager, req, FALSE);
+	else if ( id ==  TIMEOUT_INACTIVITY_ON_BATTERY && on_battery  )
+	    xfpm_manager_sleep_request (manager, req, FALSE);
+    }
+}
+
+static void
+xfpm_manager_set_idle_alarm_on_ac (XfpmManager *manager)
+{
+    guint on_ac;
+    
+    g_object_get (G_OBJECT (manager->priv->conf),
+		  ON_AC_INACTIVITY_TIMEOUT, &on_ac,
+		  NULL);
+    
+#ifdef DEBUG
+    if ( on_ac == 14 )
+	TRACE ("setting inactivity sleep timeout on ac to never");
+    else
+	TRACE ("setting inactivity sleep timeout on ac to %d", on_ac);
+#endif
+    
+    if ( on_ac == 14 )
+    {
+	egg_idletime_alarm_remove (manager->priv->idle, TIMEOUT_INACTIVITY_ON_AC );
+    }
+    else
+    {
+	egg_idletime_alarm_set (manager->priv->idle, TIMEOUT_INACTIVITY_ON_AC, on_ac * 1000 * 60);
+    }
+}
+
+static void
+xfpm_manager_set_idle_alarm_on_battery (XfpmManager *manager)
+{
+    guint on_battery;
+    
+    g_object_get (G_OBJECT (manager->priv->conf),
+		  ON_BATTERY_INACTIVITY_TIMEOUT, &on_battery,
+		  NULL);
+    
+#ifdef DEBUG
+    if ( on_battery == 14 )
+	TRACE ("setting inactivity sleep timeout on battery to never");
+    else
+	TRACE ("setting inactivity sleep timeout on battery to %d", on_battery);
+#endif
+    
+    if ( on_battery == 14 )
+    {
+	egg_idletime_alarm_remove (manager->priv->idle, TIMEOUT_INACTIVITY_ON_BATTERY );
+    }
+    else
+    {
+	egg_idletime_alarm_set (manager->priv->idle, TIMEOUT_INACTIVITY_ON_BATTERY, on_battery * 1000 * 60);
+    }
+}
+
+static void
+xfpm_manager_on_battery_changed_cb (XfpmPower *power, gboolean on_battery, XfpmManager *manager)
+{
+    egg_idletime_alarm_reset_all (manager->priv->idle);
+}
+
+static void
+xfpm_manager_set_idle_alarm (XfpmManager *manager)
+{
+    xfpm_manager_set_idle_alarm_on_ac (manager);
+    xfpm_manager_set_idle_alarm_on_battery (manager);
+    
+}
+
 XfpmManager *
-xfpm_manager_new (DBusGConnection *bus)
+xfpm_manager_new (DBusGConnection *bus, const gchar *client_id)
 {
     XfpmManager *manager = NULL;
-    manager = g_object_new(XFPM_TYPE_MANAGER,NULL);
+    GError *error = NULL;
+    gchar *current_dir;
+    
+    const gchar *restart_command[] =
+    {
+	"xfce4-power-manager",
+	"--restart",
+	NULL
+    };
+	
+    manager = g_object_new (XFPM_TYPE_MANAGER, NULL);
 
     manager->priv->session_bus = bus;
     
-    xfpm_manager_dbus_class_init (XFPM_MANAGER_GET_CLASS(manager));
+    current_dir = g_get_current_dir ();
+    manager->priv->client = xfce_sm_client_get_full (XFCE_SM_CLIENT_RESTART_NORMAL,
+						     XFCE_SM_CLIENT_PRIORITY_DEFAULT,
+						     client_id,
+						     current_dir,
+						     restart_command,
+						     SYSCONFDIR "/xdg/autostart/" PACKAGE_NAME ".desktop");
+    
+    g_free (current_dir);
+    
+    manager->priv->session_managed = xfce_sm_client_connect (manager->priv->client, &error);
+    
+    if ( error )
+    {
+	g_warning ("Unable to connect to session managet : %s", error->message);
+	g_error_free (error);
+    }
+    else
+    {
+	g_signal_connect_swapped (manager->priv->client, "quit",
+				  G_CALLBACK (xfpm_manager_quit), manager);
+    }
+    
+    xfpm_manager_dbus_class_init (XFPM_MANAGER_GET_CLASS (manager));
     xfpm_manager_dbus_init (manager);
     
     return manager;
@@ -214,8 +503,6 @@ xfpm_manager_new (DBusGConnection *bus)
 
 void xfpm_manager_start (XfpmManager *manager)
 {
-    gboolean hal_running;
-    
     if ( !xfpm_manager_reserve_names (manager) )
 	goto out;
 	
@@ -223,26 +510,137 @@ void xfpm_manager_start (XfpmManager *manager)
 				  NULL,
 				  XFPM_TYPE_ERROR);
     
-    hal_running = xfpm_dbus_monitor_hal_connected (manager->priv->monitor);
+    manager->priv->power = xfpm_power_get ();
+    manager->priv->button = xfpm_button_new ();
+    manager->priv->conf = xfpm_xfconf_new ();
+    manager->priv->console = xfpm_console_kit_new ();
+    manager->priv->monitor = xfpm_dbus_monitor_new ();
+    manager->priv->disks = xfpm_disks_new ();
+    manager->priv->inhibit = xfpm_inhibit_new ();
+    manager->priv->idle = egg_idletime_new ();
     
-    if (!hal_running )
-    {
-	xfpm_error (_("Xfce power manager"), _("HAL daemon is not running"));
-	goto out;
-    }
-    manager->priv->engine = xfpm_engine_new ();
+    g_signal_connect (manager->priv->idle, "alarm-expired",
+		      G_CALLBACK (xfpm_manager_alarm_timeout_cb), manager);
+    
+    g_signal_connect (manager->priv->conf, "notify::" ON_AC_INACTIVITY_TIMEOUT,
+		      G_CALLBACK (xfpm_manager_set_idle_alarm_on_ac), manager);
+		      
+    g_signal_connect (manager->priv->conf, "notify::" ON_BATTERY_INACTIVITY_TIMEOUT,
+		      G_CALLBACK (xfpm_manager_set_idle_alarm_on_battery), manager);
     
+    xfpm_manager_set_idle_alarm (manager);
+    
+    g_signal_connect (manager->priv->inhibit, "has-inhibit-changed",
+		      G_CALLBACK (xfpm_manager_inhibit_changed_cb), manager);
+    
+    g_signal_connect (manager->priv->monitor, "system-bus-connection-changed",
+		      G_CALLBACK (xfpm_manager_system_bus_connection_changed_cb), manager);
+   
+    manager->priv->backlight = xfpm_backlight_new ();
+    
+#ifdef HAVE_DPMS
+    manager->priv->dpms = xfpm_dpms_new ();
+#endif
+    
+    g_signal_connect (manager->priv->button, "button_pressed",
+		      G_CALLBACK (xfpm_manager_button_pressed_cb), manager);
+    
+    g_signal_connect (manager->priv->power, "lid-changed",
+		      G_CALLBACK (xfpm_manager_lid_changed_cb), manager);
+    
+    g_signal_connect (manager->priv->power, "on-battery-changed",
+		      G_CALLBACK (xfpm_manager_on_battery_changed_cb), manager);
+    
+    g_signal_connect_swapped (manager->priv->power, "waking-up",
+			      G_CALLBACK (xfpm_manager_reset_sleep_timer), manager);
+    
+    g_signal_connect_swapped (manager->priv->power, "sleeping",
+			      G_CALLBACK (xfpm_manager_reset_sleep_timer), manager);
+			      
+    g_signal_connect_swapped (manager->priv->power, "ask-shutdown",
+			      G_CALLBACK (xfpm_manager_ask_shutdown), manager);
+    
+    g_signal_connect_swapped (manager->priv->power, "shutdown",
+			      G_CALLBACK (xfpm_manager_shutdown), manager);
+			      
 out:
 	;
 }
 
 void xfpm_manager_stop (XfpmManager *manager)
 {
-    TRACE ("Stopping");
+    XFPM_DEBUG ("Stopping");
     g_return_if_fail (XFPM_IS_MANAGER (manager));
     xfpm_manager_quit (manager);
 }
 
+GHashTable *xfpm_manager_get_config (XfpmManager *manager)
+{
+    GHashTable *hash;
+    
+    guint8 mapped_buttons;
+    gboolean auth_hibernate = FALSE;
+    gboolean auth_suspend = FALSE;
+    gboolean can_suspend = FALSE;
+    gboolean can_hibernate = FALSE;
+    gboolean has_sleep_button = FALSE;
+    gboolean has_hibernate_button = FALSE;
+    gboolean has_power_button = FALSE;
+    gboolean has_battery = TRUE;
+    gboolean has_lcd_brightness = TRUE;
+    gboolean can_shutdown = TRUE;
+    gboolean has_lid = FALSE;
+    gboolean can_spin = FALSE;
+    gboolean devkit_disk = FALSE;
+    
+    hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+    
+    g_object_get (G_OBJECT (manager->priv->console),
+		  "can-shutdown", &can_shutdown,
+		  NULL);
+
+    g_object_get (G_OBJECT (manager->priv->power),
+                  "auth-suspend", &auth_suspend,
+		  "auth-hibernate", &auth_hibernate,
+                  "can-suspend", &can_suspend,
+                  "can-hibernate", &can_hibernate, 
+		  "has-lid", &has_lid,
+		  NULL);
+
+    can_spin = xfpm_disks_get_can_spin (manager->priv->disks);
+    devkit_disk = xfpm_disks_kit_is_running (manager->priv->disks);
+    
+    has_battery = xfpm_power_has_battery (manager->priv->power);
+    has_lcd_brightness = xfpm_backlight_has_hw (manager->priv->backlight);
+    
+    mapped_buttons = xfpm_button_get_mapped (manager->priv->button);
+    
+    if ( mapped_buttons & SLEEP_KEY )
+        has_sleep_button = TRUE;
+    if ( mapped_buttons & HIBERNATE_KEY )
+        has_hibernate_button = TRUE;
+    if ( mapped_buttons & POWER_KEY )
+        has_power_button = TRUE;
+	
+    g_hash_table_insert (hash, g_strdup ("sleep-button"), g_strdup (xfpm_bool_to_string (has_sleep_button)));
+    g_hash_table_insert (hash, g_strdup ("power-button"), g_strdup (xfpm_bool_to_string (has_power_button)));
+    g_hash_table_insert (hash, g_strdup ("hibernate-button"), g_strdup (xfpm_bool_to_string (has_hibernate_button)));
+    g_hash_table_insert (hash, g_strdup ("auth-suspend"), g_strdup (xfpm_bool_to_string (auth_suspend)));
+    g_hash_table_insert (hash, g_strdup ("auth-hibernate"), g_strdup (xfpm_bool_to_string (auth_hibernate)));
+    g_hash_table_insert (hash, g_strdup ("can-suspend"), g_strdup (xfpm_bool_to_string (can_suspend)));
+    g_hash_table_insert (hash, g_strdup ("can-hibernate"), g_strdup (xfpm_bool_to_string (can_hibernate)));
+    g_hash_table_insert (hash, g_strdup ("can-shutdown"), g_strdup (xfpm_bool_to_string (can_shutdown)));
+    
+    g_hash_table_insert (hash, g_strdup ("has-battery"), g_strdup (xfpm_bool_to_string (has_battery)));
+    g_hash_table_insert (hash, g_strdup ("has-lid"), g_strdup (xfpm_bool_to_string (has_lid)));
+    g_hash_table_insert (hash, g_strdup ("can-spin"), g_strdup (xfpm_bool_to_string (can_spin)));
+    g_hash_table_insert (hash, g_strdup ("devkit-disk"), g_strdup (xfpm_bool_to_string (devkit_disk)));
+    
+    g_hash_table_insert (hash, g_strdup ("has-brightness"), g_strdup (xfpm_bool_to_string (has_lcd_brightness)));
+    
+    return hash;
+}
+
 /*
  * 
  * DBus server implementation
@@ -284,7 +682,7 @@ xfpm_manager_dbus_init (XfpmManager *manager)
 static gboolean
 xfpm_manager_dbus_quit (XfpmManager *manager, GError **error)
 {
-    TRACE("Quit message received\n");
+    XFPM_DEBUG("Quit message received\n");
     
     xfpm_manager_quit (manager);
     
@@ -294,7 +692,7 @@ xfpm_manager_dbus_quit (XfpmManager *manager, GError **error)
 static gboolean xfpm_manager_dbus_restart     (XfpmManager *manager,
 					       GError **error)
 {
-    TRACE("Restart message received");
+    XFPM_DEBUG("Restart message received");
     
     xfpm_manager_quit (manager);
     
@@ -308,10 +706,7 @@ static gboolean xfpm_manager_dbus_get_config (XfpmManager *manager,
 					      GError **error)
 {
     
-    *OUT_config = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
-    
-    xfpm_engine_get_info (manager->priv->engine, *OUT_config);
-    
+    *OUT_config = xfpm_manager_get_config (manager);
     return TRUE;
 }
 					      
diff --git a/src/xfpm-manager.h b/src/xfpm-manager.h
index 54a37ef..9cca308 100644
--- a/src/xfpm-manager.h
+++ b/src/xfpm-manager.h
@@ -48,12 +48,15 @@ typedef struct
 
 GType        		  xfpm_manager_get_type        (void) G_GNUC_CONST;
 
-XfpmManager    		 *xfpm_manager_new             (DBusGConnection *bus);
+XfpmManager    		 *xfpm_manager_new             (DBusGConnection *bus,
+							const gchar *client_id);
 
 void            	  xfpm_manager_start           (XfpmManager *manager);
 
 void                      xfpm_manager_stop            (XfpmManager *manager);
 
+GHashTable		 *xfpm_manager_get_config      (XfpmManager *manager);
+
 G_END_DECLS
 
 #endif /* __XFPM_MANAGER_H */
diff --git a/src/xfpm-network-manager.c b/src/xfpm-network-manager.c
index 57d20f0..ab98714 100644
--- a/src/xfpm-network-manager.c
+++ b/src/xfpm-network-manager.c
@@ -63,6 +63,9 @@ gboolean 	xfpm_send_message_to_network_manager  	(const gchar *message)
     g_object_unref (G_OBJECT(proxy));
     dbus_g_connection_unref (bus);
     
+    /* Sleep 0.5 second to allow the nm applet to disconnect*/
+    g_usleep (500000);
+    
 #endif /* WITH_NETWORK_MANAGER */
     return TRUE;
 }
diff --git a/src/xfpm-notify.c b/src/xfpm-notify.c
new file mode 100644
index 0000000..17a896c
--- /dev/null
+++ b/src/xfpm-notify.c
@@ -0,0 +1,374 @@
+/*
+ * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
+#include <gtk/gtk.h>
+
+#include <libxfce4util/libxfce4util.h>
+
+#include <libnotify/notify.h>
+
+#include "xfpm-common.h"
+#include "xfpm-notify.h"
+#include "xfpm-dbus-monitor.h"
+
+static void xfpm_notify_finalize   (GObject *object);
+
+static NotifyNotification * xfpm_notify_new_notification_internal (const gchar *title, 
+								   const gchar *message, 
+								   const gchar *icon_name, 
+								   guint timeout, 
+								   XfpmNotifyUrgency urgency, 
+								   GtkStatusIcon *icon) G_GNUC_MALLOC;
+
+#define XFPM_NOTIFY_GET_PRIVATE(o) \
+(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_NOTIFY, XfpmNotifyPrivate))
+
+struct XfpmNotifyPrivate
+{
+    XfpmDBusMonitor    *monitor;
+    
+    NotifyNotification *notification;
+    NotifyNotification *critical;
+    
+    gboolean	        supports_actions;
+    gboolean		supports_sync; /*For x-canonical-private-synchronous */
+};
+
+enum
+{
+    PROP_0,
+    PROP_ACTIONS,
+    PROP_SYNC
+};
+
+G_DEFINE_TYPE(XfpmNotify, xfpm_notify, G_TYPE_OBJECT)
+
+static void
+xfpm_notify_get_server_caps (XfpmNotify *notify)
+{
+    GList *caps = NULL;
+    notify->priv->supports_actions = FALSE;
+    notify->priv->supports_sync    = FALSE;
+    
+    caps = notify_get_server_caps ();
+    
+    if (caps != NULL) 
+    {
+	if (g_list_find_custom (caps, "x-canonical-private-synchronous", (GCompareFunc) g_strcmp0) != NULL)
+	    notify->priv->supports_sync = TRUE;
+    
+	if (g_list_find_custom (caps, "actions", (GCompareFunc) g_strcmp0) != NULL)
+	    notify->priv->supports_actions = TRUE;
+
+	g_list_foreach(caps, (GFunc)g_free, NULL);
+	g_list_free(caps);
+    }
+}
+
+static void
+xfpm_notify_check_server (XfpmDBusMonitor *monitor, 
+			  gchar *service_name, 
+			  gboolean connected,
+			  gboolean on_session,
+			  XfpmNotify *notify)
+{
+    if ( !g_strcmp0 (service_name, "org.freedesktop.Notifications") && on_session && connected )
+	xfpm_notify_get_server_caps (notify);
+}
+
+static void xfpm_notify_get_property (GObject *object,
+				      guint prop_id,
+				      GValue *value,
+				      GParamSpec *pspec)
+{
+    XfpmNotify *notify;
+    
+    notify = XFPM_NOTIFY (object);
+    
+    switch (prop_id)
+    {
+	case PROP_ACTIONS:
+	    g_value_set_boolean (value, notify->priv->supports_actions);
+	    break;
+	case PROP_SYNC:
+	    g_value_set_boolean (value, notify->priv->supports_sync);
+	    break;
+	default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+            break;
+    }
+}
+
+static void
+xfpm_notify_class_init (XfpmNotifyClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    object_class->finalize = xfpm_notify_finalize;
+    object_class->get_property = xfpm_notify_get_property;
+
+    g_object_class_install_property (object_class,
+                                     PROP_ACTIONS,
+                                     g_param_spec_boolean ("actions",
+                                                           NULL, NULL,
+                                                           FALSE,
+                                                           G_PARAM_READABLE));
+
+    g_object_class_install_property (object_class,
+                                     PROP_SYNC,
+                                     g_param_spec_boolean ("sync",
+                                                           NULL, NULL,
+                                                           FALSE,
+                                                           G_PARAM_READABLE));
+
+    g_type_class_add_private (klass, sizeof (XfpmNotifyPrivate));
+}
+
+static void
+xfpm_notify_init (XfpmNotify *notify)
+{
+    notify->priv = XFPM_NOTIFY_GET_PRIVATE (notify);
+    
+    notify->priv->notification = NULL;
+    notify->priv->critical = NULL;
+    
+    notify->priv->monitor = xfpm_dbus_monitor_new ();
+    xfpm_dbus_monitor_add_service (notify->priv->monitor, DBUS_BUS_SESSION, "org.freedesktop.Notifications");
+    g_signal_connect (notify->priv->monitor, "service-connection-changed",
+		      G_CALLBACK (xfpm_notify_check_server), notify);
+    
+    xfpm_notify_get_server_caps (notify);
+}
+
+static void
+xfpm_notify_finalize (GObject *object)
+{
+    XfpmNotify *notify;
+
+    notify = XFPM_NOTIFY (object);
+    
+    xfpm_notify_close_normal (notify);
+    xfpm_notify_close_critical (notify);
+    
+    G_OBJECT_CLASS (xfpm_notify_parent_class)->finalize(object);
+}
+
+static void
+xfpm_notify_set_notification_icon (NotifyNotification *n, const gchar *icon_name )
+{
+    GdkPixbuf *pix = xfpm_icon_load (icon_name, 48);
+    
+    if ( pix )
+    {
+	notify_notification_set_icon_from_pixbuf (n,
+						  pix);
+	g_object_unref ( G_OBJECT(pix));
+    }
+    
+}
+
+static NotifyNotification *
+xfpm_notify_new_notification_internal (const gchar *title, const gchar *message,
+				       const gchar *icon_name, guint timeout,
+				       XfpmNotifyUrgency urgency, GtkStatusIcon *icon)
+{
+    NotifyNotification *n;
+    
+    n = notify_notification_new (title, message, NULL, NULL);
+    
+    if ( icon_name )
+    	xfpm_notify_set_notification_icon (n, icon_name);
+	
+    if ( icon )
+    	notify_notification_attach_to_status_icon (n, icon);
+	
+    notify_notification_set_urgency (n, (NotifyUrgency)urgency);
+    
+    if ( timeout != 0)
+	notify_notification_set_timeout (n, timeout);
+    
+    return n;
+}
+
+static void
+xfpm_notify_closed_cb (NotifyNotification *n, XfpmNotify *notify)
+{
+    notify->priv->notification = NULL;
+    g_object_unref (G_OBJECT (n));
+}
+
+static void
+xfpm_notify_close_critical_cb (NotifyNotification *n, XfpmNotify *notify)
+{
+    notify->priv->critical = NULL;
+    g_object_unref (G_OBJECT (n));
+}
+
+static gboolean
+xfpm_notify_show (NotifyNotification *n)
+{
+    notify_notification_show (n, NULL);
+    return FALSE;
+}
+
+static void
+xfpm_notify_close_notification (XfpmNotify *notify )
+{
+    if ( notify->priv->notification )
+    {
+    	if (!notify_notification_close (notify->priv->notification, NULL))
+	    g_warning ("Failed to close notification\n");
+	
+	g_object_unref (G_OBJECT(notify->priv->notification) );
+	notify->priv->notification  = NULL;
+    }
+}
+
+XfpmNotify *
+xfpm_notify_new (void)
+{
+    static gpointer xfpm_notify_object = NULL;
+    
+    if ( xfpm_notify_object != NULL )
+    {
+	g_object_ref (xfpm_notify_object);
+    }
+    else
+    {
+	xfpm_notify_object = g_object_new (XFPM_TYPE_NOTIFY, NULL);
+	g_object_add_weak_pointer (xfpm_notify_object, &xfpm_notify_object);
+    }
+    return XFPM_NOTIFY (xfpm_notify_object);
+}
+
+void xfpm_notify_show_notification (XfpmNotify *notify, const gchar *title,
+				    const gchar *text,  const gchar *icon_name,
+				    gint timeout, gboolean simple,
+				    XfpmNotifyUrgency urgency, GtkStatusIcon *icon)
+{
+    NotifyNotification *n;
+    
+    if ( !simple )
+        xfpm_notify_close_notification (notify);
+    
+    n = xfpm_notify_new_notification_internal (title, 
+				               text, icon_name, 
+					       timeout, urgency, 
+					       icon);
+					       
+    xfpm_notify_present_notification (notify, n, simple);
+}
+
+NotifyNotification *xfpm_notify_new_notification (XfpmNotify *notify,
+						  const gchar *title,
+						  const gchar *text,
+						  const gchar *icon_name,
+						  guint timeout,
+						  XfpmNotifyUrgency urgency,
+						  GtkStatusIcon *icon)
+{
+    NotifyNotification *n = xfpm_notify_new_notification_internal (title, 
+							           text, icon_name, 
+								   timeout, urgency, 
+								   icon);
+    return n;
+}
+
+void xfpm_notify_add_action_to_notification (XfpmNotify *notify, NotifyNotification *n,
+					    const gchar *id, const gchar *action_label,
+					    NotifyActionCallback callback, gpointer data)
+{
+    g_return_if_fail (XFPM_IS_NOTIFY(notify));
+    
+    notify_notification_add_action (n, id, action_label,
+				   (NotifyActionCallback)callback,
+				    data, NULL);
+    
+}
+
+void xfpm_notify_present_notification (XfpmNotify *notify, NotifyNotification *n, gboolean simple)
+{
+    g_return_if_fail (XFPM_IS_NOTIFY(notify));
+    
+    if ( !simple )
+        xfpm_notify_close_notification (notify);
+    
+    if ( !simple )
+    {
+	g_signal_connect (G_OBJECT(n),"closed",
+			G_CALLBACK(xfpm_notify_closed_cb), notify);
+	notify->priv->notification = n;
+    }
+    
+    g_idle_add ((GSourceFunc) xfpm_notify_show, n);
+}
+
+void xfpm_notify_critical (XfpmNotify *notify, NotifyNotification *n)
+{
+    g_return_if_fail (XFPM_IS_NOTIFY (notify));
+
+    xfpm_notify_close_critical (notify);
+    
+    notify->priv->critical = n;
+    
+    g_signal_connect (G_OBJECT (n), "closed", 
+		      G_CALLBACK (xfpm_notify_close_critical_cb), notify);
+		      
+    g_idle_add ((GSourceFunc) xfpm_notify_show, n);
+}
+
+void xfpm_notify_close_critical (XfpmNotify *notify)
+{
+    g_return_if_fail (XFPM_IS_NOTIFY (notify));
+    
+    if ( notify->priv->critical )
+    {
+    	if (!notify_notification_close (notify->priv->critical, NULL))
+	    g_warning ("Failed to close notification\n");
+	
+	g_object_unref (G_OBJECT(notify->priv->critical) );
+	notify->priv->critical  = NULL;
+    }
+}
+
+void xfpm_notify_close_normal  (XfpmNotify *notify)
+{
+    g_return_if_fail (XFPM_IS_NOTIFY (notify));
+    
+    xfpm_notify_close_notification (notify);
+}
diff --git a/libxfpm/xfpm-notify.h b/src/xfpm-notify.h
similarity index 100%
rename from libxfpm/xfpm-notify.h
rename to src/xfpm-notify.h
diff --git a/src/xfpm-polkit.c b/src/xfpm-polkit.c
new file mode 100644
index 0000000..a63e7a9
--- /dev/null
+++ b/src/xfpm-polkit.c
@@ -0,0 +1,191 @@
+/*
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <dbus/dbus-glib.h>
+
+#ifdef HAVE_POLKIT
+#include <polkit/polkit.h>
+#endif
+
+#include "xfpm-polkit.h"
+
+static void xfpm_polkit_finalize   (GObject *object);
+
+#define XFPM_POLKIT_GET_PRIVATE(o) \
+(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_POLKIT, XfpmPolkitPrivate))
+
+struct XfpmPolkitPrivate
+{
+    DBusGConnection   *bus;
+#ifdef HAVE_POLKIT
+    PolkitAuthority   *authority;
+#endif
+};
+
+enum
+{
+    AUTH_CHANGED,
+    LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (XfpmPolkit, xfpm_polkit, G_TYPE_OBJECT)
+
+static gboolean 
+xfpm_polkit_check_auth_intern (XfpmPolkit *polkit, const gchar *action_id)
+{
+#ifdef HAVE_POLKIT
+    PolkitSubject *subj;
+    PolkitAuthorizationResult *res;
+    GError *error = NULL;
+    gboolean ret = FALSE;
+    
+    subj = polkit_unix_process_new (getpid ());
+    
+    res = polkit_authority_check_authorization_sync (polkit->priv->authority, 
+						     subj, 
+						     action_id,
+						     NULL,
+						     POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE,
+						     NULL,
+						     &error);
+    
+    if ( error )
+    {
+	g_warning ("Unable to get authorization result for action :%s : %s", action_id, error->message);
+	g_error_free (error);
+	goto out;
+    }
+    
+    if (polkit_authorization_result_get_is_authorized (res))
+    {
+	ret = TRUE;
+    }
+    
+out:
+    if (res)
+	g_object_unref (res);
+	
+    return ret;
+    
+#endif
+    return TRUE;
+}
+
+#ifdef HAVE_POLKIT
+static void
+xfpm_polkit_auth_changed_cb (PolkitAuthority *authority, XfpmPolkit *polkit)
+{
+}
+#endif
+
+static void
+xfpm_polkit_class_init (XfpmPolkitClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    object_class->finalize = xfpm_polkit_finalize;
+
+    signals [AUTH_CHANGED] = 
+        g_signal_new ("auth-changed",
+                      XFPM_TYPE_POLKIT,
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET(XfpmPolkitClass, auth_changed),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE, 0, G_TYPE_NONE);
+
+    g_type_class_add_private (klass, sizeof (XfpmPolkitPrivate));
+}
+
+static void
+xfpm_polkit_init (XfpmPolkit *polkit)
+{
+    GError *error = NULL;
+    
+    polkit->priv = XFPM_POLKIT_GET_PRIVATE (polkit);
+    
+    polkit->priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+    
+    if ( error )
+    {
+	g_critical ("Error getting system bus connection : %s", error->message);
+	g_error_free (error);
+	goto out;
+    }
+#ifdef HAVE_POLKIT
+    polkit->priv->authority = polkit_authority_get ();
+    g_signal_connect (polkit->priv->authority, "changed",
+		      G_CALLBACK (xfpm_polkit_auth_changed_cb), polkit);
+#endif
+    
+    
+out:
+    ;
+    
+}
+
+static void
+xfpm_polkit_finalize (GObject *object)
+{
+    XfpmPolkit *polkit;
+
+    polkit = XFPM_POLKIT (object);
+#ifdef HAVE_POLKIT
+    if (polkit->priv->authority )
+	g_object_unref (polkit->priv->authority);
+#endif
+
+    if ( polkit->priv->bus )
+	dbus_g_connection_unref (polkit->priv->bus);
+
+    G_OBJECT_CLASS (xfpm_polkit_parent_class)->finalize (object);
+}
+
+XfpmPolkit *
+xfpm_polkit_get (void)
+{
+    static gpointer xfpm_polkit_obj = NULL;
+    
+    if ( G_LIKELY (xfpm_polkit_obj) )
+    {
+	g_object_ref (xfpm_polkit_obj);
+    }
+    else
+    {
+	xfpm_polkit_obj = g_object_new (XFPM_TYPE_POLKIT, NULL);
+    }
+    
+    return XFPM_POLKIT (xfpm_polkit_obj);
+}
+
+gboolean xfpm_polkit_check_auth	(XfpmPolkit *polkit, const gchar *action_id)
+{
+    return xfpm_polkit_check_auth_intern (polkit, action_id);
+}
diff --git a/src/xfpm-polkit.h b/src/xfpm-polkit.h
new file mode 100644
index 0000000..69225e5
--- /dev/null
+++ b/src/xfpm-polkit.h
@@ -0,0 +1,58 @@
+/*
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __XFPM_POLKIT_H
+#define __XFPM_POLKIT_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define XFPM_TYPE_POLKIT        (xfpm_polkit_get_type () )
+#define XFPM_POLKIT(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_POLKIT, XfpmPolkit))
+#define XFPM_IS_POLKIT(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_POLKIT))
+
+typedef struct XfpmPolkitPrivate XfpmPolkitPrivate;
+
+typedef struct
+{
+    GObject         	   parent;
+    XfpmPolkitPrivate     *priv;
+    
+} XfpmPolkit;
+
+typedef struct
+{
+    GObjectClass 	   parent_class;
+    
+    void		  (*auth_changed)		(XfpmPolkit *polkit);
+    
+} XfpmPolkitClass;
+
+GType        		   xfpm_polkit_get_type        	(void) G_GNUC_CONST;
+
+XfpmPolkit                *xfpm_polkit_get             	(void);
+
+gboolean		   xfpm_polkit_check_auth	(XfpmPolkit *polkit,
+							 const gchar *action_id);
+
+G_END_DECLS
+
+#endif /* __XFPM_POLKIT_H */
diff --git a/src/xfpm-power-common.c b/src/xfpm-power-common.c
new file mode 100644
index 0000000..0b4dd1b
--- /dev/null
+++ b/src/xfpm-power-common.c
@@ -0,0 +1,197 @@
+/*
+ * * Copyright (C) 2010 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <libxfce4util/libxfce4util.h>
+
+#include "xfpm-power-common.h"
+#include "xfpm-enum-glib.h"
+
+#include "xfpm-icons.h"
+
+/**
+ * xfpm_power_enumerate_devices:
+ * 
+ **/
+GPtrArray *
+xfpm_power_enumerate_devices (DBusGProxy *proxy)
+{
+    gboolean ret;
+    GError *error = NULL;
+    GPtrArray *array = NULL;
+    GType g_type_array;
+
+    g_type_array = dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH);
+    
+    ret = dbus_g_proxy_call (proxy, "EnumerateDevices", &error,
+			     G_TYPE_INVALID,
+			     g_type_array, &array,
+			     G_TYPE_INVALID);
+    if (!ret) 
+    {
+	g_critical ("Couldn't enumerate power devices: %s", error->message);
+	g_error_free (error);
+    }
+    
+    return array;
+}
+
+/**
+ * xfpm_power_get_interface_properties:
+ * 
+ **/
+GHashTable *xfpm_power_get_interface_properties (DBusGProxy *proxy_prop, const gchar *iface_name)
+{
+    gboolean ret;
+    GError *error = NULL;
+    GHashTable *props = NULL;
+
+    props = NULL;
+
+    ret = dbus_g_proxy_call (proxy_prop, "GetAll", &error,
+			     G_TYPE_STRING, iface_name,
+			     G_TYPE_INVALID,
+			     dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &props,
+			     G_TYPE_INVALID);
+			    
+    if (!ret) 
+    {
+	g_warning ("Unable to get interface properties for : %s : %s", iface_name, error->message);
+	g_error_free (error);
+    }
+    
+    return props;
+}
+
+/**
+ * xfpm_power_get_interface_property:
+ * 
+ **/
+GValue xfpm_power_get_interface_property (DBusGProxy *proxy, const gchar *iface_name, const gchar *prop_name)
+{
+    gboolean ret;
+    GError *error = NULL;
+    GValue value = { 0, };
+
+    ret = dbus_g_proxy_call (proxy, "Get", &error,
+			     G_TYPE_STRING, iface_name,
+			     G_TYPE_STRING, prop_name,
+			     G_TYPE_INVALID,
+			     G_TYPE_VALUE, &value, G_TYPE_INVALID);
+							
+    if (!ret) 
+    {
+	g_warning ("Unable to get property %s on interface  %s : %s", prop_name, iface_name, error->message);
+	g_error_free (error);
+    }
+    
+    return value;
+}
+
+/**
+ * xfpm_power_translate_device_type:
+ * 
+ **/
+const gchar *
+xfpm_power_translate_device_type (guint type)
+{
+    switch (type)
+    {
+        case XFPM_DEVICE_TYPE_BATTERY:
+            return _("Battery");
+        case XFPM_DEVICE_TYPE_UPS:
+            return _("UPS");
+        case XFPM_DEVICE_TYPE_LINE_POWER:
+            return _("Line power");
+        case XFPM_DEVICE_TYPE_MOUSE:
+            return _("Mouse");
+        case XFPM_DEVICE_TYPE_KBD:
+            return _("Keyboard");
+	case XFPM_DEVICE_TYPE_MONITOR:
+	    return _("Monitor");
+	case XFPM_DEVICE_TYPE_PDA:
+	    return _("PDA");
+	case XFPM_DEVICE_TYPE_PHONE:
+	    return _("Phone");
+	case XFPM_DEVICE_TYPE_UNKNOWN:
+	    return _("Unknown");
+    }
+    
+    return _("Battery");
+}
+
+/**
+ * xfpm_power_translate_technology:
+ * 
+ **/
+const gchar *xfpm_power_translate_technology (guint value)
+{
+    switch (value)
+    {
+        case 0:
+            return _("Unknown");
+        case 1:
+            return _("Lithium ion");
+        case 2:
+            return _("Lithium polymer");
+        case 3:
+            return _("Lithium iron phosphate");
+        case 4:
+            return _("Lead acid");
+        case 5:
+            return _("Nickel cadmium");
+        case 6:
+            return _("Nickel metal hybride");
+    }
+    
+    return _("Unknown");
+}
+
+const gchar *xfpm_power_get_icon_name (guint device_type)
+{
+    switch (device_type)
+    {
+        case XFPM_DEVICE_TYPE_BATTERY:
+            return XFPM_BATTERY_ICON;
+        case XFPM_DEVICE_TYPE_UPS:
+            return XFPM_UPS_ICON;
+        case XFPM_DEVICE_TYPE_LINE_POWER:
+            return XFPM_AC_ADAPTER_ICON;
+        case XFPM_DEVICE_TYPE_MOUSE:
+            return XFPM_MOUSE_ICON;
+        case XFPM_DEVICE_TYPE_KBD:
+            return XFPM_KBD_ICON;
+	case XFPM_DEVICE_TYPE_MONITOR:
+	    return "monitor";
+	case XFPM_DEVICE_TYPE_PDA:
+	    return XFPM_PDA_ICON;
+	case XFPM_DEVICE_TYPE_PHONE:
+	    return XFPM_PHONE_ICON;
+	case XFPM_DEVICE_TYPE_UNKNOWN:
+	    return XFPM_BATTERY_ICON;
+    }
+    
+    return XFPM_BATTERY_ICON;
+}
+
+
diff --git a/src/xfpm-power-common.h b/src/xfpm-power-common.h
new file mode 100644
index 0000000..83c530d
--- /dev/null
+++ b/src/xfpm-power-common.h
@@ -0,0 +1,61 @@
+/*
+ * * Copyright (C) 2010 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef XFPM_UPOWER_COMMON
+#define XFPM_UPOWER_COMMON
+
+#include <dbus/dbus-glib.h>
+
+#define DKP_NAME 	     "org.freedesktop.DeviceKit.Power"
+#define DKP_PATH 	     "/org/freedesktop/DeviceKit/Power"
+
+#define DKP_IFACE 	     "org.freedesktop.DeviceKit.Power"
+#define DKP_IFACE_DEVICE     "org.freedesktop.DeviceKit.Power.Device"
+#define DKP_PATH_DEVICE      "/org/freedesktop/DeviceKit/Power/devices/"
+
+#define DKP_PATH_WAKEUPS     "/org/freedesktop/DeviceKit/Power/Wakeups"
+#define DKP_IFACE_WAKEUPS    "org.freedesktop.DeviceKit.Power.Wakeups"
+
+#define UPOWER_NAME 	     "org.freedesktop.DeviceKit.Power"
+#define UPOWER_PATH 	     "/org/freedesktop/DeviceKit/Power"
+
+#define UPOWER_IFACE 	     "org.freedesktop.DeviceKit.Power"
+#define UPOWER_IFACE_DEVICE  "org.freedesktop.DeviceKit.Power.Device"
+
+#define UPOWER_PATH_WAKEUPS  "/org/freedesktop/DeviceKit/Power/Wakeups"
+#define UPOWER_IFACE_WAKEUPS "org.freedesktop.DeviceKit.Power.Wakeups"
+
+
+GPtrArray 		*xfpm_power_enumerate_devices		 	(DBusGProxy *proxy);
+
+GHashTable 		*xfpm_power_get_interface_properties 		(DBusGProxy *proxy_prop, 
+									 const gchar *iface_name);
+
+GValue 			 xfpm_power_get_interface_property   		(DBusGProxy *proxy, 
+									 const gchar *iface_name, 
+									 const gchar *prop_name);
+
+const gchar 		*xfpm_power_translate_device_type 		(guint type);
+
+const gchar		*xfpm_power_translate_technology		(guint value);
+
+const gchar 		*xfpm_power_get_icon_name			(guint device_type);
+
+#endif /* XFPM_UPOWER_COMMON */
diff --git a/src/xfpm-power-info.c b/src/xfpm-power-info.c
new file mode 100644
index 0000000..6a8bbce
--- /dev/null
+++ b/src/xfpm-power-info.c
@@ -0,0 +1,986 @@
+/*
+ * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <signal.h>
+
+#include <gtk/gtk.h>
+#include <glib.h>
+
+#include <libxfce4util/libxfce4util.h>
+#include <libxfce4ui/libxfce4ui.h>
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+#include "xfpm-icons.h"
+#include "xfpm-power-common.h"
+#include "xfpm-enum-glib.h"
+
+#include "xfpm-unique.h"
+
+typedef struct 
+{
+    DBusGConnection *bus;
+    
+    DBusGProxy 	    *power_proxy;
+    DBusGProxy      *wakeups_proxy;
+    
+    GtkWidget 	    *dialog;
+    GtkWidget       *notebook;
+    GtkWidget	    *sideview; /*Sidebar tree view*/
+    
+    GtkWidget	    *wakeups; /* Tree view processor wakeups*/
+    
+} XfpmInfo;
+
+enum
+{
+    XFPM_DEVICE_INFO_NAME,
+    XFPM_DEVICE_INFO_VALUE,
+    XFPM_DEVICE_INFO_LAST
+};
+    
+enum
+{
+    COL_SIDEBAR_ICON,
+    COL_SIDEBAR_NAME,
+    COL_SIDEBAR_INT,
+    NCOLS_SIDEBAR
+    
+};
+  
+enum
+{
+    COL_WAKEUPS_TYPE,
+    COL_WAKEUPS_PID,
+    COL_WAKEUPS_CMD,
+    COL_WAKEUPS_VALUE,
+    COL_WAKEUPS_DETAILS,
+    NCOLS_WAKEUPS
+};
+
+static void G_GNUC_NORETURN
+show_version (void)
+{
+    g_print (_("\n"
+             "Xfce Power Manager %s\n\n"
+             "Part of the Xfce Goodies Project\n"
+             "http://goodies.xfce.org\n\n"
+             "Licensed under the GNU GPL.\n\n"), VERSION);
+
+    exit (EXIT_SUCCESS);
+}
+
+
+/**
+ * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
+ * gpm_stats_format_cmdline:
+ **/
+static gchar *
+gpm_stats_format_cmdline (const gchar *command, gboolean is_userspace)
+{
+	gchar *found;
+	gchar *temp = NULL;
+	gchar *cmdline;
+	const gchar *temp_ptr;
+
+	/* nothing */
+	if (command == NULL) {
+		/* TRANSLATORS: the command line was not provided */
+		temp_ptr = _("No data");
+		goto out;
+	}
+
+	/* common kernel cmd names */
+	if (g_strcmp0 (command, "insmod") == 0) {
+		/* TRANSLATORS: kernel module, usually a device driver */
+		temp_ptr = _("Kernel module");
+		goto out;
+	}
+	if (g_strcmp0 (command, "modprobe") == 0) {
+		/* TRANSLATORS: kernel module, usually a device driver */
+		temp_ptr = _("Kernel module");
+		goto out;
+	}
+	if (g_strcmp0 (command, "swapper") == 0) {
+		/* TRANSLATORS: kernel housekeeping */
+		temp_ptr = _("Kernel core");
+		goto out;
+	}
+	if (g_strcmp0 (command, "kernel-ipi") == 0) {
+		/* TRANSLATORS: interrupt between processors */
+		temp_ptr = _("Interprocessor interrupt");
+		goto out;
+	}
+	if (g_strcmp0 (command, "interrupt") == 0) {
+		/* TRANSLATORS: unknown interrupt */
+		temp_ptr = _("Interrupt");
+		goto out;
+	}
+
+	/* truncate at first space or ':' */
+	temp = g_strdup (command);
+	found = strstr (temp, ":");
+	if (found != NULL)
+		*found = '\0';
+	found = strstr (temp, " ");
+	if (found != NULL)
+		*found = '\0';
+
+	/* remove path */
+	found = g_strrstr (temp, "/");
+	if (found != NULL && strncmp (temp, "event", 5) != 0)
+		temp_ptr = found + 1;
+	else
+		temp_ptr = temp;
+
+out:
+	/* format command line */
+	if (is_userspace)
+		cmdline = g_markup_escape_text (temp_ptr, -1);
+	else
+		cmdline = g_markup_printf_escaped ("<i>%s</i>", temp_ptr);
+	g_free (temp);
+
+	/* return */
+	return cmdline;
+}
+
+/**
+ * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
+ * gpm_stats_format_details:
+ **/
+static gchar *
+gpm_stats_format_details (const gchar *command_details)
+{
+	gchar *details;
+
+	/* replace common driver names */
+	if (g_strcmp0 (command_details, "i8042") == 0) {
+		/* TRANSLATORS: the keyboard and mouse device event */
+		details = g_strdup (_("PS/2 keyboard/mouse/touchpad"));
+	} else if (g_strcmp0 (command_details, "acpi") == 0) {
+		/* TRANSLATORS: ACPI, the Intel power standard on laptops and desktops */
+		details = g_strdup (_("ACPI"));
+	} else if (g_strcmp0 (command_details, "ata_piix") == 0) {
+		/* TRANSLATORS: serial ATA is a new style of hard disk interface */
+		details = g_strdup (_("Serial ATA"));
+	} else if (g_strcmp0 (command_details, "libata") == 0) {
+		/* TRANSLATORS: this is the old-style ATA interface */
+		details = g_strdup (_("ATA host controller"));
+	} else if (g_strcmp0 (command_details, "iwl3945") == 0 || g_strcmp0 (command_details, "iwlagn") == 0) {
+		/* TRANSLATORS: 802.11 wireless adaptor */
+		details = g_strdup (_("Intel wireless adaptor"));
+
+	/* try to make the wakeup type nicer */
+	} else if (g_str_has_prefix (command_details, "__mod_timer")) {
+		/* TRANSLATORS: a timer is something that fires periodically */
+		details = g_strdup_printf (_("Timer %s"), command_details+12);
+	} else if (g_str_has_prefix (command_details, "mod_timer")) {
+		/* TRANSLATORS: a timer is something that fires periodically */
+		details = g_strdup_printf (_("Timer %s"), command_details+10);
+	} else if (g_str_has_prefix (command_details, "hrtimer_start_expires")) {
+		/* TRANSLATORS: a timer is something that fires periodically */
+		details = g_strdup_printf (_("Timer %s"), command_details+22);
+	} else if (g_str_has_prefix (command_details, "hrtimer_start")) {
+		/* TRANSLATORS: a timer is something that fires periodically */
+		details = g_strdup_printf (_("Timer %s"), command_details+14);
+	} else if (g_str_has_prefix (command_details, "do_setitimer")) {
+		/* TRANSLATORS: a timer is something that fires periodically */
+		details = g_strdup_printf (_("Timer %s"), command_details+10);
+	} else if (g_str_has_prefix (command_details, "do_nanosleep")) {
+		/* TRANSLATORS: this is a task that's woken up from sleeping */
+		details = g_strdup_printf (_("Sleep %s"), command_details+13);
+	} else if (g_str_has_prefix (command_details, "enqueue_task_rt")) {
+		/* TRANSLATORS: this is a new realtime task */
+		details = g_strdup_printf (_("New task %s"), command_details+16);
+	} else if (g_str_has_prefix (command_details, "futex_wait")) {
+		/* TRANSLATORS: this is a task thats woken to check state */
+		details = g_strdup_printf (_("Wait %s"), command_details+11);
+	} else if (g_str_has_prefix (command_details, "queue_delayed_work_on")) {
+		/* TRANSLATORS: a work queue is a list of work that has to be done */
+		details = g_strdup_printf (_("Work queue %s"), command_details+22);
+	} else if (g_str_has_prefix (command_details, "queue_delayed_work")) {
+		/* TRANSLATORS: a work queue is a list of work that has to be done */
+		details = g_strdup_printf (_("Work queue %s"), command_details+19);
+	} else if (g_str_has_prefix (command_details, "dst_run_gc")) {
+		/* TRANSLATORS: this is when the networking subsystem clears out old entries */
+		details = g_strdup_printf (_("Network route flush %s"), command_details+11);
+	} else if (g_str_has_prefix (command_details, "usb_hcd_poll_rh_status")) {
+		/* TRANSLATORS: activity on the USB bus */
+		details = g_strdup_printf (_("USB activity %s"), command_details+23);
+	} else if (g_str_has_prefix (command_details, "schedule_hrtimeout_range")) {
+		/* TRANSLATORS: we've timed out of an aligned timer */
+		details = g_strdup_printf (_("Wakeup %s"), command_details+25);
+	} else if (g_str_has_prefix (command_details, "Local timer interrupts")) {
+		/* TRANSLATORS: interupts on the system required for basic operation */
+		details = g_strdup (_("Local interrupts"));
+	} else if (g_str_has_prefix (command_details, "Rescheduling interrupts")) {
+		/* TRANSLATORS: interrupts when a task gets moved from one core to another */
+		details = g_strdup (_("Rescheduling interrupts"));
+	} else
+		details = g_markup_escape_text (command_details, -1);
+
+	return details;
+}
+
+static gchar *
+xfpm_info_get_energy_property (GHashTable *props, const gchar *prop, const gchar *unit)
+{
+    GValue *value;
+    gchar *val = NULL;
+    gdouble energy;
+    
+    value = g_hash_table_lookup (props, prop);
+    
+    if ( !value )
+	return NULL;
+	
+    energy = g_value_get_double (value);
+    
+    val = g_strdup_printf ("%.1f %s", energy, unit);
+    
+    return val;
+}
+
+static void
+xfpm_info_add_sidebar_icon (XfpmInfo *info, const gchar *name, const gchar *icon_name)
+{
+    GtkListStore *list_store;
+    GtkTreeIter iter;
+    GdkPixbuf *pix;
+    guint nt;
+
+    list_store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (info->sideview)));
+    
+    nt = gtk_notebook_get_n_pages (GTK_NOTEBOOK (info->notebook));
+    
+    pix = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+				    icon_name,
+				    48,
+				    GTK_ICON_LOOKUP_USE_BUILTIN,
+				    NULL);
+    
+    gtk_list_store_append (list_store, &iter);
+    gtk_list_store_set (list_store, &iter, 
+			COL_SIDEBAR_ICON, pix,
+			COL_SIDEBAR_NAME, name,
+			COL_SIDEBAR_INT, nt,
+			-1);
+			
+    if ( pix )
+	g_object_unref (pix);
+}
+
+static void
+xfpm_info_add_device_view (XfpmInfo *info, GHashTable *props, const gchar *object_path)
+{
+    GtkWidget *view;
+
+    GtkListStore *list_store;
+    GtkTreeIter iter;
+    GtkTreeViewColumn *col;
+    GtkCellRenderer *renderer;
+    GValue *value;
+    const gchar *cstr;
+    gchar *str;
+    gint i = 0;
+    guint type = 0;
+    const gchar *battery_type = NULL;
+    
+    view = gtk_tree_view_new ();
+    
+    list_store = gtk_list_store_new (XFPM_DEVICE_INFO_LAST, G_TYPE_STRING, G_TYPE_STRING);
+
+    gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (list_store));
+    
+    renderer = gtk_cell_renderer_text_new ();
+    
+    /*Device Attribute*/
+    col = gtk_tree_view_column_new();
+    gtk_tree_view_column_pack_start (col, renderer, FALSE);
+    gtk_tree_view_column_set_attributes (col, renderer, "text", XFPM_DEVICE_INFO_NAME, NULL);
+    gtk_tree_view_column_set_title (col, _("Attribute"));
+    gtk_tree_view_append_column (GTK_TREE_VIEW (view), col);
+    
+    /*Device Attribute Value*/
+    col = gtk_tree_view_column_new();
+    gtk_tree_view_column_pack_start (col, renderer, FALSE);
+    gtk_tree_view_column_set_attributes (col, renderer, "text", XFPM_DEVICE_INFO_VALUE, NULL);
+    gtk_tree_view_column_set_title (col, _("Value"));
+    
+    gtk_tree_view_append_column (GTK_TREE_VIEW (view), col);
+    
+    /**
+     * Add Device information:
+     **/
+    /*Device*/
+    gtk_list_store_append (list_store, &iter);
+    gtk_list_store_set (list_store, &iter, 
+			XFPM_DEVICE_INFO_NAME, _("Device"), 
+			XFPM_DEVICE_INFO_VALUE, g_str_has_prefix (object_path, DKP_PATH_DEVICE) ? object_path + strlen (DKP_PATH_DEVICE) : object_path,
+			-1);
+    i++;
+    
+    
+    /*Type*/
+    value = g_hash_table_lookup (props, "Type");
+    
+    if ( value )
+    {
+	type = g_value_get_uint (value);
+	battery_type = xfpm_power_translate_device_type (type);
+	gtk_list_store_append (list_store, &iter);
+	gtk_list_store_set (list_store, &iter, 
+			    XFPM_DEVICE_INFO_NAME, _("Type"), 
+			    XFPM_DEVICE_INFO_VALUE, battery_type,
+			    -1);
+	i++;
+    }
+    
+    value = g_hash_table_lookup (props, "PowerSupply");
+    
+    if ( value )
+    {
+	gtk_list_store_append (list_store, &iter);
+	gtk_list_store_set (list_store, &iter, 
+			    XFPM_DEVICE_INFO_NAME, _("PowerSupply"), 
+			    XFPM_DEVICE_INFO_VALUE, g_value_get_boolean (value) == TRUE ? _("True") : _("False"),
+			    -1);
+	i++;
+    }
+    
+    if ( type != XFPM_DEVICE_TYPE_LINE_POWER )
+    {
+	/*Model*/
+	value = g_hash_table_lookup (props, "Model");
+	
+	if ( value )
+	{
+	    cstr = g_value_get_string (value);
+	    if ( cstr && strlen (cstr) > 0)
+	    {
+		gtk_list_store_append (list_store, &iter);
+		gtk_list_store_set (list_store, &iter, 
+				    XFPM_DEVICE_INFO_NAME, _("Model"), 
+				    XFPM_DEVICE_INFO_VALUE, g_value_get_string (value),
+				    -1);
+		i++;
+	    }
+	}
+	
+	/*Technology*/
+	value = g_hash_table_lookup (props, "Technology");
+	
+	if ( value )
+	{
+	    gtk_list_store_append (list_store, &iter);
+	    gtk_list_store_set (list_store, &iter, 
+				XFPM_DEVICE_INFO_NAME, _("Technology"), 
+				XFPM_DEVICE_INFO_VALUE, xfpm_power_translate_technology (g_value_get_uint (value)),
+				-1);
+	    i++;
+	}
+	
+	/* TRANSLATORS: Unit here is What hour*/
+	str = xfpm_info_get_energy_property (props, "EnergyFullDesign", _("Wh"));
+	
+	if ( str )
+	{
+	    gtk_list_store_append (list_store, &iter);
+	    gtk_list_store_set (list_store, &iter, 
+				XFPM_DEVICE_INFO_NAME, _("Energy full design"), 
+				XFPM_DEVICE_INFO_VALUE, str,
+				-1);
+	    i++;
+	    g_free (str);
+	}
+	
+	/* TRANSLATORS: Unit here is What hour*/
+	str = xfpm_info_get_energy_property (props, "EnergyFull", _("Wh"));
+	
+	if ( str )
+	{
+	    gtk_list_store_append (list_store, &iter);
+	    gtk_list_store_set (list_store, &iter, 
+				XFPM_DEVICE_INFO_NAME, _("Energy full"), 
+				XFPM_DEVICE_INFO_VALUE, str,
+				-1);
+	    i++;
+	    g_free (str);
+	}
+	
+	/* TRANSLATORS: Unit here is What hour*/
+	str = xfpm_info_get_energy_property (props, "EnergyEmpty", _("Wh"));
+	
+	if ( str )
+	{
+	    gtk_list_store_append (list_store, &iter);
+	    gtk_list_store_set (list_store, &iter, 
+				XFPM_DEVICE_INFO_NAME, _("Energy empty"), 
+				XFPM_DEVICE_INFO_VALUE, str,
+				-1);
+	    i++;
+	    g_free (str);
+	}
+	
+	/* TRANSLATORS: Unit here is volt*/
+	str = xfpm_info_get_energy_property (props, "Voltage", _("V"));
+	if ( str )
+	{
+	    gtk_list_store_append (list_store, &iter);
+	    gtk_list_store_set (list_store, &iter, 
+				XFPM_DEVICE_INFO_NAME, _("Voltage"), 
+				XFPM_DEVICE_INFO_VALUE, str,
+				-1);
+	    i++;
+	    g_free (str);
+	}
+	
+	/*Vendor*/
+	value = g_hash_table_lookup (props, "Vendor");
+	
+	if ( value )
+	{
+	    cstr = g_value_get_string (value);
+	    if ( cstr && strlen (cstr) > 0)
+	    {
+		gtk_list_store_append (list_store, &iter);
+		gtk_list_store_set (list_store, &iter, 
+				    XFPM_DEVICE_INFO_NAME, _("Vendor"), 
+				    XFPM_DEVICE_INFO_VALUE, g_value_get_string (value),
+				    -1);
+		i++;
+	    }
+	}
+	
+	/*Serial*/
+	value = g_hash_table_lookup (props, "Serial");
+	
+	if ( value )
+	{
+	    cstr = g_value_get_string (value);
+	    if ( cstr && strlen (cstr) > 0)
+	    {
+		gtk_list_store_append (list_store, &iter);
+		gtk_list_store_set (list_store, &iter, 
+				    XFPM_DEVICE_INFO_NAME, _("Serial"), 
+				    XFPM_DEVICE_INFO_VALUE, g_value_get_string (value),
+				    -1);
+		i++;
+	    }
+	}
+    }
+    
+    xfpm_info_add_sidebar_icon (info, battery_type, xfpm_power_get_icon_name (type));
+    
+    gtk_notebook_append_page (GTK_NOTEBOOK (info->notebook), view, NULL);
+    gtk_widget_show (view);
+}
+
+static void
+xfpm_info_add_device (XfpmInfo *info, const gchar *object_path)
+{
+    DBusGProxy *proxy_prop;
+    GHashTable *props;
+    
+    proxy_prop = dbus_g_proxy_new_for_name (info->bus, 
+					    DKP_NAME,
+					    object_path,
+					    DBUS_INTERFACE_PROPERTIES);
+					    
+    if ( !proxy_prop )
+    {
+	g_warning ("Unable to create proxy for : %s", object_path);
+	return;
+    }
+    
+    props = xfpm_power_get_interface_properties (proxy_prop, DKP_IFACE_DEVICE);
+    
+    if ( props )
+    {
+	xfpm_info_add_device_view (info, props, object_path);
+	g_hash_table_destroy (props);
+    }
+}
+
+static void
+xfpm_info_power_devices (XfpmInfo *info)
+{
+    GPtrArray *array = NULL;
+    guint i;
+    
+    info->power_proxy = dbus_g_proxy_new_for_name (info->bus, 
+						   DKP_NAME,
+						   DKP_PATH,
+						   DKP_IFACE);
+						   
+    if ( !info->power_proxy )
+    {
+	g_warning ("Unable to create proxy for : %s", DKP_NAME);
+	return;
+    }
+    
+    array = xfpm_power_enumerate_devices (info->power_proxy);
+    
+    if ( array )
+    {
+	for ( i = 0; i < array->len; i++)
+	{
+	    const gchar *object_path = ( const gchar *) g_ptr_array_index (array, i);
+	    xfpm_info_add_device (info, object_path);
+	}
+	g_ptr_array_free (array, TRUE);
+    }
+}
+
+
+/**
+ * 
+ * Method GetData on /org/freedesktop/DeviceKit/Power/Wakeups
+ * 
+ * <method name="GetData">
+ *     <arg name="data" type="a(budss)" direction="out"/> (1)
+ * </method>
+ *  (1): array | boolean	Wheter the proceess on userspace
+ * 	       | uint           PID
+ *             | double		Wakeups value            
+ *             | string         command line
+ *             | string         details
+ **/
+static void
+xfpm_info_update_wakeups (XfpmInfo *info)
+{
+    GtkListStore *store;
+    
+    GError *error = NULL;
+    
+    GType collection_type;
+    GType struct_type;
+    
+    GPtrArray *array = NULL;
+    
+    gboolean ret;
+    guint i;
+    
+    struct_type = dbus_g_type_get_struct ("GValueArray",
+					  G_TYPE_BOOLEAN,
+					  G_TYPE_UINT,
+					  G_TYPE_DOUBLE,
+					  G_TYPE_STRING,
+					  G_TYPE_STRING,
+					  G_TYPE_INVALID);
+    
+    collection_type = dbus_g_type_get_collection ("GPtrArray", struct_type);
+    
+    ret = dbus_g_proxy_call (info->wakeups_proxy, "GetData", &error,
+			     G_TYPE_INVALID,
+			     collection_type, &array,
+			     NULL);
+		       
+    if ( !ret )
+    {
+	g_warning ("GetData Failed on %s : %s", DKP_PATH_WAKEUPS, error->message);
+	g_error_free (error);
+	return;
+    }
+		    
+    store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (info->wakeups)));
+    
+    gtk_list_store_clear (GTK_LIST_STORE (store));
+    
+    for ( i = 0; i < array->len; i++ )
+    {
+	GValue elem = { 0 };
+	GtkTreeIter iter;
+	
+	gboolean userspace;
+	guint pid;
+	gdouble value;
+	gchar *cmd;
+	gchar *formatted_cmd;
+	gchar *details;
+	gchar *formatted_details;
+	gchar *pid_str;
+	gchar *value_str;
+	const gchar *icon;
+	
+	g_value_init (&elem, struct_type);
+	g_value_set_static_boxed (&elem, g_ptr_array_index (array, i));
+	
+	dbus_g_type_struct_get (&elem,
+				0, &userspace,
+				1, &pid,
+				2, &value,
+				3, &cmd,
+				4, &details,
+				G_MAXUINT);
+	
+	if ( userspace )
+	{
+	    pid_str = g_strdup_printf ("%i", pid);
+	}
+	else
+	{
+	    if ( pid < 0xff0 )
+	    {
+		pid_str = g_strdup_printf ("IRQ%i", pid);
+	    }
+	    else
+	    {
+		pid_str = g_strdup("IRQx");
+	    }
+	}
+	value_str = g_strdup_printf ("%.1f", value);
+	
+	icon = userspace ? "application-x-executable" : "applications-system";
+	
+	formatted_cmd = gpm_stats_format_cmdline (cmd, userspace);
+	formatted_details = gpm_stats_format_details (details);
+	
+	gtk_list_store_append (store, &iter);
+	gtk_list_store_set (store, &iter, 
+			    COL_WAKEUPS_TYPE, icon,
+			    COL_WAKEUPS_PID, pid_str,
+			    COL_WAKEUPS_VALUE, value_str,
+			    COL_WAKEUPS_CMD, formatted_cmd,
+			    COL_WAKEUPS_DETAILS, formatted_details,
+			    -1);
+	
+	g_free (cmd);
+	g_free (details);
+	g_free (formatted_cmd);
+	g_free (formatted_details);
+	
+	g_value_unset (&elem);
+    }
+	
+    g_ptr_array_free (array, TRUE);
+}
+
+static gboolean
+xfpm_info_update_wakeups_idle (gpointer data)
+{
+    XfpmInfo *info;
+    
+    info = (XfpmInfo*)data;
+    
+    if ( GTK_WIDGET_VISIBLE (info->wakeups) ) 
+        xfpm_info_update_wakeups (info);
+    
+    return TRUE;
+}
+
+static void
+xfpm_info_cpu_wakeups (XfpmInfo *info)
+{
+    GtkWidget *vbox;
+    GtkWidget *scrolled;
+    GtkListStore *list_store;
+    GtkTreeViewColumn *col;
+    GtkCellRenderer *renderer;
+    
+    info->wakeups_proxy = dbus_g_proxy_new_for_name (info->bus,
+						     DKP_NAME,
+						     DKP_PATH_WAKEUPS,
+						     DKP_IFACE_WAKEUPS);
+							  
+    if ( !info->wakeups_proxy )
+    {
+	g_warning ("Unable to create proxy for %s", DKP_PATH_WAKEUPS);
+	return;
+    }
+    
+    list_store = gtk_list_store_new (NCOLS_WAKEUPS, 
+				     G_TYPE_STRING, /*type*/
+				     G_TYPE_STRING, /*pid*/
+				     G_TYPE_STRING, /*value*/
+				     G_TYPE_STRING, /*command*/
+				     G_TYPE_STRING); /*details*/
+				     
+    info->wakeups = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
+    
+    xfpm_info_add_sidebar_icon (info, _("Processor"), XFPM_PROCESSOR_ICON);
+    
+    col = gtk_tree_view_column_new ();
+    renderer = gtk_cell_renderer_pixbuf_new ();
+    g_object_set (G_OBJECT (renderer), "stock-size", GTK_ICON_SIZE_BUTTON, NULL);
+    gtk_tree_view_column_pack_start (col, renderer, FALSE);
+    gtk_tree_view_column_set_attributes (col, renderer, "icon-name", COL_WAKEUPS_TYPE, NULL);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (info->wakeups), col);
+    gtk_tree_view_column_set_title (col, _("Type"));
+    
+    renderer = gtk_cell_renderer_text_new ();
+    
+    col = gtk_tree_view_column_new ();
+    gtk_tree_view_column_pack_start (col, renderer, FALSE);
+    gtk_tree_view_column_set_attributes (col, renderer, "text", COL_WAKEUPS_PID, NULL);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (info->wakeups), col);
+    /* TANSLATORS: PID, is the process id, e.g what ps x gives*/
+    gtk_tree_view_column_set_title (col, _("PID"));
+    
+    col = gtk_tree_view_column_new ();
+    gtk_tree_view_column_pack_start (col, renderer, FALSE);
+    gtk_tree_view_column_set_attributes (col, renderer, "markup", COL_WAKEUPS_VALUE, NULL);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (info->wakeups), col);
+    gtk_tree_view_column_set_title (col, _("Wakeups"));
+    
+    col = gtk_tree_view_column_new ();
+    gtk_tree_view_column_pack_start (col, renderer, FALSE);
+    gtk_tree_view_column_set_attributes (col, renderer, "markup", COL_WAKEUPS_CMD, NULL);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (info->wakeups), col);
+    gtk_tree_view_column_set_title (col, _("Command"));
+    
+    col = gtk_tree_view_column_new ();
+    gtk_tree_view_column_pack_start (col, renderer, FALSE);
+    gtk_tree_view_column_set_attributes (col, renderer, "markup", COL_WAKEUPS_DETAILS, NULL);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (info->wakeups), col);
+    gtk_tree_view_column_set_title (col, _("Details"));
+    
+    vbox = gtk_vbox_new (FALSE, 4);
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+				    GTK_POLICY_NEVER,
+				    GTK_POLICY_AUTOMATIC);
+    gtk_container_add (GTK_CONTAINER (scrolled), info->wakeups);
+    
+    gtk_box_pack_start (GTK_BOX (vbox), scrolled, TRUE, TRUE, 0);
+    gtk_notebook_append_page (GTK_NOTEBOOK (info->notebook), vbox, NULL);
+    
+    xfpm_info_update_wakeups (info);
+    
+    g_timeout_add_seconds (4, (GSourceFunc) xfpm_info_update_wakeups_idle, info);
+    
+    gtk_widget_show (vbox);
+}
+
+static void
+view_cursor_changed_cb (GtkTreeView *view, XfpmInfo *info)
+{
+    GtkTreeSelection *sel;
+    GtkTreeModel     *model;
+    GtkTreeIter       selected_row;
+    gint int_data = 0;
+
+    sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+
+    if ( !gtk_tree_selection_get_selected (sel, &model, &selected_row))
+	return;
+
+    gtk_tree_model_get(model,
+                       &selected_row,
+                       COL_SIDEBAR_INT,
+                       &int_data,
+                       -1);
+
+    gtk_notebook_set_current_page (GTK_NOTEBOOK (info->notebook), int_data);
+}
+
+static void
+xfpm_info_create (XfpmInfo *info)
+{
+    GtkWidget *content_area;
+    GtkWidget *hbox;
+    GtkWidget *viewport;
+    GtkListStore *list_store;
+    GtkTreeViewColumn *col;
+    GtkCellRenderer *renderer;
+    
+    info->dialog = xfce_titled_dialog_new_with_buttons (_("Power Information"),
+							NULL,
+							GTK_DIALOG_DESTROY_WITH_PARENT,
+							GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
+							NULL);
+							
+    gtk_window_set_default_size (GTK_WINDOW (info->dialog), -1, 400);
+				 
+    gtk_window_set_icon_name (GTK_WINDOW (info->dialog), GTK_STOCK_INFO);
+			      
+    content_area = gtk_dialog_get_content_area (GTK_DIALOG (info->dialog));
+    
+    hbox = gtk_hbox_new (FALSE, 4);
+    
+    gtk_container_add (GTK_CONTAINER (content_area), hbox);
+    
+    viewport = gtk_viewport_new (NULL, NULL);
+    info->sideview = gtk_tree_view_new ();
+    list_store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT);
+
+    gtk_tree_view_set_model (GTK_TREE_VIEW (info->sideview), GTK_TREE_MODEL (list_store));
+    
+    gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (info->sideview),TRUE);
+    col = gtk_tree_view_column_new ();
+
+    renderer = gtk_cell_renderer_pixbuf_new ();
+    
+    gtk_tree_view_column_pack_start (col, renderer, FALSE);
+    gtk_tree_view_column_set_attributes (col, renderer, "pixbuf", 0, NULL);
+
+    renderer = gtk_cell_renderer_text_new ();
+    gtk_tree_view_column_pack_start (col, renderer, FALSE);
+    gtk_tree_view_column_set_attributes (col, renderer, "markup", 1, NULL);
+    
+    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (info->sideview), FALSE);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (info->sideview), col);
+    
+    g_signal_connect (info->sideview, "cursor-changed",
+		      G_CALLBACK (view_cursor_changed_cb), info);
+    
+    gtk_container_add (GTK_CONTAINER (viewport), info->sideview);
+    
+    gtk_box_pack_start (GTK_BOX (hbox), viewport, FALSE, FALSE, 0);
+    
+    info->notebook = gtk_notebook_new ();
+    gtk_box_pack_start (GTK_BOX (hbox), info->notebook, TRUE, TRUE, 0);
+    gtk_notebook_set_show_tabs (GTK_NOTEBOOK (info->notebook), FALSE);
+    
+    /*Show power devices information, AC adapter, batteries*/
+    xfpm_info_power_devices (info);
+    
+    /*Sow CPU wakeups*/
+    xfpm_info_cpu_wakeups (info);
+    
+    g_object_set (G_OBJECT (hbox),
+		  "border-width", 4,
+		  NULL);
+    
+    gtk_widget_show_all (hbox);
+}
+
+static void
+xfpm_info_connect (XfpmInfo *info)
+{
+    GError *error = NULL;
+    
+    info->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+    
+    if ( error )
+    {
+	xfce_dialog_show_error (NULL,
+				error,
+				NULL);
+	g_error ("Cannot connect to system bus : %s", error->message);
+    }
+}
+
+static XfpmInfo *
+xfpm_info_new (void)
+{
+    XfpmInfo *info;
+    
+    info = g_new0 (XfpmInfo, 1);
+    
+    info->bus           = NULL;
+    info->power_proxy   = NULL;
+    info->wakeups_proxy = NULL;
+    info->dialog        = NULL;
+    
+    return info;
+}
+
+static void
+xfpm_info_free (XfpmInfo *info)
+{
+    if ( info->bus ) 
+	dbus_g_connection_unref (info->bus);
+	
+    if ( info->power_proxy )
+	g_object_unref (info->power_proxy);
+	
+    if ( info->wakeups_proxy )
+	g_object_unref (info->wakeups_proxy);
+	
+    g_free (info);
+}
+
+int main (int argc, char **argv)
+{
+    XfpmInfo *info;
+    XfpmUnique *unique;
+    
+    GError *error = NULL;
+    gboolean version = FALSE;
+    
+    GOptionEntry option_entries[] = 
+    {
+	{ "version", 'V', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &version, N_("Version information"), NULL },
+	{ NULL, },
+    };
+
+    xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8");
+    
+    g_set_application_name (PACKAGE_NAME);
+    
+    if (!gtk_init_with_args (&argc, &argv, (gchar *)"", option_entries, (gchar *)PACKAGE, &error)) 
+    {
+        if (G_LIKELY (error)) 
+        {
+            g_printerr ("%s: %s.\n", G_LOG_DOMAIN, error->message);
+            g_printerr (_("Type '%s --help' for usage."), G_LOG_DOMAIN);
+            g_printerr ("\n");
+            g_error_free (error);
+        }
+        else
+        {
+            g_error ("Unable to open display.");
+	}
+
+        return EXIT_FAILURE;
+    }
+    
+    if ( version )    
+    {
+	show_version ();
+    }
+    
+    
+    unique = xfpm_unique_new ("org.Xfce.PowerManager.Info");
+    
+    if ( !xfpm_unique_app_is_running (unique ) )
+    {
+	info = xfpm_info_new ();
+	xfpm_info_connect (info);
+	xfpm_info_create (info);
+	
+	g_signal_connect_swapped (unique, "ping-received",
+				  G_CALLBACK (gtk_window_present), info->dialog);
+	
+	gtk_dialog_run (GTK_DIALOG (info->dialog));
+	
+	gtk_widget_destroy (info->dialog);
+	
+	xfpm_info_free (info);
+    }
+    
+    g_object_unref (unique);
+    
+    return EXIT_SUCCESS;
+}
diff --git a/src/xfpm-power.c b/src/xfpm-power.c
new file mode 100644
index 0000000..6911b86
--- /dev/null
+++ b/src/xfpm-power.c
@@ -0,0 +1,1709 @@
+/*
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+#include <libxfce4util/libxfce4util.h>
+#include <libxfce4ui/libxfce4ui.h>
+
+#include "xfpm-power.h"
+#include "xfpm-dbus.h"
+#include "xfpm-battery.h"
+#include "xfpm-xfconf.h"
+#include "xfpm-notify.h"
+#include "xfpm-errors.h"
+#include "xfpm-console-kit.h"
+#include "xfpm-inhibit.h"
+#include "xfpm-polkit.h"
+#include "xfpm-network-manager.h"
+#include "xfpm-icons.h"
+#include "xfpm-common.h"
+#include "xfpm-power-common.h"
+#include "xfpm-config.h"
+#include "xfpm-enum-glib.h"
+#include "xfpm-debug.h"
+#include "xfpm-enum-types.h"
+
+static void xfpm_power_finalize     (GObject *object);
+
+static void xfpm_power_get_property (GObject *object,
+				   guint prop_id,
+				   GValue *value,
+				   GParamSpec *pspec);
+
+static void xfpm_power_dbus_class_init (XfpmPowerClass * klass);
+static void xfpm_power_dbus_init (XfpmPower *power);
+
+static void xfpm_power_refresh_adaptor_visible (XfpmPower *power);
+
+#define XFPM_POWER_GET_PRIVATE(o) \
+(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_DKP, XfpmPowerPrivate))
+
+struct XfpmPowerPrivate
+{
+    DBusGConnection *bus;
+    
+    DBusGProxy      *proxy;
+    DBusGProxy      *proxy_prop;
+    
+    GHashTable      *hash;
+    
+    XfpmConsoleKit  *console;
+    XfpmInhibit	    *inhibit;
+    XfpmXfconf      *conf;
+    GtkStatusIcon   *adapter_icon;
+    
+    gboolean	     inhibited;
+    
+    XfpmNotify	    *notify;
+#ifdef HAVE_POLKIT
+    XfpmPolkit 	    *polkit;
+#endif
+    gboolean	     auth_suspend;
+    gboolean	     auth_hibernate;
+    
+    /* Properties */
+    gboolean	     on_low_battery;
+    gboolean	     lid_is_present;
+    gboolean         lid_is_closed;
+    gboolean	     on_battery;
+    gchar           *daemon_version;
+    gboolean	     can_suspend;
+    gboolean         can_hibernate;
+    
+    /**
+     * Warning dialog to use when notification daemon 
+     * doesn't support actions.
+     **/
+    GtkWidget 	    *dialog;
+};
+
+enum
+{
+    PROP_0,
+    PROP_ON_LOW_BATTERY,
+    PROP_ON_BATTERY,
+    PROP_AUTH_SUSPEND,
+    PROP_AUTH_HIBERNATE,
+    PROP_CAN_SUSPEND,
+    PROP_CAN_HIBERNATE,
+    PROP_HAS_LID
+};
+
+enum
+{
+    ON_BATTERY_CHANGED,
+    LOW_BATTERY_CHANGED,
+    LID_CHANGED,
+    WAKING_UP,
+    SLEEPING,
+    ASK_SHUTDOWN,
+    SHUTDOWN,
+    LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+
+
+G_DEFINE_TYPE (XfpmPower, xfpm_power, G_TYPE_OBJECT)
+
+#ifdef HAVE_POLKIT
+static void
+xfpm_power_check_polkit_auth (XfpmPower *power)
+{
+    power->priv->auth_suspend = xfpm_polkit_check_auth (power->priv->polkit, 
+						      "org.freedesktop.devicekit.power.suspend");
+
+    power->priv->auth_hibernate = xfpm_polkit_check_auth (power->priv->polkit, 
+							"org.freedesktop.devicekit.power.hibernate");
+
+}
+#endif
+
+static void
+xfpm_power_check_pm (XfpmPower *power, GHashTable *props)
+{
+    GValue *value;
+    gboolean ret;
+    
+    value = g_hash_table_lookup (props, "CanSuspend");
+    
+    if (value == NULL) 
+    {
+	g_warning ("No 'CanSuspend' property");
+    }
+    ret = g_value_get_boolean (value);
+    
+    if (ret != power->priv->can_suspend) 
+    {
+	power->priv->can_suspend = ret;
+    }
+
+    value = g_hash_table_lookup (props, "CanHibernate");
+    
+    if (value == NULL) 
+    {
+	g_warning ("No 'CanHibernate' property");
+    }
+    
+    ret = g_value_get_boolean (value);
+    
+    if (ret != power->priv->can_hibernate) 
+    {
+	power->priv->can_hibernate = ret;
+    }
+}
+
+static void
+xfpm_power_check_power (XfpmPower *power, GHashTable *props)
+{
+    GValue *value;
+    gboolean on_battery;
+    
+    value = g_hash_table_lookup (props, "OnBattery");
+    
+    if (G_LIKELY (value)) 
+    {
+	on_battery = g_value_get_boolean (value);
+    
+	if (on_battery != power->priv->on_battery ) 
+	{
+	    GList *list;
+	    guint len, i;
+	    g_signal_emit (G_OBJECT (power), signals [ON_BATTERY_CHANGED], 0, on_battery);
+	    power->priv->on_battery = on_battery;
+	    list = g_hash_table_get_values (power->priv->hash);
+	    len = g_list_length (list);
+	    for ( i = 0; i < len; i++)
+	    {
+		g_object_set (G_OBJECT (g_list_nth_data (list, i)), 
+			      "ac-online", !on_battery,
+			      NULL);
+	    }
+	}
+    }
+    else
+    {
+	g_warning ("No 'OnBattery' property");
+    }
+}
+
+static void
+xfpm_power_check_lid (XfpmPower *power, GHashTable *props)
+{
+    GValue *value;
+    
+    value = g_hash_table_lookup (props, "LidIsPresent");
+    
+    if (value == NULL) 
+    {
+	g_warning ("No 'LidIsPresent' property");
+	return;
+    }
+
+    power->priv->lid_is_present = g_value_get_boolean (value);
+
+    if (power->priv->lid_is_present) 
+    {
+	gboolean closed;
+	
+	value = g_hash_table_lookup (props, "LidIsClosed");
+    
+	if (value == NULL) 
+	{
+	    g_warning ("No 'LidIsClosed' property");
+	    return;
+	}
+	
+	closed = g_value_get_boolean (value);
+	
+	if (closed != power->priv->lid_is_closed ) 
+	{
+	    power->priv->lid_is_closed = closed;
+	    g_signal_emit (G_OBJECT (power), signals [LID_CHANGED], 0, power->priv->lid_is_closed);
+	}
+    }
+}
+
+static void
+xfpm_power_check_daemon_version (XfpmPower *power, GHashTable *props)
+{
+    GValue *value;
+    gint power_version;
+	
+    value = g_hash_table_lookup (props, "DaemonVersion");
+
+    if (value == NULL) 
+    {
+	g_warning ("No 'DaemonVersion' property");
+	/*
+	 * Version less than 011 uses dash-dash
+	 */
+	value = g_hash_table_lookup (props, "daemon-version");
+	
+	if (value == NULL) 
+	{
+	    g_warning ("No 'daemon-version' property");
+	    goto out;
+	}
+    }
+    
+    power->priv->daemon_version = g_strdup (g_value_get_string (value));
+    XFPM_DEBUG ("Dkp daemon version %s", power->priv->daemon_version);
+    power_version = strtol (power->priv->daemon_version, NULL, 10);
+    
+    if ( power_version < 11)
+    {
+	XfconfChannel *channel;
+	gboolean show_error;
+	
+	channel = xfpm_xfconf_get_channel (power->priv->conf);
+	
+	show_error = xfconf_channel_get_bool (channel, PROPERTIES_PREFIX "show-power-version-error", TRUE);
+	
+	XFPM_WARNING ("Dkp version %d is less than the required minimum version 011", power_version);
+	
+	
+	if ( show_error )
+	{
+	    GError *error = NULL;
+	    gchar *message;
+	    message = g_strdup_printf ("%s %s", 
+				   _("Xfce Power Manager requires version 011 of devicekit-power " 
+				   "to work properly while the version found is"), 
+				   power->priv->daemon_version);
+		
+	    g_set_error (&error, 0, 0, "%s", message);
+	    xfce_dialog_show_error (NULL, error, "%s", _("Devicekit-power version 011 or above not found"));
+	    xfconf_channel_set_bool (channel, PROPERTIES_PREFIX "show-power-version-error", FALSE);
+	    g_free (message);
+	    g_error_free (error);
+	}
+	
+	g_error (_("Devicekit-power version 011 or above not found"));
+    }
+out:
+    ;
+}
+
+/*
+ * Get the properties on org.freedesktop.DeviceKit.Power
+ * 
+ * DaemonVersion      's'
+ * CanSuspend'        'b'
+ * CanHibernate'      'b'
+ * OnBattery'         'b'
+ * OnLowBattery'      'b'
+ * LidIsClosed'       'b'
+ * LidIsPresent'      'b'
+ */
+static void
+xfpm_power_get_properties (XfpmPower *power)
+{
+    GHashTable *props;
+    
+    props = xfpm_power_get_interface_properties (power->priv->proxy_prop, DKP_IFACE);
+    
+    xfpm_power_check_pm (power, props);
+    xfpm_power_check_lid (power, props);
+    xfpm_power_check_power (power, props);
+
+    if ( power->priv->daemon_version == NULL )
+    {
+	xfpm_power_check_daemon_version (power, props);
+    }
+    g_hash_table_destroy (props);
+}
+
+static void
+xfpm_power_report_error (XfpmPower *power, const gchar *error, const gchar *icon_name)
+{
+    GtkStatusIcon *battery = NULL;
+    guint i, len;
+    GList *list;
+    
+    list = g_hash_table_get_values (power->priv->hash);
+    len = g_list_length (list);
+    
+    for ( i = 0; i < len; i++)
+    {
+	XfpmDeviceType type;
+	battery = g_list_nth_data (list, i);
+	type = xfpm_battery_get_device_type (XFPM_BATTERY (battery));
+	if ( type == XFPM_DEVICE_TYPE_BATTERY ||
+	     type == XFPM_DEVICE_TYPE_UPS )
+	     break;
+    }
+    
+    xfpm_notify_show_notification (power->priv->notify, 
+				   _("Xfce power manager"), 
+				   error, 
+				   icon_name,
+				   10000,
+				   FALSE,
+				   XFPM_NOTIFY_CRITICAL,
+				   battery);
+    
+}
+
+static void
+xfpm_power_sleep (XfpmPower *power, const gchar *sleep, gboolean force)
+{
+    GError *error = NULL;
+    gboolean lock_screen;
+    
+    if ( power->priv->inhibited && force == FALSE)
+    {
+	gboolean ret;
+	
+	ret = xfce_dialog_confirm (NULL,
+				   GTK_STOCK_YES,
+				   "Yes",
+				   _("An application is currently disabling the automatic sleep,"
+				   " doing this action now may damage the working state of this application,"
+				   " are you sure you want to hibernate the system?"),
+				   NULL);
+				   
+	if ( !ret )
+	    return;
+    }
+    
+    g_signal_emit (G_OBJECT (power), signals [SLEEPING], 0);
+    xfpm_send_message_to_network_manager ("sleep");
+        
+    g_object_get (G_OBJECT (power->priv->conf),
+		  LOCK_SCREEN_ON_SLEEP, &lock_screen,
+		  NULL);
+    
+    if ( lock_screen )
+    {
+	g_usleep (2000000); /* 2 seconds */
+	xfpm_lock_screen ();
+    }
+    
+    dbus_g_proxy_call (power->priv->proxy, sleep, &error,
+		       G_TYPE_INVALID,
+		       G_TYPE_INVALID);
+    
+    if ( error )
+    {
+	if ( g_error_matches (error, DBUS_GERROR, DBUS_GERROR_NO_REPLY) )
+	{
+	    XFPM_DEBUG ("D-Bus time out, but should be harmless");
+	}
+	else
+	{
+	    const gchar *icon_name;
+	    if ( !g_strcmp0 (sleep, "Hibernate") )
+		icon_name = XFPM_HIBERNATE_ICON;
+	    else
+		icon_name = XFPM_SUSPEND_ICON;
+	    
+	    xfpm_power_report_error (power, error->message, icon_name);
+	    g_error_free (error);
+	}
+    }
+    
+    g_signal_emit (G_OBJECT (power), signals [WAKING_UP], 0);
+    xfpm_send_message_to_network_manager ("wake");
+}
+
+static void
+xfpm_power_hibernate_cb (XfpmPower *power)
+{
+    xfpm_power_sleep (power, "Hibernate", FALSE);
+}
+
+static void
+xfpm_power_suspend_cb (XfpmPower *power)
+{
+    xfpm_power_sleep (power, "Suspend", FALSE);
+}
+
+static void
+xfpm_power_hibernate_clicked (XfpmPower *power)
+{
+    gtk_widget_destroy (power->priv->dialog );
+    power->priv->dialog = NULL;
+    xfpm_power_sleep (power, "Hibernate", TRUE);
+}
+
+static void
+xfpm_power_suspend_clicked (XfpmPower *power)
+{
+    gtk_widget_destroy (power->priv->dialog );
+    power->priv->dialog = NULL;
+    xfpm_power_sleep (power, "Suspend", TRUE);
+}
+
+static void
+xfpm_power_shutdown_clicked (XfpmPower *power)
+{
+    gtk_widget_destroy (power->priv->dialog );
+    power->priv->dialog = NULL;
+    g_signal_emit (G_OBJECT (power), signals [SHUTDOWN], 0);
+}
+
+static void
+xfpm_power_power_info_cb (gpointer data)
+{
+    g_spawn_command_line_async ("xfce4-power-information", NULL);
+}
+
+static void
+xfpm_power_tray_exit_activated_cb (gpointer data)
+{
+    gboolean ret;
+    
+    ret = xfce_dialog_confirm (NULL, 
+			       GTK_STOCK_YES, 
+			       _("Quit"),
+			       _("All running instances of the power manager will exit"),
+			       "%s",
+			        _("Quit Xfce power manager?"));
+    if ( ret )
+    {
+	xfpm_quit ();
+    }
+}
+
+static void
+xfpm_power_show_tray_menu (XfpmPower *power, 
+			 GtkStatusIcon *icon, 
+			 guint button, 
+			 guint activate_time,
+			 gboolean show_info_item)
+{
+    GtkWidget *menu, *mi, *img;
+
+    menu = gtk_menu_new();
+
+    // Hibernate menu option
+    mi = gtk_image_menu_item_new_with_label (_("Hibernate"));
+    img = gtk_image_new_from_icon_name (XFPM_HIBERNATE_ICON, GTK_ICON_SIZE_MENU);
+    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img);
+    gtk_widget_set_sensitive (mi, FALSE);
+    
+    if ( power->priv->can_hibernate && power->priv->auth_hibernate)
+    {
+	gtk_widget_set_sensitive (mi, TRUE);
+	g_signal_connect_swapped (G_OBJECT (mi), "activate",
+				  G_CALLBACK (xfpm_power_hibernate_cb), power);
+    }
+    gtk_widget_show (mi);
+    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+    
+    // Suspend menu option
+    mi = gtk_image_menu_item_new_with_label (_("Suspend"));
+    img = gtk_image_new_from_icon_name (XFPM_SUSPEND_ICON, GTK_ICON_SIZE_MENU);
+    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img);
+    
+    gtk_widget_set_sensitive (mi, FALSE);
+    
+    if ( power->priv->can_suspend && power->priv->auth_hibernate)
+    {
+	gtk_widget_set_sensitive (mi, TRUE);
+	g_signal_connect_swapped (mi, "activate",
+				  G_CALLBACK (xfpm_power_suspend_cb), power);
+    }
+    
+    gtk_widget_show (mi);
+    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+/*
+    saver_inhibited = xfpm_screen_saver_get_inhibit (tray->priv->srv);
+    mi = gtk_check_menu_item_new_with_label (_("Monitor power control"));
+    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi), !saver_inhibited);
+    gtk_widget_set_tooltip_text (mi, _("Disable or enable monitor power control, "\
+                                       "for example you could disable the screen power "\
+				       "control to avoid screen blanking when watching a movie."));
+    
+    g_signal_connect (G_OBJECT (mi), "activate",
+		      G_CALLBACK (xfpm_tray_icon_inhibit_active_cb), tray);
+    gtk_widget_set_sensitive (mi, TRUE);
+    gtk_widget_show(mi);
+    gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
+*/
+    
+    mi = gtk_separator_menu_item_new ();
+    gtk_widget_show (mi);
+    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+
+    // Power information
+    
+    mi = gtk_image_menu_item_new_with_label (_("Power Information"));
+    img = gtk_image_new_from_stock (GTK_STOCK_INFO, GTK_ICON_SIZE_MENU);
+    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img);
+
+    gtk_widget_set_sensitive (mi,TRUE);
+    
+    g_signal_connect_swapped (mi, "activate",
+			      G_CALLBACK (xfpm_power_power_info_cb), icon);
+		     
+    gtk_widget_show (mi);
+    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+    
+    mi = gtk_separator_menu_item_new ();
+    gtk_widget_show (mi);
+    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+		     
+    mi = gtk_image_menu_item_new_from_stock (GTK_STOCK_HELP, NULL);
+    gtk_widget_set_sensitive (mi, TRUE);
+    gtk_widget_show (mi);
+    g_signal_connect (mi, "activate", G_CALLBACK (xfpm_help), NULL);
+	
+    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+    
+    mi = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT, NULL);
+    gtk_widget_set_sensitive (mi, TRUE);
+    gtk_widget_show (mi);
+    g_signal_connect (mi, "activate", G_CALLBACK (xfpm_about), _("Xfce Power Manager"));
+    
+    gtk_menu_shell_append (GTK_MENU_SHELL(menu), mi);
+    
+    mi = gtk_image_menu_item_new_from_stock (GTK_STOCK_PREFERENCES, NULL);
+    gtk_widget_set_sensitive (mi, TRUE);
+    gtk_widget_show (mi);
+    g_signal_connect (mi, "activate",G_CALLBACK (xfpm_preferences), NULL);
+    
+    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+
+    mi = gtk_separator_menu_item_new ();
+    gtk_widget_show (mi);
+    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+
+    mi = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL);
+    gtk_widget_set_sensitive (mi, TRUE);
+    gtk_widget_show (mi);
+    g_signal_connect_swapped (mi, "activate", G_CALLBACK (xfpm_power_tray_exit_activated_cb), NULL);
+    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+
+    g_signal_connect (menu, "selection-done",
+		      G_CALLBACK (gtk_widget_destroy), NULL);
+
+    // Popup the menu
+    gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
+		   gtk_status_icon_position_menu, 
+		   icon, button, activate_time);
+    
+}
+
+static void 
+xfpm_power_show_tray_menu_battery (GtkStatusIcon *icon, guint button, 
+			         guint activate_time, XfpmPower *power)
+{
+    xfpm_power_show_tray_menu (power, icon, button, activate_time, TRUE);
+}
+
+static void 
+xfpm_power_show_tray_menu_adaptor (GtkStatusIcon *icon, guint button, 
+			         guint activate_time, XfpmPower *power)
+{
+    xfpm_power_show_tray_menu (power, icon, button, activate_time, FALSE);
+}
+
+static XfpmBatteryCharge
+xfpm_power_get_current_charge_state (XfpmPower *power)
+{
+    GList *list;
+    guint len, i;
+    XfpmBatteryCharge max_charge_status = XFPM_BATTERY_CHARGE_UNKNOWN;
+    
+    list = g_hash_table_get_values (power->priv->hash);
+    len = g_list_length (list);
+    
+    for ( i = 0; i < len; i++)
+    {
+	XfpmBatteryCharge battery_charge;
+	XfpmDeviceType type;
+	
+	g_object_get (G_OBJECT (g_list_nth_data (list, i)),
+		      "charge-status", &battery_charge,
+		      "device-type", &type,
+		      NULL);
+	if ( type != XFPM_DEVICE_TYPE_BATTERY && 
+	     type != XFPM_DEVICE_TYPE_UPS )
+	    continue;
+	
+	max_charge_status = MAX (max_charge_status, battery_charge);
+    }
+    
+    return max_charge_status;
+}
+
+static void
+xfpm_power_notify_action_callback (NotifyNotification *n, gchar *action, XfpmPower *power)
+{
+    if ( !g_strcmp0 (action, "Shutdown") )
+	g_signal_emit (G_OBJECT (power), signals [SHUTDOWN], 0);
+    else
+	xfpm_power_sleep (power, action, TRUE);
+}
+
+static void
+xfpm_power_add_actions_to_notification (XfpmPower *power, NotifyNotification *n)
+{
+    gboolean can_shutdown;
+    
+    g_object_get (G_OBJECT (power->priv->console),
+		  "can-shutdown", &can_shutdown,
+		  NULL);
+		  
+    if (  power->priv->can_hibernate && power->priv->auth_hibernate )
+    {
+        xfpm_notify_add_action_to_notification(
+			       power->priv->notify,
+			       n,
+                               "Hibernate",
+                               _("Hibernate the system"),
+                               (NotifyActionCallback)xfpm_power_notify_action_callback,
+                               power);      
+    }
+    
+    if (  power->priv->can_suspend && power->priv->auth_suspend )
+    {
+        xfpm_notify_add_action_to_notification(
+			       power->priv->notify,
+			       n,
+                               "Suspend",
+                               _("Suspend the system"),
+                               (NotifyActionCallback)xfpm_power_notify_action_callback,
+                               power);      
+    }
+    
+    if (can_shutdown )
+	xfpm_notify_add_action_to_notification(
+				   power->priv->notify,
+				   n,
+				   "Shutdown",
+				   _("Shutdown the system"),
+				   (NotifyActionCallback)xfpm_power_notify_action_callback,
+				   power);    
+}
+
+static void
+xfpm_power_show_critical_action_notification (XfpmPower *power, XfpmBattery *battery)
+{
+    const gchar *message;
+    NotifyNotification *n;
+    
+    message = _("System is running on low power. "\
+               "Save your work to avoid losing data");
+	      
+    n = 
+	xfpm_notify_new_notification (power->priv->notify, 
+				      _("Xfce power manager"), 
+				      message, 
+				      gtk_status_icon_get_icon_name (GTK_STATUS_ICON (battery)),
+				      20000,
+				      XFPM_NOTIFY_CRITICAL,
+				      GTK_STATUS_ICON (battery));
+    
+    xfpm_power_add_actions_to_notification (power, n);
+    xfpm_notify_critical (power->priv->notify, n);
+
+}
+
+static void
+xfpm_power_close_critical_dialog (XfpmPower *power)
+{
+    gtk_widget_destroy (power->priv->dialog);
+    power->priv->dialog = NULL;
+}
+
+static void
+xfpm_power_show_critical_action_gtk (XfpmPower *power)
+{
+    GtkWidget *dialog;
+    GtkWidget *content_area;
+    GtkWidget *img;
+    GtkWidget *cancel;
+    const gchar *message;
+    gboolean can_shutdown;
+    
+    g_object_get (G_OBJECT (power->priv->console),
+		  "can-shutdown", &can_shutdown,
+		  NULL);
+    
+    message = _("System is running on low power. "\
+               "Save your work to avoid losing data");
+    
+    dialog = gtk_dialog_new_with_buttons (_("Xfce Power Manager"), NULL, GTK_DIALOG_MODAL,
+                                          NULL);
+    
+    gtk_dialog_set_default_response (GTK_DIALOG (dialog),
+                                     GTK_RESPONSE_CANCEL);
+    
+    content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+    gtk_box_pack_start_defaults (GTK_BOX (content_area), gtk_label_new (message));
+    
+    if ( power->priv->can_hibernate && power->priv->auth_hibernate )
+    {
+	GtkWidget *hibernate;
+	hibernate = gtk_button_new_with_label (_("Hibernate"));
+	img = gtk_image_new_from_icon_name (XFPM_HIBERNATE_ICON, GTK_ICON_SIZE_BUTTON);
+	gtk_button_set_image (GTK_BUTTON (hibernate), img);
+	gtk_dialog_add_action_widget (GTK_DIALOG (dialog), hibernate, GTK_RESPONSE_NONE);
+	
+	g_signal_connect_swapped (hibernate, "clicked",
+			          G_CALLBACK (xfpm_power_hibernate_clicked), power);
+    }
+    
+    if ( power->priv->can_suspend && power->priv->auth_suspend )
+    {
+	GtkWidget *suspend;
+	
+	suspend = gtk_button_new_with_label (_("Suspend"));
+	img = gtk_image_new_from_icon_name (XFPM_SUSPEND_ICON, GTK_ICON_SIZE_BUTTON);
+	gtk_button_set_image (GTK_BUTTON (suspend), img);
+	gtk_dialog_add_action_widget (GTK_DIALOG (dialog), suspend, GTK_RESPONSE_NONE);
+	
+	g_signal_connect_swapped (suspend, "clicked",
+			          G_CALLBACK (xfpm_power_suspend_clicked), power);
+    }
+    
+    if ( can_shutdown )
+    {
+	GtkWidget *shutdown;
+	
+	shutdown = gtk_button_new_with_label (_("Shutdown"));
+	img = gtk_image_new_from_icon_name (XFPM_SUSPEND_ICON, GTK_ICON_SIZE_BUTTON);
+	gtk_button_set_image (GTK_BUTTON (shutdown), img);
+	gtk_dialog_add_action_widget (GTK_DIALOG (dialog), shutdown, GTK_RESPONSE_NONE);
+	
+	g_signal_connect_swapped (shutdown, "clicked",
+			          G_CALLBACK (xfpm_power_shutdown_clicked), power);
+    }
+    
+    cancel = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
+    gtk_dialog_add_action_widget (GTK_DIALOG (dialog), cancel, GTK_RESPONSE_NONE);
+    
+    g_signal_connect_swapped (cancel, "clicked",
+			      G_CALLBACK (xfpm_power_close_critical_dialog), power);
+    
+    g_signal_connect_swapped (dialog, "destroy",
+			      G_CALLBACK (xfpm_power_close_critical_dialog), power);
+    if ( power->priv->dialog )
+    {
+	gtk_widget_destroy (power->priv->dialog);
+	power->priv->dialog = NULL;
+	
+    }
+    power->priv->dialog = dialog;
+    gtk_widget_show_all (dialog);
+}
+
+static void
+xfpm_power_show_critical_action (XfpmPower *power, XfpmBattery *battery)
+{
+    gboolean supports_actions;
+    
+    g_object_get (G_OBJECT (power->priv->notify),
+		  "actions", &supports_actions,
+		  NULL);
+		  
+    if ( supports_actions )
+	xfpm_power_show_critical_action_notification (power, battery);
+    else
+	xfpm_power_show_critical_action_gtk (power);
+}
+
+static void
+xfpm_power_process_critical_action (XfpmPower *power, XfpmShutdownRequest req)
+{
+    if ( req == XFPM_ASK )
+	g_signal_emit (G_OBJECT (power), signals [ASK_SHUTDOWN], 0);
+    else if ( req == XFPM_DO_SUSPEND )
+	xfpm_power_sleep (power, "Suspend", TRUE);
+    else if ( req == XFPM_DO_HIBERNATE )
+	xfpm_power_sleep (power, "Hibernate", TRUE);
+    else if ( req == XFPM_DO_SHUTDOWN )
+	g_signal_emit (G_OBJECT (power), signals [SHUTDOWN], 0);
+}
+
+static void
+xfpm_power_system_on_low_power (XfpmPower *power, XfpmBattery *battery)
+{
+    XfpmShutdownRequest critical_action;
+    
+    g_object_get (G_OBJECT (power->priv->conf),
+	          CRITICAL_BATT_ACTION_CFG, &critical_action,
+		  NULL);
+
+    XFPM_DEBUG ("System is running on low power");
+    XFPM_DEBUG_ENUM (critical_action, XFPM_TYPE_SHUTDOWN_REQUEST, "Critical battery action");
+
+    if ( critical_action == XFPM_DO_NOTHING )
+    {
+	xfpm_power_show_critical_action (power, battery);
+    }
+    else
+    {
+	xfpm_power_process_critical_action (power, critical_action);
+    }
+}
+
+static void
+xfpm_power_battery_charge_changed_cb (XfpmBattery *battery, XfpmPower *power)
+{
+    gboolean notify;
+    XfpmBatteryCharge battery_charge;
+    XfpmBatteryCharge current_charge;
+    
+    battery_charge = xfpm_battery_get_charge (battery);
+    current_charge = xfpm_power_get_current_charge_state (power);
+    
+    XFPM_DEBUG_ENUM (current_charge, XFPM_TYPE_BATTERY_CHARGE, "Current system charge status");
+    
+    if ( current_charge == XFPM_BATTERY_CHARGE_CRITICAL && power->priv->on_battery)
+    {
+	xfpm_power_system_on_low_power (power, battery);
+	power->priv->on_low_battery = TRUE;
+	g_signal_emit (G_OBJECT (power), signals [LOW_BATTERY_CHANGED], 0, power->priv->on_low_battery);
+	return;
+    }
+    
+    if ( power->priv->on_low_battery )
+    {
+	power->priv->on_low_battery = FALSE;
+	g_signal_emit (G_OBJECT (power), signals [LOW_BATTERY_CHANGED], 0, power->priv->on_low_battery);
+    }
+    
+    g_object_get (G_OBJECT (power->priv->conf),
+		  GENERAL_NOTIFICATION_CFG, &notify,
+		  NULL);
+    
+    if ( power->priv->on_battery )
+    {
+	if ( current_charge == XFPM_BATTERY_CHARGE_LOW )
+	{
+	    if ( notify )
+		xfpm_notify_show_notification (power->priv->notify, 
+					       _("Xfce power manager"), 
+					       _("System is running on low power"), 
+					       gtk_status_icon_get_icon_name (GTK_STATUS_ICON (battery)),
+					       10000,
+					       FALSE,
+					       XFPM_NOTIFY_NORMAL,
+					       GTK_STATUS_ICON (battery));
+	    
+	}
+	else if ( battery_charge == XFPM_BATTERY_CHARGE_LOW )
+	{
+	    
+	    if ( notify )
+		xfpm_notify_show_notification (power->priv->notify, 
+					       _("Xfce power manager"), 
+					       _("Battery charge level is low"), 
+					       gtk_status_icon_get_icon_name (GTK_STATUS_ICON (battery)),
+					       10000,
+					       FALSE,
+					       XFPM_NOTIFY_NORMAL,
+					       GTK_STATUS_ICON (battery));
+	}
+    }
+    
+    /*Current charge is okay now, then close the dialog*/
+    if ( power->priv->dialog )
+    {
+	gtk_widget_destroy (power->priv->dialog);
+	power->priv->dialog = NULL;
+    }
+}
+
+static void
+xfpm_power_add_device (XfpmPower *power, const gchar *object_path)
+{
+    DBusGProxy *proxy_prop;
+    guint device_type;
+    GValue value;
+    
+    proxy_prop = dbus_g_proxy_new_for_name (power->priv->bus, 
+					    DKP_NAME,
+					    object_path,
+					    DBUS_INTERFACE_PROPERTIES);
+				       
+    if ( !proxy_prop )
+    {
+	g_warning ("Unable to create proxy for : %s", object_path);
+	return;
+    }
+    
+    value = xfpm_power_get_interface_property (proxy_prop, DKP_IFACE_DEVICE, "Type");
+    
+    device_type = g_value_get_uint (&value);
+    
+    if ( device_type == XFPM_DEVICE_TYPE_BATTERY || 
+	 device_type == XFPM_DEVICE_TYPE_UPS     ||
+	 device_type == XFPM_DEVICE_TYPE_MOUSE   ||
+	 device_type == XFPM_DEVICE_TYPE_KBD     ||
+	 device_type == XFPM_DEVICE_TYPE_PHONE)
+    {
+	GtkStatusIcon *battery;
+	DBusGProxy *proxy;
+	XFPM_DEBUG_ENUM (device_type, XFPM_TYPE_DEVICE_TYPE, 
+			"Battery device detected at : %s", object_path);
+	proxy = dbus_g_proxy_new_for_name (power->priv->bus,
+					   DKP_NAME,
+					   object_path,
+					   DKP_IFACE_DEVICE);
+	battery = xfpm_battery_new ();
+	gtk_status_icon_set_visible (battery, FALSE);
+	xfpm_battery_monitor_device (XFPM_BATTERY (battery), proxy, proxy_prop, device_type);
+	g_hash_table_insert (power->priv->hash, g_strdup (object_path), battery);
+	
+	g_signal_connect (battery, "popup-menu",
+			  G_CALLBACK (xfpm_power_show_tray_menu_battery), power);
+	
+	g_signal_connect (battery, "battery-charge-changed",
+			  G_CALLBACK (xfpm_power_battery_charge_changed_cb), power);
+			  
+	xfpm_power_refresh_adaptor_visible (power);
+    }
+    else if ( device_type != XFPM_DEVICE_TYPE_LINE_POWER )
+    {
+	g_warning ("Unable to monitor unkown power device with object_path : %s", object_path);
+	g_object_unref (proxy_prop);
+    }
+}
+
+static void
+xfpm_power_get_power_devices (XfpmPower *power)
+{
+    GPtrArray *array = NULL;
+    guint i;
+    
+    array = xfpm_power_enumerate_devices (power->priv->proxy);
+    
+    if ( array )
+    {
+	for ( i = 0; i < array->len; i++)
+	{
+	    const gchar *object_path = ( const gchar *) g_ptr_array_index (array, i);
+	    XFPM_DEBUG ("Power device detected at : %s", object_path);
+	    xfpm_power_add_device (power, object_path);
+	}
+	g_ptr_array_free (array, TRUE);
+    }
+    
+}
+
+static void
+xfpm_power_remove_device (XfpmPower *power, const gchar *object_path)
+{
+    g_hash_table_remove (power->priv->hash, object_path);
+    xfpm_power_refresh_adaptor_visible (power);
+}
+
+static void
+xfpm_power_inhibit_changed_cb (XfpmInhibit *inhibit, gboolean is_inhibit, XfpmPower *power)
+{
+    power->priv->inhibited = is_inhibit;
+}
+
+static void
+xfpm_power_changed_cb (DBusGProxy *proxy, XfpmPower *power)
+{
+    xfpm_power_get_properties (power);
+}
+
+static void
+xfpm_power_device_added_cb (DBusGProxy *proxy, const gchar *object_path, XfpmPower *power)
+{
+    xfpm_power_add_device (power, object_path);
+}
+
+static void
+xfpm_power_device_removed_cb (DBusGProxy *proxy, const gchar *object_path, XfpmPower *power)
+{
+    xfpm_power_remove_device (power, object_path);
+}
+
+static void
+xfpm_power_device_changed_cb (DBusGProxy *proxy, const gchar *object_path, XfpmPower *power)
+{
+    XfpmBattery *battery;
+    
+    battery = g_hash_table_lookup (power->priv->hash, object_path);
+    
+    if ( battery )
+    {
+	
+    }
+}
+
+#ifdef HAVE_POLKIT
+static void
+xfpm_power_polkit_auth_changed_cb (XfpmPower *power)
+{
+    XFPM_DEBUG ("Auth configuration changed");
+    xfpm_power_check_polkit_auth (power);
+}
+#endif
+
+static void
+xfpm_power_hide_adapter_icon (XfpmPower *power)
+{
+     XFPM_DEBUG ("Hide adaptor icon");
+     
+    if ( power->priv->adapter_icon )
+    {
+        g_object_unref (power->priv->adapter_icon);
+        power->priv->adapter_icon = NULL;
+    }
+}
+
+static void
+xfpm_power_show_adapter_icon (XfpmPower *power)
+{
+    g_return_if_fail (power->priv->adapter_icon == NULL);
+    
+    power->priv->adapter_icon = gtk_status_icon_new ();
+    
+    XFPM_DEBUG ("Showing adaptor icon");
+    
+    gtk_status_icon_set_from_icon_name (power->priv->adapter_icon, XFPM_AC_ADAPTER_ICON);
+    
+    gtk_status_icon_set_visible (power->priv->adapter_icon, TRUE);
+    
+    g_signal_connect (power->priv->adapter_icon, "popup-menu",
+		      G_CALLBACK (xfpm_power_show_tray_menu_adaptor), power);
+}
+
+static void
+xfpm_power_refresh_adaptor_visible (XfpmPower *power)
+{
+    XfpmShowIcon show_icon;
+    
+    g_object_get (G_OBJECT (power->priv->conf),
+		  SHOW_TRAY_ICON_CFG, &show_icon,
+		  NULL);
+		  
+    XFPM_DEBUG_ENUM (show_icon, XFPM_TYPE_SHOW_ICON, "Tray icon configuration: ");
+    
+    if ( show_icon == SHOW_ICON_ALWAYS )
+    {
+	if ( g_hash_table_size (power->priv->hash) == 0 )
+	{
+	    xfpm_power_show_adapter_icon (power);
+#if GTK_CHECK_VERSION (2, 16, 0)
+	    gtk_status_icon_set_tooltip_text (power->priv->adapter_icon, 
+					      power->priv->on_battery ? 
+					      _("Adaptor is offline") :
+					      _("Adaptor is online") );
+#else
+	    gtk_status_icon_set_tooltip (power->priv->adapter_icon, 
+					 power->priv->on_battery ? 
+					 _("Adaptor is offline") :
+					 _("Adaptor is online") );
+#endif
+	}
+	else
+	{
+	    xfpm_power_hide_adapter_icon (power);
+	}
+    }
+    else
+    {
+	xfpm_power_hide_adapter_icon (power);
+    }
+}
+
+static void
+xfpm_power_class_init (XfpmPowerClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    object_class->finalize = xfpm_power_finalize;
+
+    object_class->get_property = xfpm_power_get_property;
+
+    signals [ON_BATTERY_CHANGED] = 
+        g_signal_new ("on-battery-changed",
+                      XFPM_TYPE_DKP,
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET(XfpmPowerClass, on_battery_changed),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__BOOLEAN,
+                      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+
+    signals [LOW_BATTERY_CHANGED] = 
+        g_signal_new ("low-battery-changed",
+                      XFPM_TYPE_DKP,
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET(XfpmPowerClass, low_battery_changed),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__BOOLEAN,
+                      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+
+    signals [LID_CHANGED] = 
+        g_signal_new ("lid-changed",
+                      XFPM_TYPE_DKP,
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET(XfpmPowerClass, lid_changed),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__BOOLEAN,
+                      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+
+    signals [WAKING_UP] = 
+        g_signal_new ("waking-up",
+                      XFPM_TYPE_DKP,
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET(XfpmPowerClass, waking_up),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE, 0, G_TYPE_NONE);
+
+    signals [SLEEPING] = 
+        g_signal_new ("sleeping",
+                      XFPM_TYPE_DKP,
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET(XfpmPowerClass, sleeping),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE, 0, G_TYPE_NONE);
+
+    signals [ASK_SHUTDOWN] = 
+        g_signal_new ("ask-shutdown",
+                      XFPM_TYPE_DKP,
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET(XfpmPowerClass, ask_shutdown),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE, 0, G_TYPE_NONE);
+
+    signals [SHUTDOWN] = 
+        g_signal_new ("shutdown",
+                      XFPM_TYPE_DKP,
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET(XfpmPowerClass, shutdown),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE, 0, G_TYPE_NONE);
+
+    g_object_class_install_property (object_class,
+                                     PROP_ON_BATTERY,
+                                     g_param_spec_boolean ("on-battery",
+                                                          NULL, NULL,
+                                                          FALSE,
+                                                          G_PARAM_READABLE));
+
+    g_object_class_install_property (object_class,
+                                     PROP_ON_LOW_BATTERY,
+                                     g_param_spec_boolean ("on-low-battery",
+                                                          NULL, NULL,
+                                                          FALSE,
+                                                          G_PARAM_READABLE));
+
+    g_object_class_install_property (object_class,
+                                     PROP_AUTH_SUSPEND,
+                                     g_param_spec_boolean ("auth-suspend",
+                                                          NULL, NULL,
+                                                          FALSE,
+                                                          G_PARAM_READABLE));
+
+    g_object_class_install_property (object_class,
+                                     PROP_AUTH_HIBERNATE,
+                                     g_param_spec_boolean ("auth-hibernate",
+                                                          NULL, NULL,
+                                                          FALSE,
+                                                          G_PARAM_READABLE));
+
+    g_object_class_install_property (object_class,
+                                     PROP_CAN_HIBERNATE,
+                                     g_param_spec_boolean ("can-hibernate",
+                                                          NULL, NULL,
+                                                          FALSE,
+                                                          G_PARAM_READABLE));
+
+    g_object_class_install_property (object_class,
+                                     PROP_CAN_SUSPEND,
+                                     g_param_spec_boolean ("can-suspend",
+                                                          NULL, NULL,
+                                                          FALSE,
+                                                          G_PARAM_READABLE));
+
+    g_object_class_install_property (object_class,
+                                     PROP_HAS_LID,
+                                     g_param_spec_boolean ("has-lid",
+                                                          NULL, NULL,
+                                                          FALSE,
+                                                          G_PARAM_READABLE));
+
+    g_type_class_add_private (klass, sizeof (XfpmPowerPrivate));
+    
+    xfpm_power_dbus_class_init (klass);
+}
+
+static void
+xfpm_power_init (XfpmPower *power)
+{
+    GError *error = NULL;
+    
+    power->priv = XFPM_POWER_GET_PRIVATE (power);
+    
+    power->priv->hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
+    power->priv->lid_is_present  = FALSE;
+    power->priv->lid_is_closed   = FALSE;
+    power->priv->on_battery      = FALSE;
+    power->priv->on_low_battery  = FALSE;
+    power->priv->daemon_version  = NULL;
+    power->priv->can_suspend     = FALSE;
+    power->priv->can_hibernate   = FALSE;
+    power->priv->auth_hibernate  = TRUE;
+    power->priv->auth_suspend    = TRUE;
+    power->priv->dialog          = NULL;
+    power->priv->adapter_icon    = NULL;
+    
+    power->priv->inhibit = xfpm_inhibit_new ();
+    power->priv->notify  = xfpm_notify_new ();
+    power->priv->conf    = xfpm_xfconf_new ();
+    power->priv->console = xfpm_console_kit_new ();
+    
+    g_signal_connect_swapped (power->priv->conf, "notify::" SHOW_TRAY_ICON_CFG,
+			      G_CALLBACK (xfpm_power_refresh_adaptor_visible), power);
+    
+#ifdef HAVE_POLKIT
+    power->priv->polkit  = xfpm_polkit_get ();
+    g_signal_connect_swapped (power->priv->polkit, "auth-changed",
+			      G_CALLBACK (xfpm_power_polkit_auth_changed_cb), power);
+#endif
+    
+    g_signal_connect (power->priv->inhibit, "has-inhibit-changed",
+		      G_CALLBACK (xfpm_power_inhibit_changed_cb), power);
+    
+    power->priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+    
+    if ( error )
+    {
+	g_critical ("Unable to connect to the system bus : %s", error->message);
+	g_error_free (error);
+	goto out;
+    }
+    
+    power->priv->proxy = dbus_g_proxy_new_for_name (power->priv->bus,
+					          DKP_NAME,
+						  DKP_PATH,
+						  DKP_IFACE);
+    if (power->priv->proxy == NULL) 
+    {
+	g_critical ("Unable to create proxy for %s", DKP_NAME);
+	goto out;
+    }
+    
+    power->priv->proxy_prop = dbus_g_proxy_new_for_name (power->priv->bus,
+						       DKP_NAME,
+						       DKP_PATH,
+						       DBUS_INTERFACE_PROPERTIES);
+    if (power->priv->proxy_prop == NULL) 
+    {
+	g_critical ("Unable to create proxy for %s", DKP_NAME);
+	goto out;
+    }
+    
+    xfpm_power_get_power_devices (power);
+    xfpm_power_get_properties (power);
+#ifdef HAVE_POLKIT
+    xfpm_power_check_polkit_auth (power);
+#endif
+
+    dbus_g_proxy_add_signal (power->priv->proxy, "Changed", G_TYPE_INVALID);
+    dbus_g_proxy_add_signal (power->priv->proxy, "DeviceAdded", G_TYPE_STRING, G_TYPE_INVALID);
+    dbus_g_proxy_add_signal (power->priv->proxy, "DeviceRemoved", G_TYPE_STRING, G_TYPE_INVALID);
+    dbus_g_proxy_add_signal (power->priv->proxy, "DeviceChanged", G_TYPE_STRING, G_TYPE_INVALID);
+    
+    dbus_g_proxy_connect_signal (power->priv->proxy, "Changed",
+				 G_CALLBACK (xfpm_power_changed_cb), power, NULL);
+    dbus_g_proxy_connect_signal (power->priv->proxy, "DeviceRemoved",
+				 G_CALLBACK (xfpm_power_device_removed_cb), power, NULL);
+    dbus_g_proxy_connect_signal (power->priv->proxy, "DeviceAdded",
+				 G_CALLBACK (xfpm_power_device_added_cb), power, NULL);
+   
+    dbus_g_proxy_connect_signal (power->priv->proxy, "DeviceChanged",
+				 G_CALLBACK (xfpm_power_device_changed_cb), power, NULL);
+
+    
+out:
+    xfpm_power_refresh_adaptor_visible (power);
+
+    xfpm_power_dbus_init (power);
+
+    /*
+     * Emit org.freedesktop.PowerManagement session signals on startup
+     */
+    g_signal_emit (G_OBJECT (power), signals [ON_BATTERY_CHANGED], 0, power->priv->on_battery);
+}
+
+static void xfpm_power_get_property (GObject *object,
+				   guint prop_id,
+				   GValue *value,
+				   GParamSpec *pspec)
+{
+    XfpmPower *power;
+    power = XFPM_POWER (object);
+
+    switch (prop_id)
+    {
+	case PROP_ON_BATTERY:
+	    g_value_set_boolean (value, power->priv->on_battery);
+	    break;
+	case PROP_AUTH_HIBERNATE:
+	    g_value_set_boolean (value, power->priv->auth_hibernate);
+	    break;
+	case PROP_AUTH_SUSPEND:
+	    g_value_set_boolean (value, power->priv->auth_suspend);
+	    break;
+	case PROP_CAN_SUSPEND:
+	    g_value_set_boolean (value, power->priv->can_suspend);
+	    break;
+	case PROP_CAN_HIBERNATE:
+	    g_value_set_boolean (value, power->priv->can_hibernate);
+	    break;
+	case PROP_HAS_LID:
+	    g_value_set_boolean (value, power->priv->lid_is_present);
+	    break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+            break;
+    }
+}
+
+static void
+xfpm_power_finalize (GObject *object)
+{
+    XfpmPower *power;
+
+    power = XFPM_POWER (object);
+    
+    g_free (power->priv->daemon_version);
+    
+    g_object_unref (power->priv->inhibit);
+    g_object_unref (power->priv->notify);
+    g_object_unref (power->priv->conf);
+    g_object_unref (power->priv->console);
+    
+    xfpm_power_hide_adapter_icon (power);
+    
+    dbus_g_connection_unref (power->priv->bus);
+    
+    if ( power->priv->proxy )
+    {
+	dbus_g_proxy_disconnect_signal (power->priv->proxy, "Changed",
+					G_CALLBACK (xfpm_power_changed_cb), power);
+	dbus_g_proxy_disconnect_signal (power->priv->proxy, "DeviceRemoved",
+					G_CALLBACK (xfpm_power_device_removed_cb), power);
+	dbus_g_proxy_disconnect_signal (power->priv->proxy, "DeviceAdded",
+					G_CALLBACK (xfpm_power_device_added_cb), power);
+	dbus_g_proxy_disconnect_signal (power->priv->proxy, "DeviceChanged",
+					G_CALLBACK (xfpm_power_device_changed_cb), power);
+	g_object_unref (power->priv->proxy);
+    }
+    
+    if ( power->priv->proxy_prop )
+	g_object_unref (power->priv->proxy_prop);
+
+    g_hash_table_destroy (power->priv->hash);
+
+#ifdef HAVE_POLKIT
+    g_object_unref (power->priv->polkit);
+#endif
+
+    G_OBJECT_CLASS (xfpm_power_parent_class)->finalize (object);
+}
+
+XfpmPower *
+xfpm_power_get (void)
+{
+    static gpointer xfpm_power_object = NULL;
+    
+    if ( G_LIKELY (xfpm_power_object != NULL ) )
+    {
+	g_object_ref (xfpm_power_object);
+    }
+    else
+    {
+	xfpm_power_object = g_object_new (XFPM_TYPE_DKP, NULL);
+	g_object_add_weak_pointer (xfpm_power_object, &xfpm_power_object);
+    }
+    
+    return XFPM_POWER (xfpm_power_object);
+}
+
+void xfpm_power_suspend (XfpmPower *power, gboolean force)
+{
+    xfpm_power_sleep (power, "Suspend", force);
+}
+
+void xfpm_power_hibernate (XfpmPower *power, gboolean force)
+{
+    xfpm_power_sleep (power, "Hibernate", force);
+}
+
+gboolean xfpm_power_has_battery (XfpmPower *power)
+{
+    GtkStatusIcon *battery = NULL;
+    guint i, len;
+    GList *list;
+    
+    gboolean ret = FALSE;
+    
+    list = g_hash_table_get_values (power->priv->hash);
+    len = g_list_length (list);
+    
+    for ( i = 0; i < len; i++)
+    {
+	XfpmDeviceType type;
+	battery = g_list_nth_data (list, i);
+	type = xfpm_battery_get_device_type (XFPM_BATTERY (battery));
+	if ( type == XFPM_DEVICE_TYPE_BATTERY ||
+	     type == XFPM_DEVICE_TYPE_UPS )
+	{
+	    ret = TRUE;
+	    break;
+	}
+    }
+    
+    return ret;
+}
+
+/*
+ * 
+ * DBus server implementation for org.freedesktop.PowerManagement
+ * 
+ */
+static gboolean xfpm_power_dbus_shutdown (XfpmPower *power,
+				        GError **error);
+
+static gboolean xfpm_power_dbus_reboot   (XfpmPower *power,
+					GError **error);
+					   
+static gboolean xfpm_power_dbus_hibernate (XfpmPower * power,
+					 GError **error);
+
+static gboolean xfpm_power_dbus_suspend (XfpmPower * power,
+				       GError ** error);
+
+static gboolean xfpm_power_dbus_can_reboot (XfpmPower * power,
+					  gboolean * OUT_can_reboot, 
+					  GError ** error);
+
+static gboolean xfpm_power_dbus_can_shutdown (XfpmPower * power,
+					    gboolean * OUT_can_reboot, 
+					    GError ** error);
+
+static gboolean xfpm_power_dbus_can_hibernate (XfpmPower * power,
+					     gboolean * OUT_can_hibernate,
+					     GError ** error);
+
+static gboolean xfpm_power_dbus_can_suspend (XfpmPower * power,
+					   gboolean * OUT_can_suspend,
+					   GError ** error);
+
+static gboolean xfpm_power_dbus_get_power_save_status (XfpmPower * power,
+						     gboolean * OUT_save_power,
+						     GError ** error);
+
+static gboolean xfpm_power_dbus_get_on_battery (XfpmPower * power,
+					      gboolean * OUT_on_battery,
+					      GError ** error);
+
+static gboolean xfpm_power_dbus_get_low_battery (XfpmPower * power,
+					       gboolean * OUT_low_battery,
+					       GError ** error);
+
+#include "org.freedesktop.PowerManagement.h"
+
+static void
+xfpm_power_dbus_class_init (XfpmPowerClass * klass)
+{
+    dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass),
+                                     &dbus_glib_xfpm_power_object_info);
+}
+
+static void
+xfpm_power_dbus_init (XfpmPower *power)
+{
+    DBusGConnection *bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+
+    dbus_g_connection_register_g_object (bus,
+                                         "/org/freedesktop/PowerManagement",
+                                         G_OBJECT (power));
+}
+
+static gboolean xfpm_power_dbus_shutdown (XfpmPower *power,
+				        GError **error)
+{
+    gboolean can_reboot;
+    
+    g_object_get (G_OBJECT (power->priv->console),
+		  "can-shutdown", &can_reboot,
+		  NULL);
+    
+    if ( !can_reboot)
+    {
+	g_set_error (error, XFPM_ERROR, XFPM_ERROR_PERMISSION_DENIED,
+                    _("Permission denied"));
+        return FALSE;
+    }
+    
+    xfpm_console_kit_shutdown (power->priv->console, error);
+    
+    return TRUE;
+}
+
+static gboolean xfpm_power_dbus_reboot   (XfpmPower *power,
+					GError **error)
+{
+    gboolean can_reboot;
+    
+    g_object_get (G_OBJECT (power->priv->console),
+		  "can-restart", &can_reboot,
+		  NULL);
+    
+    if ( !can_reboot)
+    {
+	g_set_error (error, XFPM_ERROR, XFPM_ERROR_PERMISSION_DENIED,
+                    _("Permission denied"));
+        return FALSE;
+    }
+    
+    xfpm_console_kit_reboot (power->priv->console, error);
+    
+    return TRUE;
+}
+					   
+static gboolean xfpm_power_dbus_hibernate (XfpmPower * power,
+					 GError **error)
+{
+    if ( !power->priv->auth_suspend )
+    {
+	g_set_error (error, XFPM_ERROR, XFPM_ERROR_PERMISSION_DENIED,
+                    _("Permission denied"));
+        return FALSE;
+	
+    }
+    
+    if (!power->priv->can_hibernate )
+    {
+	g_set_error (error, XFPM_ERROR, XFPM_ERROR_NO_HARDWARE_SUPPORT,
+                    _("Suspend not supported"));
+        return FALSE;
+    }
+    
+    xfpm_power_sleep (power, "Hibernate", FALSE);
+    
+    return TRUE;
+}
+
+static gboolean xfpm_power_dbus_suspend (XfpmPower * power,
+				       GError ** error)
+{
+    if ( !power->priv->auth_suspend )
+    {
+	g_set_error (error, XFPM_ERROR, XFPM_ERROR_PERMISSION_DENIED,
+                    _("Permission denied"));
+        return FALSE;
+	
+    }
+    
+    if (!power->priv->can_suspend )
+    {
+	g_set_error (error, XFPM_ERROR, XFPM_ERROR_NO_HARDWARE_SUPPORT,
+                    _("Suspend not supported"));
+        return FALSE;
+    }
+    
+    xfpm_power_sleep (power, "Suspend", FALSE);
+    
+    return TRUE;
+}
+
+static gboolean xfpm_power_dbus_can_reboot (XfpmPower * power,
+					  gboolean * OUT_can_reboot, 
+					  GError ** error)
+{
+    g_object_get (G_OBJECT (power->priv->console),
+		  "can-reboot", OUT_can_reboot,
+		  NULL);
+		  
+    return TRUE;
+}
+
+static gboolean xfpm_power_dbus_can_shutdown (XfpmPower * power,
+					    gboolean * OUT_can_shutdown, 
+					    GError ** error)
+{
+    g_object_get (G_OBJECT (power->priv->console),
+		  "can-shutdown", OUT_can_shutdown,
+		  NULL);
+    return TRUE;
+}
+
+static gboolean xfpm_power_dbus_can_hibernate (XfpmPower * power,
+					     gboolean * OUT_can_hibernate,
+					     GError ** error)
+{
+    *OUT_can_hibernate = power->priv->can_hibernate;
+    return TRUE;
+}
+
+static gboolean xfpm_power_dbus_can_suspend (XfpmPower * power,
+					   gboolean * OUT_can_suspend,
+					   GError ** error)
+{
+    *OUT_can_suspend = power->priv->can_suspend;
+    
+    return TRUE;
+}
+
+static gboolean xfpm_power_dbus_get_power_save_status (XfpmPower * power,
+						     gboolean * OUT_save_power,
+						     GError ** error)
+{
+    //FIXME
+    return TRUE;
+}
+
+static gboolean xfpm_power_dbus_get_on_battery (XfpmPower * power,
+					      gboolean * OUT_on_battery,
+					      GError ** error)
+{
+    *OUT_on_battery = power->priv->on_battery;
+    
+    return TRUE;
+}
+
+static gboolean xfpm_power_dbus_get_low_battery (XfpmPower * power,
+					       gboolean * OUT_low_battery,
+					       GError ** error)
+{
+    *OUT_low_battery = power->priv->on_low_battery;
+    
+    return TRUE;
+}
diff --git a/src/xfpm-power.h b/src/xfpm-power.h
new file mode 100644
index 0000000..c927354
--- /dev/null
+++ b/src/xfpm-power.h
@@ -0,0 +1,79 @@
+/*
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __XFPM_POWER_H
+#define __XFPM_POWER_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define XFPM_TYPE_DKP        (xfpm_power_get_type () )
+#define XFPM_POWER(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_DKP, XfpmPower))
+#define XFPM_IS_DKP(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_DKP))
+
+typedef struct XfpmPowerPrivate XfpmPowerPrivate;
+
+typedef struct
+{
+    GObject         	parent;
+    
+    XfpmPowerPrivate     *priv;
+    
+} XfpmPower;
+
+typedef struct
+{
+    GObjectClass 	parent_class;
+    
+    void                (*on_battery_changed)         	(XfpmPower *power,
+						         gboolean on_battery);
+    
+    void                (*low_battery_changed)        	(XfpmPower *power,
+							 gboolean low_battery);
+    
+    void		(*lid_changed)			(XfpmPower *power,
+							 gboolean lid_is_closed);
+							
+    void		(*waking_up)			(XfpmPower *power);
+    
+    void		(*sleeping)			(XfpmPower *power);
+    
+    void		(*ask_shutdown)			(XfpmPower *power);
+    
+    void		(*shutdown)			(XfpmPower *power);
+    
+} XfpmPowerClass;
+
+GType        		xfpm_power_get_type        	(void) G_GNUC_CONST;
+
+XfpmPower       	       *xfpm_power_get             	(void);
+
+void			xfpm_power_suspend         	(XfpmPower *power,
+							 gboolean force);
+
+void			xfpm_power_hibernate       	(XfpmPower *power,
+							 gboolean force);
+
+gboolean		xfpm_power_has_battery		(XfpmPower *power);
+
+G_END_DECLS
+
+#endif /* __XFPM_POWER_H */
diff --git a/src/xfpm-screen-saver.c b/src/xfpm-screen-saver.c
deleted file mode 100644
index 983e9d9..0000000
--- a/src/xfpm-screen-saver.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * * Copyright (C) 2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <glib.h>
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include <libxfce4util/libxfce4util.h>
-
-#include "libxfpm/xfpm-dbus.h"
-
-#include "xfpm-screen-saver.h"
-#include "xfpm-inhibit.h"
-#include "xfpm-dbus-monitor.h"
-
-static void xfpm_screen_saver_finalize   (GObject *object);
-
-#define XFPM_SCREEN_SAVER_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_SCREEN_SAVER, XfpmScreenSaverPrivate))
-
-struct XfpmScreenSaverPrivate
-{
-    DBusGConnection *bus;
-    XfpmInhibit     *inhibit;
-    
-    gboolean         inhibited;
-};
-
-enum
-{
-    SCREEN_SAVER_INHIBITED,
-    LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(XfpmScreenSaver, xfpm_screen_saver, G_TYPE_OBJECT)
-
-static void
-xfpm_screen_saver_inhibit_changed_cb (XfpmInhibit *inhbit, gboolean inhibited, XfpmScreenSaver *srv)
-{
-    g_signal_emit (G_OBJECT (srv), signals [SCREEN_SAVER_INHIBITED], 0, inhibited);
-}
-
-static void
-xfpm_screen_saver_class_init(XfpmScreenSaverClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-     signals[SCREEN_SAVER_INHIBITED] =
-	    g_signal_new("screen-saver-inhibited",
-			 XFPM_TYPE_SCREEN_SAVER,
-			 G_SIGNAL_RUN_LAST,
-			 G_STRUCT_OFFSET(XfpmScreenSaverClass, screen_saver_inhibited),
-			 NULL, NULL,
-			 g_cclosure_marshal_VOID__BOOLEAN,
-			 G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
-
-    object_class->finalize = xfpm_screen_saver_finalize;
-    
-    g_type_class_add_private(klass,sizeof(XfpmScreenSaverPrivate));
-}
-
-static void
-xfpm_screen_saver_init(XfpmScreenSaver *srv)
-{
-    srv->priv = XFPM_SCREEN_SAVER_GET_PRIVATE(srv);
-    
-    srv->priv->inhibit = xfpm_inhibit_new ();
-    g_signal_connect (srv->priv->inhibit, "has-inhibit-changed",
-		      G_CALLBACK (xfpm_screen_saver_inhibit_changed_cb), srv);
-}
-
-static void
-xfpm_screen_saver_finalize(GObject *object)
-{
-    XfpmScreenSaver *srv;
-
-    srv = XFPM_SCREEN_SAVER(object);
-    
-    g_object_unref (srv->priv->inhibit);
-    
-    G_OBJECT_CLASS(xfpm_screen_saver_parent_class)->finalize(object);
-}
-
-XfpmScreenSaver *
-xfpm_screen_saver_new(void)
-{
-    static gpointer xfpm_screen_saver_object = NULL;
-    
-    if ( G_LIKELY (xfpm_screen_saver_object != NULL) )
-    {
-	g_object_ref (xfpm_screen_saver_object);
-    }
-    else
-    {
-	xfpm_screen_saver_object = g_object_new (XFPM_TYPE_SCREEN_SAVER, NULL);
-	g_object_add_weak_pointer (xfpm_screen_saver_object, &xfpm_screen_saver_object);
-    }
-    return XFPM_SCREEN_SAVER (xfpm_screen_saver_object);
-}
-
-void xfpm_screen_saver_inhibit (XfpmScreenSaver *srv)
-{
-    g_return_if_fail (XFPM_IS_SCREEN_SAVER (srv));
-    
-    if ( srv->priv->inhibited == FALSE )
-    {
-	srv->priv->inhibited = TRUE;
-	g_signal_emit (G_OBJECT (srv), signals[SCREEN_SAVER_INHIBITED], 0, srv->priv->inhibited);
-    }
-}
-
-void xfpm_screen_saver_uninhibit (XfpmScreenSaver *srv)
-{
-    g_return_if_fail (XFPM_IS_SCREEN_SAVER (srv));
-    
-    if ( srv->priv->inhibited == TRUE )
-    {
-	srv->priv->inhibited = FALSE;
-	g_signal_emit (G_OBJECT (srv), signals[SCREEN_SAVER_INHIBITED], 0, srv->priv->inhibited);
-    }
-}
-
-gboolean xfpm_screen_saver_get_inhibit (XfpmScreenSaver *srv)
-{
-    g_return_val_if_fail (XFPM_IS_SCREEN_SAVER (srv), FALSE);
-    
-    return srv->priv->inhibited;
-}
diff --git a/src/xfpm-screen-saver.h b/src/xfpm-screen-saver.h
deleted file mode 100644
index 021f228..0000000
--- a/src/xfpm-screen-saver.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * * Copyright (C) 2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __XFPM_SCREEN_SAVER_H
-#define __XFPM_SCREEN_SAVER_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_SCREEN_SAVER        (xfpm_screen_saver_get_type () )
-#define XFPM_SCREEN_SAVER(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_SCREEN_SAVER, XfpmScreenSaver))
-#define XFPM_IS_SCREEN_SAVER(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_SCREEN_SAVER))
-
-typedef struct XfpmScreenSaverPrivate XfpmScreenSaverPrivate;
-
-typedef struct
-{
-    GObject		 	  parent;
-    XfpmScreenSaverPrivate	 *priv;
-	
-} XfpmScreenSaver;
-
-typedef struct
-{
-    GObjectClass 		  parent_class;
-    
-    void                          (*screen_saver_inhibited)	    (XfpmScreenSaver *srv,
-								     gboolean is_inhibited);
-	
-} XfpmScreenSaverClass;
-
-GType        			  xfpm_screen_saver_get_type        (void) G_GNUC_CONST;
-
-XfpmScreenSaver       	 	 *xfpm_screen_saver_new             (void);
-
-void				  xfpm_screen_saver_inhibit         (XfpmScreenSaver *srv);
-
-void 				  xfpm_screen_saver_uninhibit       (XfpmScreenSaver *srv);
-
-gboolean                          xfpm_screen_saver_get_inhibit     (XfpmScreenSaver *srv);
-
-G_END_DECLS
-
-#endif /* __XFPM_SCREEN_SAVER_H */
diff --git a/src/xfpm-session.c b/src/xfpm-session.c
deleted file mode 100644
index 1daed15..0000000
--- a/src/xfpm-session.c
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * * Copyright (C) 2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <glib.h>
-#include <gtk/gtk.h>
-
-#include <dbus/dbus-glib.h>
-
-#include <libxfce4util/libxfce4util.h>
-#include <libxfcegui4/libxfcegui4.h>
-
-#include "xfpm-session.h"
-
-static void xfpm_session_finalize   (GObject *object);
-
-#define XFPM_SESSION_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_SESSION, XfpmSessionPrivate))
-
-/* copied from xfce4-session/shutdown.h -- ORDER MATTERS.  The numbers
- * correspond to the 'type' parameter of org.xfce.Session.Manager.Shutdown
- */
-typedef enum
-{
-    XFSM_SHUTDOWN_ASK = 0,
-    XFSM_SHUTDOWN_LOGOUT,
-    XFSM_SHUTDOWN_HALT,
-    XFSM_SHUTDOWN_REBOOT,
-    XFSM_SHUTDOWN_SUSPEND,
-    XFSM_SHUTDOWN_HIBERNATE,
-  
-} XfsmShutdownType;
-
-struct XfpmSessionPrivate
-{
-    SessionClient *client;
-    gboolean       managed;
-    gboolean	   initted;
-};
-
-enum
-{
-    SESSION_DIE,
-    LAST_SIGNAL
-};
-
-static guint signals [LAST_SIGNAL] = { 0 };
-
-static gpointer xfpm_session_object = NULL;
-
-G_DEFINE_TYPE (XfpmSession, xfpm_session, G_TYPE_OBJECT)
-
-static void
-xfpm_session_die (gpointer client_data)
-{
-    XfpmSession *session;
-    
-    if ( G_UNLIKELY (xfpm_session_object == NULL ) )
-	return;
-	
-    session = XFPM_SESSION (xfpm_session_object);
-    if ( G_UNLIKELY (session->priv->managed == FALSE) )
-	return;
-	
-    TRACE ("Session disconnected signal\n");
-    g_signal_emit (G_OBJECT (session), signals [SESSION_DIE], 0);
-}
-
-static void
-xfpm_session_class_init (XfpmSessionClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-    signals[SESSION_DIE] = 
-        g_signal_new("session-die",
-                      XFPM_TYPE_SESSION,
-                      G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET(XfpmSessionClass, session_die),
-                      NULL, NULL,
-                      g_cclosure_marshal_VOID__VOID,
-                      G_TYPE_NONE, 0, G_TYPE_NONE);
-
-    object_class->finalize = xfpm_session_finalize;
-
-    g_type_class_add_private (klass, sizeof (XfpmSessionPrivate));
-}
-
-static void
-xfpm_session_init (XfpmSession *session)
-{
-    gchar **restart_command;
-    
-    session->priv = XFPM_SESSION_GET_PRIVATE (session);
-    
-    session->priv->client = NULL;
-    session->priv->managed = FALSE;
-    session->priv->initted = FALSE;
-    
-    restart_command    = g_new (gchar *, 3);
-    restart_command[0] = g_strdup ("xfce4-power-manager");
-    restart_command[1] = g_strdup ("--restart");
-    restart_command[2] = NULL;
-    
-    session->priv->client = client_session_new_full (NULL,
-						     SESSION_RESTART_IF_RUNNING,
-						     40,
-						     NULL,
-						     (gchar *) PACKAGE_NAME,
-						     NULL,
-						     restart_command,
-						     g_strdupv (restart_command),
-						     NULL,
-						     NULL,
-						     NULL);
-    if ( G_UNLIKELY (session->priv->client == NULL ) )
-    {
-	g_warning ("Failed to connect to session manager");
-	return;
-    }
-    
-    session->priv->client->die     = xfpm_session_die;
-}
-
-static void
-xfpm_session_finalize (GObject *object)
-{
-    XfpmSession *session;
-
-    session = XFPM_SESSION (object);
-
-    if ( session->priv->client != NULL )
-    {
-	client_session_free (session->priv->client);
-    }
-
-    G_OBJECT_CLASS (xfpm_session_parent_class)->finalize (object);
-}
-
-static gboolean 
-xfpm_session_shutdown_internal (XfpmSession *session, XfsmShutdownType type, gboolean allow_save)
-{
-    DBusGConnection *bus;
-    DBusGProxy *proxy;
-    GError *error = NULL;
-    
-    bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
-    
-    if ( error )
-    {
-	g_print ("Unable to get DBUS session connection, %s", error->message);
-	g_error_free (error);
-	return FALSE;
-    }
-    
-    proxy = dbus_g_proxy_new_for_name (bus,
-				       "org.xfce.SessionManager",
-                                       "/org/xfce/SessionManager",
-                                       "org.xfce.Session.Manager");
-				       
-    if ( !proxy )
-    {
-	g_critical ("Unable to create proxy for xfce session manager");
-	dbus_g_connection_unref (bus);
-	return FALSE;
-    }
-	
-    dbus_g_proxy_call (proxy, "Shutdown", &error,
-		       G_TYPE_UINT, type,
-		       G_TYPE_BOOLEAN, allow_save,
-		       G_TYPE_INVALID,
-		       G_TYPE_INVALID);
-		       
-    if ( error )
-    {
-	g_warning ("%s", error->message);
-	g_error_free (error);
-    }
-    
-    g_object_unref (proxy);
-    dbus_g_connection_unref (bus);
-    return TRUE;
-}
-
-XfpmSession *
-xfpm_session_new (void)
-{
-    if ( xfpm_session_object != NULL )
-    {
-	g_object_ref (xfpm_session_object);
-    }
-    else
-    {
-	xfpm_session_object = g_object_new (XFPM_TYPE_SESSION, NULL);
-	g_object_add_weak_pointer (xfpm_session_object, &xfpm_session_object);
-    }
-    return XFPM_SESSION (xfpm_session_object);
-}
-
-void xfpm_session_real_init (XfpmSession *session)
-{
-    session->priv->managed = session_init (session->priv->client);
-    session->priv->initted = TRUE;
-}
-
-void xfpm_session_set_client_id (XfpmSession *session, const gchar *client_id)
-{
-    g_return_if_fail (XFPM_IS_SESSION (session));
-    g_return_if_fail (session->priv->initted == FALSE);
-    
-    if ( G_UNLIKELY (session->priv->client == NULL || session->priv->managed == FALSE) )
-	return;
-    
-    TRACE ("Setting client id : %s\n", client_id);
-    client_session_set_client_id (session->priv->client, client_id);
-}
-
-void xfpm_session_quit (XfpmSession *session)
-{
-    g_return_if_fail (XFPM_IS_SESSION (session));
-    
-    if ( G_UNLIKELY (session->priv->client == NULL || session->priv->managed == FALSE) )
-	return;
-    
-    client_session_set_restart_style (session->priv->client, SESSION_RESTART_NEVER);
-}
-
-gboolean xfpm_session_shutdown (XfpmSession *session)
-{
-    gboolean allow_save   = TRUE;
-    XfsmShutdownType type = XFSM_SHUTDOWN_HALT;
-    
-    g_return_val_if_fail (XFPM_IS_SESSION (session), FALSE);
-    
-    return xfpm_session_shutdown_internal (session, type, allow_save);
-}
-
-gboolean xfpm_session_reboot (XfpmSession *session)
-{
-    gboolean allow_save   = TRUE;
-    XfsmShutdownType type = XFSM_SHUTDOWN_REBOOT;
-    
-    g_return_val_if_fail (XFPM_IS_SESSION (session), FALSE);
-    
-    return xfpm_session_shutdown_internal (session, type, allow_save);
-}
-
-gboolean xfpm_session_ask_shutdown (XfpmSession *session)
-{
-    gboolean allow_save   = TRUE;
-    XfsmShutdownType type = XFSM_SHUTDOWN_ASK;
-    
-    g_return_val_if_fail (XFPM_IS_SESSION (session), FALSE);
-    
-    return xfpm_session_shutdown_internal (session, type, allow_save);
-}
diff --git a/src/xfpm-session.h b/src/xfpm-session.h
deleted file mode 100644
index e40b13a..0000000
--- a/src/xfpm-session.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * * Copyright (C) 2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __XFPM_SESSION_H
-#define __XFPM_SESSION_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_SESSION        (xfpm_session_get_type () )
-#define XFPM_SESSION(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_SESSION, XfpmSession))
-#define XFPM_IS_SESSION(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_SESSION))
-
-typedef struct XfpmSessionPrivate XfpmSessionPrivate;
-
-typedef struct
-{
-    GObject         		 parent;
-    XfpmSessionPrivate     	*priv;
-    
-} XfpmSession;
-
-typedef struct
-{
-    GObjectClass 		 parent_class;
-    
-    void                        (*session_die)		      (XfpmSession *session);
-    
-} XfpmSessionClass;
-
-GType  		      		 xfpm_session_get_type        (void) G_GNUC_CONST;
-
-XfpmSession       		*xfpm_session_new             (void);
-
-void				 xfpm_session_real_init	      (XfpmSession *session);
-
-void			         xfpm_session_set_client_id   (XfpmSession *session,
-							       const gchar *client_id);
-							    
-/* This is used to change the restart Style */
-void				 xfpm_session_quit	      (XfpmSession *session);
-
-gboolean                         xfpm_session_shutdown        (XfpmSession *session);
-
-gboolean 			 xfpm_session_reboot 	      (XfpmSession *session);
-
-gboolean			 xfpm_session_ask_shutdown    (XfpmSession *session);
-
-G_END_DECLS
-
-#endif /* __XFPM_SESSION_H */
diff --git a/src/xfpm-shutdown.c b/src/xfpm-shutdown.c
deleted file mode 100644
index 5479543..0000000
--- a/src/xfpm-shutdown.c
+++ /dev/null
@@ -1,532 +0,0 @@
-/*
- * * Copyright (C) 2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include <libxfce4util/libxfce4util.h>
-
-#include <glib.h>
-
-#include "libxfpm/hal-device.h"
-
-#include "libxfpm/xfpm-string.h"
-#include "libxfpm/xfpm-common.h"
-
-#include "xfpm-shutdown.h"
-#include "xfpm-session.h"
-#include "xfpm-network-manager.h"
-#include "xfpm-dbus-monitor.h"
-#include "xfpm-errors.h"
-
-#define DUPLICATE_SHUTDOWN_REQUEST 8.0f
-
-static void xfpm_shutdown_finalize   (GObject *object);
-
-static void xfpm_shutdown_get_property (GObject *object,
-				        guint prop_id,
-				        GValue *value,
-				        GParamSpec *pspec);
-
-#define XFPM_SHUTDOWN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_SHUTDOWN, XfpmShutdownPrivate))
-
-struct XfpmShutdownPrivate
-{
-    DBusGConnection *bus;
-    XfpmDBusMonitor *monitor;
-
-    XfpmSession     *session;
-    gboolean         connected;
-    gboolean         can_suspend;
-    gboolean         can_hibernate;
-    gboolean         caller_privilege;
-    
-    gboolean         block_shutdown;
-};
-
-enum
-{
-    PROP_0,
-    PROP_CALLER_PRIVILEGE,
-    PROP_CAN_SUSPEND,
-    PROP_CAN_HIBERNATE,
-};
-
-enum
-{
-    WAKING_UP,
-    LAST_SIGNAL
-};
-
-static guint signals [LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(XfpmShutdown, xfpm_shutdown, G_TYPE_OBJECT)
-
-static gboolean
-xfpm_shutdown_check_interface (XfpmShutdown *shutdown, const gchar *interface)
-{
-    DBusMessage *message;
-    DBusMessage *reply;
-    DBusError error ;
-    
-    message = dbus_message_new_method_call ("org.freedesktop.Hal",
-					    "/org/freedesktop/Hal",
-					    interface,
-					    "JustToCheck");
-    
-    if (!message)
-    	return FALSE;
-    
-    dbus_error_init (&error);
-    
-    reply = 
-    	dbus_connection_send_with_reply_and_block (dbus_g_connection_get_connection(shutdown->priv->bus),
-						   message, 2000, &error);
-    dbus_message_unref (message);
-    
-    if ( reply ) dbus_message_unref (reply);
-    
-    if ( dbus_error_is_set(&error) )
-    {
-	if ( !g_strcmp0 (error.name, "org.freedesktop.DBus.Error.UnknownMethod") )
-        {
-            dbus_error_free(&error);
-	    return TRUE;
-        }
-    }
-    return FALSE;
-}
-
-static void
-xfpm_shutdown_power_management_check (XfpmShutdown *shutdown)
-{
-    HalDevice *device;
-    device = hal_device_new ();
-    hal_device_set_udi (device,  "/org/freedesktop/Hal/devices/computer");
-    
-    shutdown->priv->caller_privilege =
-	xfpm_shutdown_check_interface (shutdown,  "org.freedesktop.Hal.Device.SystemPowerManagement");
-    
-    shutdown->priv->can_suspend   = hal_device_get_property_bool (device, "power_management.can_suspend");
-    shutdown->priv->can_hibernate = hal_device_get_property_bool (device, "power_management.can_hibernate");
-    g_object_unref (device);
-}
-
-static void
-xfpm_shutdown_connection_changed_cb (XfpmDBusMonitor *monitor, gboolean connected, XfpmShutdown *shutdown)
-{
-    TRACE ("Hal connection changed=%s", xfpm_bool_to_string (connected));
-    shutdown->priv->connected = connected;
-}
-
-static void
-xfpm_shutdown_class_init(XfpmShutdownClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-    signals[WAKING_UP] = 
-        g_signal_new("waking-up",
-                      XFPM_TYPE_SHUTDOWN,
-                      G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET(XfpmShutdownClass, waking_up),
-                      NULL, NULL,
-                      g_cclosure_marshal_VOID__VOID,
-                      G_TYPE_NONE, 0, G_TYPE_NONE);
-
-    object_class->get_property = xfpm_shutdown_get_property;
-    g_object_class_install_property(object_class,
-				    PROP_CALLER_PRIVILEGE,
-				    g_param_spec_boolean("caller-privilege",
-							 NULL, NULL,
-							 FALSE,
-							 G_PARAM_READABLE));
-							 
-    g_object_class_install_property(object_class,
-				    PROP_CAN_SUSPEND,
-				    g_param_spec_boolean("can-suspend",
-							 NULL, NULL,
-							 FALSE,
-							 G_PARAM_READABLE));
-							 
-    g_object_class_install_property(object_class,
-				    PROP_CAN_HIBERNATE,
-				    g_param_spec_boolean("can-hibernate",
-							 NULL, NULL,
-							 FALSE,
-							 G_PARAM_READABLE));
-							 
-    object_class->finalize = xfpm_shutdown_finalize;
-    g_type_class_add_private(klass,sizeof(XfpmShutdownPrivate));
-}
-
-static void
-xfpm_shutdown_init (XfpmShutdown *shutdown)
-{
-    GError *error = NULL;
-    shutdown->priv = XFPM_SHUTDOWN_GET_PRIVATE(shutdown);
-    
-    shutdown->priv->bus 			= NULL;
-    shutdown->priv->connected			= FALSE;
-    shutdown->priv->can_suspend    		= FALSE;
-    shutdown->priv->can_hibernate  		= FALSE;
-    shutdown->priv->caller_privilege        	= FALSE;
-    
-    shutdown->priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
-    
-    shutdown->priv->session = xfpm_session_new ();
-    
-    if ( error )
-    {
-	g_critical ("Unable to get system bus %s.", error->message);
-	g_error_free (error);
-	return;
-    }
-    
-    shutdown->priv->monitor = xfpm_dbus_monitor_new ();
-    
-    g_signal_connect (shutdown->priv->monitor, "hal-connection-changed",
-		      G_CALLBACK (xfpm_shutdown_connection_changed_cb), shutdown);
-		      
-    shutdown->priv->connected = xfpm_dbus_monitor_hal_connected (shutdown->priv->monitor);
-    
-    xfpm_shutdown_power_management_check (shutdown);
-}
-
-static void xfpm_shutdown_get_property (GObject *object,
-				        guint prop_id,
-				        GValue *value,
-				        GParamSpec *pspec)
-{
-    XfpmShutdown *shutdown;
-    shutdown = XFPM_SHUTDOWN (object);
-
-    switch(prop_id)
-    {
-	case PROP_CALLER_PRIVILEGE:
-	    g_value_set_boolean (value, shutdown->priv->caller_privilege );
-	    break;
-	case PROP_CAN_SUSPEND:
-	    g_value_set_boolean (value, shutdown->priv->can_suspend );
-	    break;
-	case PROP_CAN_HIBERNATE:
-	    g_value_set_boolean (value, shutdown->priv->can_hibernate);
-	    break;
-	default:
-	    G_OBJECT_WARN_INVALID_PROPERTY_ID(object,prop_id,pspec);
-	    break;
-    }
-}
-
-static void
-xfpm_shutdown_finalize(GObject *object)
-{
-    XfpmShutdown *shutdown;
-
-    shutdown = XFPM_SHUTDOWN(object);
-    
-    if ( shutdown->priv->bus )
-	dbus_g_connection_unref (shutdown->priv->bus);	
-
-    g_object_unref (shutdown->priv->monitor);
-	
-    g_object_unref (shutdown->priv->session);
-	
-    G_OBJECT_CLASS(xfpm_shutdown_parent_class)->finalize(object);
-}
-
-static gboolean 
-xfpm_shutdown_internal (DBusConnection *bus, const gchar *shutdown, GError **gerror)
-{
-    DBusMessage *message, *reply = NULL;
-    DBusError error;
-    gint exit_code = 0;
-    
-    message = dbus_message_new_method_call ("org.freedesktop.Hal",
-					    "/org/freedesktop/Hal/devices/computer",
-					    "org.freedesktop.Hal.Device.SystemPowerManagement",
-					    shutdown);
-    if ( !message )
-    {
-	g_set_error ( gerror, 0, 0, "Out of memory");
-	return FALSE;
-    }
-    
-    if ( !g_strcmp0 ("Suspend", shutdown ) )
-    {
-	gint seconds = 0;
-    	dbus_message_append_args (message, DBUS_TYPE_INT32, &seconds, DBUS_TYPE_INVALID);
-    }
-    
-    dbus_error_init (&error);
-    
-    reply = dbus_connection_send_with_reply_and_block (bus,
-						       message,
-						       -1,
-						       &error);
-    dbus_message_unref (message);
-
-    if ( dbus_error_is_set(&error) )
-    {
-	dbus_set_g_error (gerror, &error);
-	return FALSE;
-    }
-    
-    switch (dbus_message_get_type(reply) )
-    {
-	case DBUS_MESSAGE_TYPE_METHOD_RETURN:
-		dbus_message_get_args (reply, NULL,
-				       DBUS_TYPE_INT32,
-				       &exit_code,
-				       DBUS_TYPE_INVALID);
-		dbus_message_unref (reply);
-		if ( exit_code == 0) return TRUE;
-		else
-		{
-		    g_warning ("Sleep program exited with exit code %d", exit_code);
-		    g_set_error (gerror, 0, 0, "System failed to sleep");
-		    return FALSE;
-		}
-		break;
-	case DBUS_MESSAGE_TYPE_ERROR:
-		dbus_message_unref (reply);
-		g_set_error ( gerror, 0, 0, "Failed to sleep");
-		return FALSE;
-		break;
-	default:
-		dbus_message_unref ( reply );
-		g_set_error ( gerror, 0, 0, "Failed to sleep");
-		return FALSE;
-    }
-    return TRUE;
-}
-
-static const gchar * G_GNUC_PURE
-_filter_error_message(const gchar *error)
-{
-    if( xfpm_strequal ("No back-end for your operating system", error))
-    {
-        return _("No back-end for your operating system");
-    }
-    else if ( xfpm_strequal ("No hibernate script found", error) )
-    {
-        return _("No hibernate script found");
-    }
-    else if ( xfpm_strequal ("No suspend script found", error) )
-    {
-	return _("No suspend script found");
-    }
-    else if ( xfpm_strequal ("No suspend method found", error) )
-    {
-        return _("No suspend method found");
-    }
-    else if ( xfpm_strequal ("No hibernate method found", error))
-    {
-        return _("No hibernate method found");
-    }
-    else if ( xfpm_strequal ("Out of memory", error) )
-    {
-	return _("Out of memory");
-    }
-    else if ( xfpm_strequal ("System failed to sleep", error ) )
-    {
-	return _("System failed to sleep");
-    }
-    return NULL;
-}
-
-XfpmShutdown *
-xfpm_shutdown_new(void)
-{
-    static gpointer xfpm_shutdown_object = NULL;
-    
-    if ( G_LIKELY (xfpm_shutdown_object != NULL) )
-    {
-	g_object_ref (xfpm_shutdown_object);
-    }
-    else
-    {
-	xfpm_shutdown_object = g_object_new (XFPM_TYPE_SHUTDOWN, NULL);
-	g_object_add_weak_pointer (xfpm_shutdown_object, &xfpm_shutdown_object);
-    }
-    return XFPM_SHUTDOWN (xfpm_shutdown_object);
-}
-
-gboolean                  xfpm_shutdown_add_callback    (XfpmShutdown *shutdown,
-							 GSourceFunc func,
-							 gboolean lock_screen,
-							 gpointer data)
-{
-    g_return_val_if_fail (XFPM_IS_SHUTDOWN (shutdown), FALSE);
-    
-    if (shutdown->priv->block_shutdown)
-	return FALSE;
-    
-    xfpm_send_message_to_network_manager ("sleep");
-    if ( lock_screen )
-	xfpm_lock_screen ();
-	
-    if ( lock_screen )
-	g_timeout_add_seconds (2 , func, data);
-    else
-	g_timeout_add (100, func, data);
-	
-    shutdown->priv->block_shutdown = TRUE;
-    return TRUE;
-}
-
-void xfpm_shutdown	(XfpmShutdown *shutdown, GError **error)
-{
-    g_return_if_fail (XFPM_IS_SHUTDOWN(shutdown));
-    
-    TRACE ("Start");
-    
-    if ( G_UNLIKELY (shutdown->priv->connected == FALSE) )
-    {
-	g_set_error (error, XFPM_ERROR, XFPM_ERROR_HAL_DISCONNECTED, _("HAL daemon is currently not connected"));
-	shutdown->priv->block_shutdown = FALSE;
-	return;
-    }
-    
-    xfpm_send_message_to_network_manager ("sleep");
-    
-    if ( !xfpm_shutdown_internal (dbus_g_connection_get_connection(shutdown->priv->bus), "Shutdown", NULL))
-    {
-	xfpm_send_message_to_network_manager ("wake");
-	shutdown->priv->block_shutdown = FALSE;
-    }
-}
-
-void xfpm_reboot (XfpmShutdown *shutdown, GError **error)
-{
-    g_return_if_fail (XFPM_IS_SHUTDOWN(shutdown));
-    
-    TRACE ("Start");
-    
-    if ( G_UNLIKELY (shutdown->priv->connected == FALSE) )
-    {
-	g_set_error (error, XFPM_ERROR, XFPM_ERROR_HAL_DISCONNECTED, _("HAL daemon is currently not connected"));
-	shutdown->priv->block_shutdown = FALSE;
-	return;
-    }
-    
-    xfpm_send_message_to_network_manager ("sleep");
-    if ( !xfpm_shutdown_internal (dbus_g_connection_get_connection(shutdown->priv->bus), "Reboot", NULL))
-    {
-	xfpm_send_message_to_network_manager ("wake");
-	shutdown->priv->block_shutdown = FALSE;
-    }
-}    
-
-void xfpm_hibernate (XfpmShutdown *shutdown, GError **error)
-{
-    GError *error_internal = NULL;
-    const gchar *error_message;
-    
-    g_return_if_fail (XFPM_IS_SHUTDOWN(shutdown));
-    
-    TRACE ("Start");
-    
-    if ( G_UNLIKELY (shutdown->priv->connected == FALSE) )
-    {
-	g_set_error (error, XFPM_ERROR, XFPM_ERROR_HAL_DISCONNECTED, _("HAL daemon is currently not connected"));
-	shutdown->priv->block_shutdown = FALSE;
-	return;
-    }
-
-    xfpm_send_message_to_network_manager ("sleep");
-
-    xfpm_shutdown_internal (dbus_g_connection_get_connection(shutdown->priv->bus), "Hibernate", &error_internal);
-    shutdown->priv->block_shutdown = FALSE;
-    
-    if ( error_internal )
-    {
-	g_warning ("%s", error_internal->message);
-	error_message = _filter_error_message (error_internal->message);
-	if ( error_message )
-	{
-	    g_set_error (error, XFPM_ERROR, XFPM_ERROR_SLEEP_FAILED, "%s", error_message);
-	}
-	g_error_free (error_internal);
-    }
-    g_signal_emit (G_OBJECT (shutdown), signals [WAKING_UP], 0);
-    
-    xfpm_send_message_to_network_manager ("wake");
-}
-
-void xfpm_suspend (XfpmShutdown *shutdown, GError **error)
-{
-    GError *error_internal = NULL;
-    const gchar *error_message;
-    
-    g_return_if_fail (XFPM_IS_SHUTDOWN(shutdown));
-    
-    TRACE ("Start");
-    
-    if ( G_UNLIKELY (shutdown->priv->connected == FALSE) )
-    {
-	g_set_error (error, XFPM_ERROR, XFPM_ERROR_HAL_DISCONNECTED, _("HAL daemon is currently not connected"));
-	shutdown->priv->block_shutdown = FALSE;
-	return;
-    }
-    
-    xfpm_send_message_to_network_manager ("sleep");
-    xfpm_shutdown_internal (dbus_g_connection_get_connection(shutdown->priv->bus), "Suspend", &error_internal);
-    shutdown->priv->block_shutdown = FALSE;
-     
-    if ( error_internal )
-    {
-	g_warning ("%s", error_internal->message);
-	error_message = _filter_error_message (error_internal->message);
-	if ( error_message )
-	{
-	    g_set_error ( error, XFPM_ERROR, XFPM_ERROR_SLEEP_FAILED, "%s", error_message);
-	}
-	g_error_free (error_internal);
-    }
-    g_signal_emit (G_OBJECT (shutdown), signals [WAKING_UP], 0);
-    xfpm_send_message_to_network_manager ("wake");
-}
-
-void xfpm_shutdown_ask (XfpmShutdown *shutdown)
-{
-    g_return_if_fail (XFPM_IS_SHUTDOWN (shutdown));
-    
-    TRACE ("Start");
-    
-    xfpm_session_ask_shutdown (shutdown->priv->session);
-}
-
-void xfpm_shutdown_reload (XfpmShutdown *shutdown)
-{
-    g_return_if_fail (XFPM_IS_SHUTDOWN (shutdown));
-    
-    TRACE ("Start");
-    
-    xfpm_shutdown_power_management_check (shutdown);
-}
diff --git a/src/xfpm-shutdown.h b/src/xfpm-shutdown.h
deleted file mode 100644
index f230558..0000000
--- a/src/xfpm-shutdown.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * * Copyright (C) 2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __XFPM_SHUTDOWN_H
-#define __XFPM_SHUTDOWN_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_SHUTDOWN        (xfpm_shutdown_get_type () )
-#define XFPM_SHUTDOWN(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_SHUTDOWN, XfpmShutdown))
-#define XFPM_IS_SHUTDOWN(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_SHUTDOWN))
-
-typedef enum
-{
-    SYSTEM_CAN_HIBERNATE         =  (1<<0),
-    SYSTEM_CAN_SUSPEND           =  (1<<1),
-    
-} SystemPowerManagement;
-
-typedef struct XfpmShutdownPrivate XfpmShutdownPrivate;
-
-typedef struct
-{
-    GObject		  parent;
-    XfpmShutdownPrivate	 *priv;
-	
-} XfpmShutdown;
-
-typedef struct
-{
-    GObjectClass 	  parent_class;
-    
-    void		  (*waking_up)			(XfpmShutdown *shutdown);
-	
-} XfpmShutdownClass;
-
-GType        		  xfpm_shutdown_get_type        (void) G_GNUC_CONST;
-XfpmShutdown       	 *xfpm_shutdown_new             (void);
-
-gboolean                  xfpm_shutdown_add_callback    (XfpmShutdown *shutdown,
-							 GSourceFunc func,
-							 gboolean lock_screen,
-							 gpointer data);
-							 
-
-void                      xfpm_shutdown			(XfpmShutdown *shutdown,
-							 GError **error);
-
-void                      xfpm_reboot			(XfpmShutdown *shutdown,
-							 GError **error);
-
-void                      xfpm_hibernate                (XfpmShutdown *shutdown,
-							 GError **error);
-
-void                      xfpm_suspend                  (XfpmShutdown *shutdown,
-							 GError **error);
-
-void                      xfpm_shutdown_ask             (XfpmShutdown *shutdown);
-
-void			  xfpm_shutdown_reload          (XfpmShutdown *shutdown);
-
-G_END_DECLS
-
-#endif /* __XFPM_SHUTDOWN_H */
diff --git a/src/xfpm-supply.c b/src/xfpm-supply.c
deleted file mode 100644
index 01d855b..0000000
--- a/src/xfpm-supply.c
+++ /dev/null
@@ -1,637 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <libxfce4util/libxfce4util.h>
-#include <libxfcegui4/libxfcegui4.h>
-
-#include "libxfpm/hal-power.h"
-#include "libxfpm/xfpm-string.h"
-#include "libxfpm/xfpm-common.h"
-#include "libxfpm/xfpm-notify.h"
-#include "libxfpm/xfpm-icons.h"
-
-#include "xfpm-supply.h"
-#include "xfpm-adapter.h"
-#include "xfpm-battery.h"
-#include "xfpm-enum.h"
-#include "xfpm-enum-types.h"
-#include "xfpm-xfconf.h"
-#include "xfpm-tray-icon.h"
-#include "xfpm-config.h"
-#include "xfpm-shutdown.h"
-#include "xfpm-inhibit.h"
-#include "xfpm-debug.h"
-#include "xfpm-marshal.h"
-
-static void xfpm_supply_finalize   (GObject *object);
-static void xfpm_supply_refresh_tray_icon (XfpmSupply *supply);
-static void xfpm_supply_hide_adapter_icon (XfpmSupply *supply);
-
-#define XFPM_SUPPLY_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_SUPPLY, XfpmSupplyPrivate))
-
-struct XfpmSupplyPrivate
-{
-    XfpmNotify    *notify;
-    XfpmAdapter   *adapter;
-    XfpmXfconf    *conf;
-    XfpmTrayIcon  *tray;
-    XfpmInhibit   *inhibit;
-    
-    HalPower      *power;
-    GHashTable    *hash;
-    
-    gboolean       low_power;
-    gboolean       adapter_present;
-    gboolean       inhibited;
-    guint8         power_management;
-};
-
-enum
-{
-    PROP_O,
-    PROP_ON_BATTERY,
-    PROP_ON_LOW_BATTERY
-};    
-
-enum
-{
-    SHUTDOWN_REQUEST,
-    LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(XfpmSupply, xfpm_supply, G_TYPE_OBJECT)
-
-static void
-xfpm_supply_get_property (GObject *object,
-			  guint prop_id,
-			  GValue *value,
-			  GParamSpec *pspec)
-{
-    XfpmSupply *supply;
-    
-    supply = XFPM_SUPPLY (object);
-    
-    switch ( prop_id )
-    {
-	case PROP_ON_BATTERY:
-	    g_value_set_boolean (value, !supply->priv->adapter_present);
-	    break;
-	case PROP_ON_LOW_BATTERY:
-	    g_value_set_boolean (value, supply->priv->low_power);
-	    break;
-	default:
-	    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-	    break;
-    }
-    
-}
-
-static void
-xfpm_supply_has_inhibit_changed_cb (XfpmInhibit *inhibit, gboolean inhibited, XfpmSupply *supply)
-{
-    supply->priv->inhibited = inhibited;
-}
-
-static void 
-xfpm_supply_tray_settings_changed (GObject *obj, GParamSpec *spec, XfpmSupply *supply)
-{
-    xfpm_supply_refresh_tray_icon (supply);
-}
-
-static void
-xfpm_supply_class_init(XfpmSupplyClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-    object_class->get_property = xfpm_supply_get_property;
-
-    signals[SHUTDOWN_REQUEST] = 
-    	g_signal_new("shutdown-request",
-                      XFPM_TYPE_SUPPLY,
-                      G_SIGNAL_RUN_LAST,
-                      G_STRUCT_OFFSET(XfpmSupplyClass, shutdown_request),
-                      NULL, NULL,
-                      _xfpm_marshal_VOID__BOOLEAN_ENUM,
-                      G_TYPE_NONE, 2, 
-		      G_TYPE_BOOLEAN,
-		      XFPM_TYPE_SHUTDOWN_REQUEST);
-		      
-    g_object_class_install_property(object_class,
-                                    PROP_ON_BATTERY,
-                                    g_param_spec_boolean("on-battery",
-                                                         NULL, NULL,
-                                                         FALSE,
-                                                         G_PARAM_READABLE));
-							 
-    g_object_class_install_property(object_class,
-                                    PROP_ON_LOW_BATTERY,
-                                    g_param_spec_boolean("on-low-battery",
-                                                         NULL, NULL,
-                                                         FALSE,
-                                                         G_PARAM_READABLE));
-
-    object_class->finalize = xfpm_supply_finalize;
-
-    g_type_class_add_private (klass, sizeof (XfpmSupplyPrivate));
-}
-
-static void
-xfpm_supply_init (XfpmSupply *supply)
-{
-    supply->priv = XFPM_SUPPLY_GET_PRIVATE (supply);
-  
-    supply->priv->hash    = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
-     
-    supply->priv->power   = hal_power_new      ();
-    supply->priv->notify  = xfpm_notify_new    ();
-    supply->priv->conf    = xfpm_xfconf_new    ();
-    supply->priv->tray    = NULL;
-    supply->priv->inhibit = xfpm_inhibit_new   ();
-    supply->priv->inhibited = FALSE;
-    supply->priv->low_power = FALSE;
-    
-    g_signal_connect (supply->priv->inhibit, "has-inhibit-changed",
-		      G_CALLBACK (xfpm_supply_has_inhibit_changed_cb), supply);
-			  
-    g_signal_connect (supply->priv->conf, "notify::" SHOW_TRAY_ICON_CFG,
-		      G_CALLBACK (xfpm_supply_tray_settings_changed), supply);
-}
-
-static void
-xfpm_supply_finalize (GObject *object)
-{
-    XfpmSupply *supply;
-    supply = XFPM_SUPPLY(object);
-    
-    g_object_unref(supply->priv->power);
-	
-    g_hash_table_destroy (supply->priv->hash);
-	
-    g_object_unref (supply->priv->notify);
-	
-    g_object_unref (supply->priv->conf);
-	
-    g_object_unref (supply->priv->adapter);
-    
-    g_object_unref (supply->priv->inhibit);
-    xfpm_supply_hide_adapter_icon (supply);
-	
-    G_OBJECT_CLASS(xfpm_supply_parent_class)->finalize(object);
-}
-
-static void
-xfpm_supply_hide_adapter_icon (XfpmSupply *supply)
-{
-    if ( supply->priv->tray )
-    {
-	TRACE ("hide adapter icon");
-	g_object_unref (supply->priv->tray);
-	supply->priv->tray = NULL;
-    }
-}
-
-static void
-xfpm_supply_show_tray_icon (XfpmSupply *supply)
-{
-#ifdef DEBUG 
-    /* This shouldn't happen at all*/
-    if ( supply->priv->tray )
-    {
-	g_critical ("Already have tray icon for adapter!");
-	xfpm_supply_hide_adapter_icon (supply);
-    }
-#endif    
-
-    supply->priv->tray = xfpm_tray_icon_new ();
-    TRACE ("show adapter icon");
-    xfpm_tray_icon_set_visible (supply->priv->tray, TRUE);
-    xfpm_tray_icon_set_icon (supply->priv->tray, XFPM_AC_ADAPTER_ICON);
-    xfpm_tray_icon_set_show_info_menu (supply->priv->tray, FALSE);
-}
-
-static void
-xfpm_supply_refresh_tray_icon (XfpmSupply *supply)
-{
-    XfpmShowIcon show_icon;
-    
-    g_object_get (G_OBJECT (supply->priv->conf),
-		  SHOW_TRAY_ICON_CFG, &show_icon,
-		  NULL);
-		  
-    XFPM_DEBUG_ENUM ("Tray icon configuration: ", show_icon, XFPM_TYPE_SHOW_ICON);
-    
-    if ( show_icon == SHOW_ICON_ALWAYS )
-    {
-	if ( g_hash_table_size (supply->priv->hash) == 0 )
-	{
-	    xfpm_supply_show_tray_icon (supply);
-	    xfpm_tray_icon_set_tooltip (supply->priv->tray,
-					supply->priv->adapter_present ? 
-					(_("Adapter present")) :
-					(_("Adapter not present")) );
-	}
-	else
-	{
-	    xfpm_supply_hide_adapter_icon (supply);
-	}
-    }
-    else
-    {
-	xfpm_supply_hide_adapter_icon (supply);
-    }
-}
-
-static gboolean 
-xfpm_supply_on_low_power (XfpmSupply *supply)
-{
-    const HalBattery *device;
-    guint low_power_level;
-    
-    GList *list = NULL;
-    guint i;
-    gboolean low_power = FALSE;
-    
-    if (supply->priv->adapter_present )
-	return FALSE;
-    
-    list = g_hash_table_get_values (supply->priv->hash);
-    
-    if ( !list)
-	return FALSE;
-	
-    g_object_get (G_OBJECT (supply->priv->conf),
-		  CRITICAL_POWER_LEVEL, &low_power_level,
-		  NULL);
-		  
-    for ( i=0; i< g_list_length(list); i++)
-    {
-	XfpmBattery *battery = NULL;
-	HalDeviceType type;
-	guint percentage;
-	battery = g_list_nth_data(list, i);
-	
-	if ( !battery )
-	    continue;
-	    
-	device = xfpm_battery_get_device (battery);
-	g_object_get (G_OBJECT(device), "type", &type, "percentage", &percentage, NULL);
-	
-	if ( type != HAL_DEVICE_TYPE_PRIMARY )
-	    continue;
-	    
-	if ( percentage < low_power_level ) 
-	    low_power = TRUE;
-	else 
-	{
-	    low_power = FALSE;
-	    break;
-	}
-    }
-    
-    return low_power;
-}
-
-static void
-_notify_action_callback (NotifyNotification *n, gchar *action, XfpmSupply *supply)
-{
-    if ( xfpm_strequal(action, "shutdown") )
-	g_signal_emit (G_OBJECT(supply ), signals[SHUTDOWN_REQUEST], 0, TRUE, XFPM_DO_SHUTDOWN);
-    else if ( xfpm_strequal(action, "hibernate") )
-	g_signal_emit (G_OBJECT(supply ), signals[SHUTDOWN_REQUEST], 0, TRUE, XFPM_DO_HIBERNATE);
-}
-
-static void
-xfpm_supply_add_actions_to_notification (XfpmSupply *supply, XfpmBattery *battery, NotifyNotification *n)
-{
-    if (supply->priv->power_management != 0 )
-    {
-        xfpm_notify_add_action_to_notification(
-			       supply->priv->notify,
-			       n,
-                               "shutdown",
-                               _("Shutdown the system"),
-                               (NotifyActionCallback)_notify_action_callback,
-                               supply);   
-    }
-    
-    if ( supply->priv->power_management & SYSTEM_CAN_HIBERNATE )
-    {
-        xfpm_notify_add_action_to_notification(
-			       supply->priv->notify,
-			       n,
-                               "hibernate",
-                               _("Hibernate the system"),
-                               (NotifyActionCallback)_notify_action_callback,
-                               supply);      
-    }
-}
-
-static void
-xfpm_supply_show_critical_action_inhibited (XfpmSupply *supply, XfpmBattery *battery)
-{
-    NotifyNotification *n;
-    const gchar *message;
-    
-    message = _("System is running on low power, "\
-               "but an application is currently disabling the automatic sleep, "\
-	       "this means that doing a sleep now may damage the data of this application. "\
-	       "Close this application before putting the computer on sleep mode or plug "\
-	       "in your AC adapter");
-    
-     n = 
-	xfpm_notify_new_notification (supply->priv->notify, 
-				      _("Xfce power manager"), 
-				      message, 
-				      xfpm_battery_get_icon_name (battery),
-				      30000,
-				      XFPM_NOTIFY_CRITICAL,
-				      xfpm_battery_get_status_icon (battery));
-				      
-    xfpm_supply_add_actions_to_notification (supply, battery, n);
-    
-    xfpm_notify_critical (supply->priv->notify, n);
-}
-
-static void
-xfpm_supply_show_critical_action (XfpmSupply *supply, XfpmBattery *battery)
-{
-    const gchar *message;
-    NotifyNotification *n;
-    
-    message = _("System is running on low power. "\
-              "Save your work to avoid losing data");
-	      
-    n = 
-	xfpm_notify_new_notification (supply->priv->notify, 
-				      _("Xfce power manager"), 
-				      message, 
-				      xfpm_battery_get_icon_name (battery),
-				      20000,
-				      XFPM_NOTIFY_CRITICAL,
-				      xfpm_battery_get_status_icon (battery));
-    
-    xfpm_supply_add_actions_to_notification (supply, battery, n);
-    xfpm_notify_critical (supply->priv->notify, n);
-}
-
-static void
-xfpm_supply_process_critical_action (XfpmSupply *supply, XfpmBattery *battery, XfpmShutdownRequest critical_action)
-{
-    if ( critical_action == XFPM_ASK )
-    {
-	if ( supply->priv->inhibited )
-	    xfpm_supply_show_critical_action_inhibited (supply, battery);
-	else
-	    xfpm_supply_show_critical_action (supply, battery);
-	    
-	return;
-    }
-	
-    g_signal_emit (G_OBJECT(supply ), signals[SHUTDOWN_REQUEST], 0, TRUE, critical_action);
-}
-
-static void
-xfpm_supply_handle_primary_critical (XfpmSupply *supply, XfpmBattery *battery)
-{
-    XfpmShutdownRequest critical_action;
-    
-    g_object_get (G_OBJECT (supply->priv->conf),
-	          CRITICAL_BATT_ACTION_CFG, &critical_action,
-		  NULL);
-
-    TRACE ("System is running on low power");
-    XFPM_DEBUG_ENUM ("Critical battery action", critical_action, XFPM_TYPE_SHUTDOWN_REQUEST);
-    
-    if ( supply->priv->inhibited )
-    {
-	xfpm_supply_show_critical_action_inhibited (supply, battery);
-    }
-    else if ( critical_action == XFPM_DO_NOTHING )
-    {
-	xfpm_supply_show_critical_action (supply, battery);
-    }
-    else
-    {
-	xfpm_supply_process_critical_action (supply, battery, critical_action);
-    }
-}
-
-static void
-xfpm_supply_battery_state_changed_cb (XfpmBattery *battery, XfpmBatteryState state, XfpmSupply *supply)
-{
-    gboolean low_power;
-    
-    low_power = xfpm_supply_on_low_power (supply);
-    
-    if ( state == BATTERY_CHARGE_CRITICAL && low_power )
-    {
-	supply->priv->low_power = TRUE;
-	g_object_notify (G_OBJECT (supply), "on-low-battery");
-	xfpm_supply_handle_primary_critical (supply, battery);
-    }
-    else if ( !low_power && supply->priv->low_power )
-    {
-	supply->priv->low_power = FALSE;
-	g_object_notify (G_OBJECT (supply), "on-low-battery");
-	xfpm_notify_close_critical (supply->priv->notify);
-    }
-}
-
-static XfpmBattery *
-xfpm_supply_get_battery (XfpmSupply *supply, const gchar *udi)
-{
-    XfpmBattery *battery;
-    battery = (XfpmBattery *)g_hash_table_lookup (supply->priv->hash, udi);
-    return battery;
-}
-
-static void
-xfpm_supply_add_battery (XfpmSupply *supply, const HalBattery *device)
-{
-    XfpmBattery *battery;
-    const gchar *udi;
-    
-    udi = hal_device_get_udi (HAL_DEVICE(device));
-
-    TRACE("New battery found %s", udi);
-
-    battery = xfpm_battery_new (device);
-    
-    g_hash_table_insert (supply->priv->hash, g_strdup(udi), battery);
-    
-    g_signal_connect (G_OBJECT(battery), "battery-state-changed",
-		      G_CALLBACK(xfpm_supply_battery_state_changed_cb), supply);
-		      
-    xfpm_supply_refresh_tray_icon (supply);
-}
-
-static void
-xfpm_supply_remove_battery (XfpmSupply *supply,  const HalBattery *device)
-{
-    const gchar *udi = hal_device_get_udi (HAL_DEVICE(device));
-    
-    XfpmBattery *battery = xfpm_supply_get_battery(supply, udi);
-	
-    if ( battery )
-    {
-	TRACE("Removing battery %s", udi);
-	if (!g_hash_table_remove (supply->priv->hash, udi))
-		g_critical ("Unable to remove battery object from hash");
-    }
-    xfpm_supply_refresh_tray_icon (supply);
-}
-
-static void
-xfpm_supply_battery_added_cb (HalPower *power, const HalBattery *device, XfpmSupply *supply)
-{
-    xfpm_supply_add_battery (supply, device);
-}
-
-static void
-xfpm_supply_battery_removed_cb (HalPower *power, const HalBattery *device, XfpmSupply *supply)
-{
-    xfpm_supply_remove_battery (supply, device);
-}
-
-static gboolean
-xfpm_supply_monitor_start (XfpmSupply *supply)
-{
-    GPtrArray *array;
-    guint i = 0;
-    
-    supply->priv->adapter_present = xfpm_adapter_get_present (supply->priv->adapter);
-    
-    array = hal_power_get_batteries (supply->priv->power);
-    
-    for ( i = 0; i<array->len; i++ )
-    {
-	HalBattery *device;
-	device = (HalBattery *)g_ptr_array_index(array, i);
-	xfpm_supply_add_battery (supply, device);
-    }
-    
-    g_ptr_array_free(array, TRUE);
-    
-    g_signal_connect(supply->priv->power, "battery-added",
-		     G_CALLBACK(xfpm_supply_battery_added_cb), supply);
-		     
-    g_signal_connect(supply->priv->power, "battery-removed",
-		     G_CALLBACK(xfpm_supply_battery_removed_cb), supply);
-    
-    return FALSE;
-}
-
-static void
-xfpm_supply_save_power (XfpmSupply *supply)
-{
-    gboolean save_power;
-
-    g_object_get (G_OBJECT (supply->priv->conf),
-		  POWER_SAVE_ON_BATTERY, &save_power,
-		  NULL);
-    
-    if ( save_power == FALSE )
-	hal_power_unset_power_save (supply->priv->power);
-    else if ( supply->priv->adapter_present )
-	hal_power_unset_power_save (supply->priv->power);
-    else 
-	hal_power_set_power_save (supply->priv->power);
-}
-
-static void
-xfpm_supply_adapter_changed_cb (XfpmAdapter *adapter, gboolean present, XfpmSupply *supply)
-{
-    supply->priv->adapter_present = present;
-    
-    g_object_notify (G_OBJECT (supply), "on-battery");
-    
-    if ( supply->priv->adapter_present && supply->priv->low_power )
-    {
-	supply->priv->low_power = FALSE;
-	g_object_notify (G_OBJECT (supply), "on-low-battery");
-	xfpm_notify_close_critical (supply->priv->notify);
-    }
-    
-    xfpm_supply_save_power (supply);
-}
-
-/*
- * Public functions
- */ 
-XfpmSupply *
-xfpm_supply_new (guint8 power_management_info)
-{
-    XfpmSupply *supply = NULL;
-    supply = g_object_new(XFPM_TYPE_SUPPLY,NULL);
-    
-    supply->priv->power_management = power_management_info;
-    
-    return supply;
-}
-
-void xfpm_supply_monitor (XfpmSupply *supply)
-{
-    supply->priv->adapter = xfpm_adapter_new ();
-    
-    g_signal_connect (supply->priv->adapter, "adapter-changed",
-		      G_CALLBACK(xfpm_supply_adapter_changed_cb), supply);
-      
-    xfpm_supply_monitor_start (supply);
-    
-    xfpm_supply_refresh_tray_icon (supply);
-    
-    supply->priv->low_power = xfpm_supply_on_low_power (supply);
-    
-    if ( supply->priv->low_power )
-	g_object_notify (G_OBJECT (supply), "on-low-battery");
-}
-
-gboolean xfpm_supply_on_low_battery (XfpmSupply *supply)
-{
-    g_return_val_if_fail (XFPM_IS_SUPPLY(supply), FALSE);
-    
-    return supply->priv->low_power;
-}
-
-void xfpm_supply_reload (XfpmSupply *supply)
-{
-    g_return_if_fail (XFPM_IS_SUPPLY (supply));
-    
-    g_object_unref (supply->priv->power);
-    
-    g_hash_table_destroy (supply->priv->hash);
-    
-    supply->priv->power = hal_power_new ();
-    supply->priv->hash  = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
-    
-    xfpm_supply_monitor_start (supply);
-}
diff --git a/src/xfpm-supply.h b/src/xfpm-supply.h
deleted file mode 100644
index 982060b..0000000
--- a/src/xfpm-supply.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __XFPM_SUPPLY_H
-#define __XFPM_SUPPLY_H
-
-#include <glib-object.h>
-
-#include "xfpm-enum.h"
-#include "xfpm-enum-glib.h"
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_SUPPLY       (xfpm_supply_get_type () )
-#define XFPM_SUPPLY(o)         (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_SUPPLY, XfpmSupply))
-#define XFPM_IS_SUPPLY(o)      (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_SUPPLY))
-
-typedef struct XfpmSupplyPrivate XfpmSupplyPrivate;
-
-typedef struct
-{
-    GObject		 parent;
-    XfpmSupplyPrivate   *priv;
-	
-} XfpmSupply;
-
-typedef struct
-{
-    GObjectClass         parent_class;
-    
-    void                (*shutdown_request)	    (XfpmSupply *supply,
-						     gboolean critical,
-						     XfpmShutdownRequest action);
-	
-} XfpmSupplyClass;
-
-GType   	         xfpm_supply_get_type       (void) G_GNUC_CONST;
-
-XfpmSupply     	        *xfpm_supply_new            (guint8 power_management_info);
-
-void                     xfpm_supply_monitor        (XfpmSupply *supply);
-
-gboolean                 xfpm_supply_on_low_battery (XfpmSupply *supply) G_GNUC_PURE;
-
-void                     xfpm_supply_reload         (XfpmSupply *supply);
-
-G_END_DECLS
-
-#endif /* __XFPM_SUPPLY_H */
diff --git a/src/xfpm-tray-icon.c b/src/xfpm-tray-icon.c
deleted file mode 100644
index ed1f116..0000000
--- a/src/xfpm-tray-icon.c
+++ /dev/null
@@ -1,558 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <glib.h>
-#include <gtk/gtk.h>
-
-#include <libxfce4util/libxfce4util.h>
-#include <libxfcegui4/libxfcegui4.h>
-
-#include "libxfpm/xfpm-common.h"
-#include "libxfpm/xfpm-string.h"
-#include "libxfpm/xfpm-notify.h"
-#include "libxfpm/xfpm-icons.h"
-
-#include "xfpm-tray-icon.h"
-#include "xfpm-shutdown.h"
-#include "xfpm-dbus-monitor.h"
-#include "xfpm-inhibit.h"
-#include "xfpm-screen-saver.h"
-#include "xfpm-xfconf.h"
-#include "xfpm-config.h"
-
-static void xfpm_tray_icon_finalize   (GObject *object);
-
-#define XFPM_TRAY_ICON_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_TRAY_ICON, XfpmTrayIconPrivate))
-
-struct XfpmTrayIconPrivate
-{
-    XfpmShutdown    *shutdown;
-    XfpmXfconf      *conf;
-    XfpmNotify      *notify;
-    XfpmInhibit     *inhibit;
-    XfpmScreenSaver *srv;
-    XfpmDBusMonitor *monitor;
-    
-    GtkStatusIcon   *icon;
-    GQuark           icon_quark;
-    gboolean         info_menu;
-    gboolean         inhibited;
-    gboolean	     data_available;
-    
-    gulong           sig;
-    gulong	     sig_1;
-};
-
-enum
-{
-    SHOW_INFORMATION,
-    LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(XfpmTrayIcon, xfpm_tray_icon, G_TYPE_OBJECT)
-
-static gboolean
-xfpm_tray_icon_size_changed_cb (GtkStatusIcon *icon, gint size, XfpmTrayIcon *tray)
-{
-    GdkPixbuf *pix;
-    
-    g_return_val_if_fail (size > 0, FALSE);
-    
-    g_debug ("Size Changed %d icon=%s", size, g_quark_to_string (tray->priv->icon_quark));
-    
-    if ( size > 128 )
-	return FALSE;
-
-    if ( tray->priv->icon_quark == 0 )
-	return FALSE;
-    
-    pix = xfce_themed_icon_load (g_quark_to_string (tray->priv->icon_quark), size);
-    
-    if ( pix )
-    {
-	gtk_status_icon_set_from_pixbuf (GTK_STATUS_ICON(tray->priv->icon), pix);
-	g_object_unref (pix);
-	return TRUE;
-    }
-    return FALSE;
-}
-
-static void
-xfpm_tray_info (GtkWidget *w, XfpmTrayIcon *tray)
-{
-    g_signal_emit (G_OBJECT (tray), signals[SHOW_INFORMATION], 0);
-}
-
-static gboolean
-xfpm_tray_icon_do_suspend (XfpmTrayIcon *tray)
-{
-    GError *error = NULL;
-
-    xfpm_suspend (tray->priv->shutdown, &error);
-
-    if (error)
-    {
-	g_warning ("%s", error->message);
-	xfpm_notify_show_notification (tray->priv->notify, 
-				      _("Xfce power manager"), 
-				       error->message, 
-				       xfpm_tray_icon_get_icon_name (tray),
-				       10000,
-				       FALSE,
-				       XFPM_NOTIFY_CRITICAL,
-				       tray->priv->icon);
-	g_error_free (error);
-    }
-    return FALSE;
-}
-
-static gboolean
-xfpm_tray_icon_do_hibernate (XfpmTrayIcon *tray)
-{
-    GError *error = NULL;
-
-    xfpm_hibernate (tray->priv->shutdown, &error);
-    
-    if (error)
-    {
-	g_warning ("%s", error->message);
-	xfpm_notify_show_notification (tray->priv->notify, 
-				      _("Xfce power manager"), 
-				       error->message, 
-				       xfpm_tray_icon_get_icon_name (tray),
-				       10000,
-				       FALSE,
-				       XFPM_NOTIFY_CRITICAL,
-				       tray->priv->icon);
-	g_error_free (error);
-    }
-    return FALSE;
-}
-
-static void
-xfpm_tray_icon_hibernate_cb (GtkWidget *w, XfpmTrayIcon *tray)
-{
-    const gchar *message;
-    gboolean lock_screen;
-    gboolean ret;
-
-    g_object_get (G_OBJECT (tray->priv->conf),
-		  LOCK_SCREEN_ON_SLEEP, &lock_screen,
-		  NULL);
-    
-    message = tray->priv->inhibited ? 
-	     _("An application is currently disabling the automatic sleep,"
-	      " doing this action now may damage the working state of this application,"
-	      " are you sure you want to hibernate the system?") :
-	      _("Are you sure you want to proceed?") ;
-    
-    ret = 
-	xfce_confirm (message,
-		      GTK_STOCK_YES,
-		      _("Hibernate"));
-    
-    if ( ret ) 
-    {
-	xfpm_shutdown_add_callback (tray->priv->shutdown, 
-				    (GSourceFunc) xfpm_tray_icon_do_hibernate, 
-				    lock_screen,
-				    tray);
-    }
-}
-
-static void
-xfpm_tray_icon_suspend_cb (GtkWidget *w, XfpmTrayIcon *tray)
-{
-    const gchar *message;
-    gboolean lock_screen;
-    gboolean ret;
-    
-    g_object_get (G_OBJECT (tray->priv->conf),
-		  LOCK_SCREEN_ON_SLEEP, &lock_screen,
-		  NULL);
-    
-    message = tray->priv->inhibited ? 
-	     _("An application is currently disabling the automatic sleep,"
-	      " doing this action now may damage the working state of this application,"
-	      " are you sure you want to suspend the system?") :
-	      _("Are you sure you want to proceed?") ;
-    
-    ret = 
-	xfce_confirm  (message,
-		       GTK_STOCK_YES,
-		       _("Suspend"));
-    
-    if ( ret ) 
-    {
-	xfpm_shutdown_add_callback (tray->priv->shutdown, 
-				    (GSourceFunc) xfpm_tray_icon_do_suspend, 
-				    lock_screen,
-				    tray);
-    }
-}
-
-static void
-xfpm_tray_icon_exit_activated_cb (GtkWidget *w, gpointer data)
-{
-    gboolean ret;
-    
-    ret = xfce_confirm (_("Quit the Xfce power manager"),
-	                GTK_STOCK_YES,
-			_("Quit"));
-    if ( ret )
-    {
-	xfpm_quit ();
-    }
-}
-
-static void
-xfpm_tray_icon_menu_selection_done (GtkMenuShell *menu, gpointer data)
-{
-    gtk_widget_destroy (GTK_WIDGET (menu));
-}
-
-static void
-xfpm_tray_icon_inhibit_active_cb (GtkWidget *mi, XfpmTrayIcon *tray)
-{
-    gboolean active;
-    active = xfpm_screen_saver_get_inhibit (tray->priv->srv);
-    
-    active == FALSE ? xfpm_screen_saver_inhibit   (tray->priv->srv) :
-		      xfpm_screen_saver_uninhibit (tray->priv->srv);
-}
-
-static void
-xfpm_tray_icon_popup_menu_cb (GtkStatusIcon *icon, guint button, 
-			      guint activate_time, XfpmTrayIcon *tray)
-{
-    GtkWidget *menu, *mi, *img;
-    gboolean can_suspend = FALSE;
-    gboolean can_hibernate = FALSE ;
-    gboolean caller = FALSE;
-
-    gboolean saver_inhibited;
-
-    menu = gtk_menu_new();
-
-    g_object_get (G_OBJECT (tray->priv->shutdown),
-		  "caller-privilege", &caller,
-		  "can-suspend", &can_suspend,
-		  "can-hibernate", &can_hibernate,
-		  NULL);
-    
-    // Hibernate menu option
-    mi = gtk_image_menu_item_new_with_label (_("Hibernate"));
-    img = gtk_image_new_from_icon_name (XFPM_HIBERNATE_ICON, GTK_ICON_SIZE_MENU);
-    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(mi), img);
-    gtk_widget_set_sensitive (mi,FALSE);
-    
-    if ( caller && can_hibernate && tray->priv->data_available )
-    {
-	gtk_widget_set_sensitive (mi, TRUE);
-	g_signal_connect (G_OBJECT (mi), "activate",
-			  G_CALLBACK (xfpm_tray_icon_hibernate_cb), tray);
-    }
-    gtk_widget_show(mi);
-    gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
-    
-    // Suspend menu option
-    mi = gtk_image_menu_item_new_with_label(_("Suspend"));
-    img = gtk_image_new_from_icon_name (XFPM_SUSPEND_ICON, GTK_ICON_SIZE_MENU);
-    gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(mi),img);
-    
-    gtk_widget_set_sensitive(mi,FALSE);
-    if ( caller && can_suspend && tray->priv->data_available )
-    {
-	gtk_widget_set_sensitive (mi,TRUE);
-	g_signal_connect (mi, "activate",
-			  G_CALLBACK (xfpm_tray_icon_suspend_cb), tray);
-    }
-    gtk_widget_show(mi);
-    gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
-
-    saver_inhibited = xfpm_screen_saver_get_inhibit (tray->priv->srv);
-    mi = gtk_check_menu_item_new_with_label (_("Monitor power control"));
-    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi), !saver_inhibited);
-    gtk_widget_set_tooltip_text (mi, _("Disable or enable monitor power control, "\
-                                       "for example you could disable the screen power "\
-				       "control to avoid screen blanking when watching a movie."));
-    
-    g_signal_connect (G_OBJECT (mi), "activate",
-		      G_CALLBACK (xfpm_tray_icon_inhibit_active_cb), tray);
-    gtk_widget_set_sensitive (mi, TRUE);
-    gtk_widget_show(mi);
-    gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
-    
-    if ( tray->priv->info_menu )
-    {
-	mi = gtk_separator_menu_item_new();
-	gtk_widget_show(mi);
-	gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
-    
-	// Battery informations
-    
-	mi = gtk_image_menu_item_new_from_stock (GTK_STOCK_INFO, NULL);
-	
-	gtk_widget_set_sensitive(mi,FALSE);
-	gtk_widget_set_sensitive (mi,TRUE);
-	
-	g_signal_connect(mi,"activate",
-			 G_CALLBACK(xfpm_tray_info), tray);
-			 
-	gtk_widget_show(mi);
-	gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
-    
-    
-	// Separator
-	mi = gtk_separator_menu_item_new();
-	gtk_widget_show(mi);
-	gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
-    }
-	
-    mi = gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP,NULL);
-    gtk_widget_set_sensitive(mi,TRUE);
-    gtk_widget_show(mi);
-    g_signal_connect(mi,"activate",G_CALLBACK(xfpm_help),NULL);
-	
-    gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
-    
-    
-    mi = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT,NULL);
-    gtk_widget_set_sensitive(mi,TRUE);
-    gtk_widget_show(mi);
-    g_signal_connect(mi,"activate",G_CALLBACK(xfpm_about), _("Xfce Power Manager"));
-    
-    gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
-    
-    mi = gtk_image_menu_item_new_from_stock(GTK_STOCK_PREFERENCES,NULL);
-    gtk_widget_set_sensitive(mi,TRUE);
-    gtk_widget_show(mi);
-    g_signal_connect(mi,"activate",G_CALLBACK(xfpm_preferences),NULL);
-    
-    gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
-
-    mi = gtk_separator_menu_item_new ();
-    gtk_widget_show (mi);
-    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
-
-    mi = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL);
-    gtk_widget_set_sensitive (mi, TRUE);
-    gtk_widget_show (mi);
-    g_signal_connect (mi, "activate", G_CALLBACK (xfpm_tray_icon_exit_activated_cb), NULL);
-    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
-
-    g_signal_connect (menu, "selection-done",
-		      G_CALLBACK (xfpm_tray_icon_menu_selection_done), NULL);
-
-    // Popup the menu
-    gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
-		   gtk_status_icon_position_menu, 
-		   icon, button, activate_time);
-}
-
-static void
-xfpm_tray_icon_inhibit_changed_cb (XfpmInhibit *inhibit, gboolean inhibited, XfpmTrayIcon *tray)
-{
-    tray->priv->inhibited = inhibited;
-}
-
-static void
-xfpm_tray_icon_hal_connection_changed_cb (XfpmDBusMonitor *monitor, gboolean connected, XfpmTrayIcon *tray)
-{
-    if ( connected == FALSE )
-	xfpm_tray_icon_set_tooltip (tray, _("No data available"));
-	
-    /*
-     * We set this variable after since xfpm_tray_icon_set_tooltip will return 
-     * if data_available is set to FALSE
-     */
-    tray->priv->data_available = connected;
-}
-
-static void
-xfpm_tray_icon_activated_cb (XfpmTrayIcon *tray)
-{
-    xfpm_preferences ();
-}
-
-static void
-xfpm_tray_icon_class_init(XfpmTrayIconClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-    signals[SHOW_INFORMATION] =
-            g_signal_new("show-information",
-                         XFPM_TYPE_TRAY_ICON,
-                         G_SIGNAL_RUN_LAST,
-                         G_STRUCT_OFFSET(XfpmTrayIconClass, show_info),
-                         NULL, NULL,
-                         g_cclosure_marshal_VOID__VOID,
-                         G_TYPE_NONE, 0, G_TYPE_NONE);
-
-    object_class->finalize = xfpm_tray_icon_finalize;
-
-    g_type_class_add_private(klass,sizeof(XfpmTrayIconPrivate));
-}
-
-static void
-xfpm_tray_icon_init(XfpmTrayIcon *tray)
-{
-    tray->priv = XFPM_TRAY_ICON_GET_PRIVATE(tray);
-    
-    tray->priv->icon  = gtk_status_icon_new();
-    tray->priv->shutdown = xfpm_shutdown_new ();
-    tray->priv->conf  = xfpm_xfconf_new ();
-    tray->priv->notify = xfpm_notify_new ();
-    tray->priv->inhibited = FALSE;
-    tray->priv->inhibit = xfpm_inhibit_new ();
-    tray->priv->srv     = xfpm_screen_saver_new ();
-    tray->priv->monitor = xfpm_dbus_monitor_new ();
-    
-    tray->priv->info_menu = TRUE;
-    tray->priv->icon_quark = 0;
-    
-    g_signal_connect (tray->priv->icon, "size-changed",
-		      G_CALLBACK (xfpm_tray_icon_size_changed_cb), tray);
-		      
-    g_signal_connect (tray->priv->icon, "popup-menu",
-		      G_CALLBACK (xfpm_tray_icon_popup_menu_cb), tray);
-		      
-    g_signal_connect_swapped (tray->priv->icon, "activate",
-			      G_CALLBACK (xfpm_tray_icon_activated_cb), tray);
-			      
-    tray->priv->sig = g_signal_connect (tray->priv->inhibit, "has-inhibit-changed",
-					G_CALLBACK (xfpm_tray_icon_inhibit_changed_cb), tray);
-					
-    tray->priv->sig_1 = g_signal_connect (tray->priv->monitor, "hal-connection-changed",
-					 G_CALLBACK (xfpm_tray_icon_hal_connection_changed_cb), tray);
-					 
-    tray->priv->data_available = xfpm_dbus_monitor_hal_connected (tray->priv->monitor);
-}
-
-static void
-xfpm_tray_icon_finalize(GObject *object)
-{
-    XfpmTrayIcon *tray;
-
-    tray = XFPM_TRAY_ICON(object);
-    
-    if ( g_signal_handler_is_connected (tray->priv->inhibit, tray->priv->sig ) )
-	g_signal_handler_disconnect (G_OBJECT (tray->priv->inhibit), tray->priv->sig);
-    
-    if ( g_signal_handler_is_connected (tray->priv->monitor, tray->priv->sig_1) )
-	g_signal_handler_disconnect (G_OBJECT (tray->priv->monitor), tray->priv->sig_1);
-	
-    g_object_unref (tray->priv->monitor);
-    
-    g_object_unref (tray->priv->icon);
-	
-    g_object_unref (tray->priv->shutdown);
-    
-    g_object_unref (tray->priv->conf);
-    
-    g_object_unref (tray->priv->notify);
-    
-    g_object_unref (tray->priv->inhibit);
-    
-    g_object_unref (tray->priv->srv);
-
-    G_OBJECT_CLASS(xfpm_tray_icon_parent_class)->finalize(object);
-}
-
-XfpmTrayIcon *
-xfpm_tray_icon_new(void)
-{
-    XfpmTrayIcon *tray = NULL;
-    tray = g_object_new (XFPM_TYPE_TRAY_ICON, NULL);
-    return tray;
-}
-
-void xfpm_tray_icon_set_show_info_menu (XfpmTrayIcon *icon, gboolean value)
-{
-    g_return_if_fail (XFPM_IS_TRAY_ICON (icon));
-    icon->priv->info_menu = value;
-}
-
-void xfpm_tray_icon_set_icon (XfpmTrayIcon *icon, const gchar *icon_name)
-{
-    g_return_if_fail(XFPM_IS_TRAY_ICON(icon));
-    
-    icon->priv->icon_quark = g_quark_from_string(icon_name);
-    
-    xfpm_tray_icon_size_changed_cb (icon->priv->icon,
-				    gtk_status_icon_get_size(icon->priv->icon),
-				    icon);
-}
-
-void xfpm_tray_icon_set_tooltip (XfpmTrayIcon *icon, const gchar *tooltip)
-{
-    g_return_if_fail (XFPM_IS_TRAY_ICON (icon));
-    /*
-     * Hal is disconnected we have the tooltips set to "no data available"
-     */
-    g_return_if_fail (icon->priv->data_available);
-
-#if GTK_CHECK_VERSION (2, 16, 0)
-    gtk_status_icon_set_tooltip_text (GTK_STATUS_ICON(icon->priv->icon), tooltip);
-#else
-    gtk_status_icon_set_tooltip (GTK_STATUS_ICON(icon->priv->icon), tooltip);
-#endif
-}
-
-void xfpm_tray_icon_set_visible (XfpmTrayIcon *icon, gboolean visible)
-{
-    g_return_if_fail(XFPM_IS_TRAY_ICON(icon));
-    
-    gtk_status_icon_set_visible(GTK_STATUS_ICON(icon->priv->icon), visible);
-}
-
-gboolean xfpm_tray_icon_get_visible (XfpmTrayIcon *icon)
-{
-    g_return_val_if_fail (XFPM_IS_TRAY_ICON(icon), FALSE);
-    
-    return gtk_status_icon_get_visible (GTK_STATUS_ICON(icon->priv->icon));
-}
-
-GtkStatusIcon *xfpm_tray_icon_get_tray_icon (XfpmTrayIcon *icon)
-{
-    g_return_val_if_fail(XFPM_IS_TRAY_ICON(icon), NULL);
-    
-    return icon->priv->icon;
-}
-
-const gchar *xfpm_tray_icon_get_icon_name   (XfpmTrayIcon *icon)
-{
-    g_return_val_if_fail(XFPM_IS_TRAY_ICON(icon), NULL);
-    
-    if ( icon->priv->icon_quark == 0 ) return NULL;
-    
-    return  g_quark_to_string (icon->priv->icon_quark);
-}
diff --git a/src/xfpm-tray-icon.h b/src/xfpm-tray-icon.h
deleted file mode 100644
index 31944e7..0000000
--- a/src/xfpm-tray-icon.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __XFPM_TRAY_ICON_H
-#define __XFPM_TRAY_ICON_H
-
-#include <glib-object.h>
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_TRAY_ICON        (xfpm_tray_icon_get_type () )
-#define XFPM_TRAY_ICON(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), XFPM_TYPE_TRAY_ICON, XfpmTrayIcon))
-#define XFPM_IS_TRAY_ICON(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), XFPM_TYPE_TRAY_ICON))
-
-typedef struct XfpmTrayIconPrivate XfpmTrayIconPrivate;
-
-typedef struct
-{
-    GObject		    parent;
-    XfpmTrayIconPrivate    *priv;
-	
-} XfpmTrayIcon;
-
-typedef struct
-{
-    GObjectClass            parent_class;
-    
-    void                    (*show_info)	   (XfpmTrayIcon *icon);
-	
-} XfpmTrayIconClass;
-
-GType        	    xfpm_tray_icon_get_type        	(void) G_GNUC_CONST;
-XfpmTrayIcon       *xfpm_tray_icon_new             	(void);
-
-void                xfpm_tray_icon_set_show_info_menu 	(XfpmTrayIcon *icon,
-						         gboolean value);
-
-void                xfpm_tray_icon_set_icon        	(XfpmTrayIcon *icon,
-							 const gchar *icon_name);
-						    
-void                xfpm_tray_icon_set_tooltip     	(XfpmTrayIcon *icon,
-							 const gchar *tooltip);
-						    
-void                xfpm_tray_icon_set_visible    	(XfpmTrayIcon *icon,
-							 gboolean visible);
-						    
-gboolean            xfpm_tray_icon_get_visible     	(XfpmTrayIcon *icon);
-
-GtkStatusIcon      *xfpm_tray_icon_get_tray_icon   	(XfpmTrayIcon *icon) G_GNUC_PURE;
-
-const gchar        *xfpm_tray_icon_get_icon_name   	(XfpmTrayIcon *icon) G_GNUC_PURE;  
-
-G_END_DECLS
-
-#endif /* __XFPM_TRAY_ICON_H */
diff --git a/src/xfpm-xfconf.c b/src/xfpm-xfconf.c
index 2152b84..3ac3a46 100644
--- a/src/xfpm-xfconf.c
+++ b/src/xfpm-xfconf.c
@@ -29,16 +29,12 @@
 #include <glib.h>
 #include <libxfce4util/libxfce4util.h>
 
-#include <xfconf/xfconf.h>
-
-#include "libxfpm/xfpm-string.h"
-#include "libxfpm/xfpm-common.h"
-
 #include "xfpm-xfconf.h"
 #include "xfpm-config.h"
 #include "xfpm-enum-glib.h"
 #include "xfpm-enum.h"
 #include "xfpm-enum-types.h"
+#include "xfpm-debug.h"
 
 static void xfpm_xfconf_finalize   (GObject *object);
 
@@ -81,6 +77,10 @@ enum
     PROP_IDLE_SLEEP_MODE,
     PROP_DIM_ON_AC_TIMEOUT,
     PROP_DIM_ON_BATTERY_TIMEOUT,
+    PROP_SPIN_DOWN_DISK_ON_AC,
+    PROP_SPIN_DOWN_DISK_ON_BATTERY,
+    PROP_SPIN_DOWN_DISK_ON_AC_TIMEOUT,
+    PROP_SPIN_DOWN_DISK_ON_BATTERY_TIMEOUT,
     N_PROPERTIES
 };
 
@@ -151,13 +151,13 @@ xfpm_xfconf_load (XfpmXfconf *conf, gboolean channel_valid)
 	{
 	    if ( !xfconf_channel_get_property (conf->priv->channel, prop_name, &value) )
 	    {
-		TRACE ("Using default configuration for %s", specs[i]->name);
+		XFPM_DEBUG ("Using default configuration for %s", specs[i]->name);
 		g_param_value_set_default (specs[i], &value);
 	    }
 	}
 	else
 	{
-	    TRACE ("Using default configuration for %s", specs[i]->name);
+	    XFPM_DEBUG ("Using default configuration for %s", specs[i]->name);
 	    g_param_value_set_default (specs[i], &value);
 	}
 	g_free (prop_name);
@@ -178,7 +178,7 @@ xfpm_xfconf_property_changed_cb (XfconfChannel *channel, gchar *property,
     if ( !g_str_has_prefix (property, PROPERTIES_PREFIX) || strlen (property) <= strlen (PROPERTIES_PREFIX) )
 	return;
 
-    TRACE("Property modified: %s\n", property);
+    XFPM_DEBUG("Property modified: %s\n", property);
     
     g_object_set_property (G_OBJECT (conf), property + strlen (PROPERTIES_PREFIX), value);
 }
@@ -464,6 +464,50 @@ xfpm_xfconf_class_init (XfpmXfconfClass *klass)
 							120,
                                                         G_PARAM_READWRITE));
 
+    /**
+     * XfpmXfconf::spin-down-on-ac
+     **/
+    g_object_class_install_property (object_class,
+                                     PROP_SPIN_DOWN_DISK_ON_AC,
+                                     g_param_spec_boolean (SPIN_DOWN_ON_AC,
+                                                           NULL, NULL,
+                                                           FALSE,
+                                                           G_PARAM_READWRITE));
+
+    /**
+     * XfpmXfconf::spin-down-on-battery
+     **/
+    g_object_class_install_property (object_class,
+                                     PROP_SPIN_DOWN_DISK_ON_BATTERY,
+                                     g_param_spec_boolean (SPIN_DOWN_ON_BATTERY,
+                                                           NULL, NULL,
+                                                           FALSE,
+                                                           G_PARAM_READWRITE));
+
+    /**
+     * XfpmXfconf::spin-down-on-ac-timeout
+     **/
+    g_object_class_install_property (object_class,
+                                     PROP_SPIN_DOWN_DISK_ON_AC_TIMEOUT,
+                                     g_param_spec_uint (SPIN_DOWN_ON_AC_TIMEOUT,
+                                                        NULL, NULL,
+							800,
+							G_MAXUINT,
+							800,
+                                                        G_PARAM_READWRITE));
+
+    /**
+     * XfpmXfconf::spin-down-on-battery-timeout
+     **/
+    g_object_class_install_property (object_class,
+                                     PROP_SPIN_DOWN_DISK_ON_BATTERY_TIMEOUT,
+                                     g_param_spec_uint (SPIN_DOWN_ON_BATTERY_TIMEOUT,
+                                                        NULL, NULL,
+							120,
+							G_MAXUINT,
+							120,
+                                                        G_PARAM_READWRITE));
+
     g_type_class_add_private (klass, sizeof (XfpmXfconfPrivate));
 }
 
@@ -517,7 +561,7 @@ xfpm_xfconf_finalize(GObject *object)
 }
 
 XfpmXfconf *
-xfpm_xfconf_new(void)
+xfpm_xfconf_new (void)
 {
     static gpointer xfpm_xfconf_object = NULL;
     
@@ -532,3 +576,8 @@ xfpm_xfconf_new(void)
     }
     return XFPM_XFCONF (xfpm_xfconf_object);
 }
+
+XfconfChannel *xfpm_xfconf_get_channel (XfpmXfconf *conf)
+{
+    return conf->priv->channel;
+}
diff --git a/src/xfpm-xfconf.h b/src/xfpm-xfconf.h
index 1fb4af1..15eccc5 100644
--- a/src/xfpm-xfconf.h
+++ b/src/xfpm-xfconf.h
@@ -22,6 +22,7 @@
 #define __XFPM_XFCONF_H
 
 #include <glib-object.h>
+#include <xfconf/xfconf.h>
 
 G_BEGIN_DECLS
 
@@ -48,6 +49,8 @@ GType        		  xfpm_xfconf_get_type           	(void) G_GNUC_CONST;
 
 XfpmXfconf       	 *xfpm_xfconf_new                 	(void);
 
+XfconfChannel 		 *xfpm_xfconf_get_channel		(XfpmXfconf *conf);
+
 G_END_DECLS
 
 #endif /* __XFPM_XFCONF_H */



More information about the Xfce4-commits mailing list