diff --git a/data/system/boot/first_login/default_deskbar_items.sh b/data/system/boot/first_login/default_deskbar_items.sh index 5f004b317c..21e0cd8b08 100755 --- a/data/system/boot/first_login/default_deskbar_items.sh +++ b/data/system/boot/first_login/default_deskbar_items.sh @@ -1,8 +1,9 @@ #!/bin/sh -# install ProcessController, NetworkStatus & volume control in the Deskbar +# install ProcessController, NetworkStatus, PowerStatus & volume control in the Deskbar /boot/system/apps/ProcessController -deskbar /boot/system/apps/NetworkStatus --deskbar +/boot/system/apps/PowerStatus --deskbar /boot/system/bin/desklink --add-volume # install KeymapSwitcher for certain locales diff --git a/src/apps/powerstatus/PowerStatus.cpp b/src/apps/powerstatus/PowerStatus.cpp index 46c785474b..2b1fce98e6 100644 --- a/src/apps/powerstatus/PowerStatus.cpp +++ b/src/apps/powerstatus/PowerStatus.cpp @@ -33,8 +33,12 @@ class PowerStatus : public BApplication { PowerStatus(); virtual ~PowerStatus(); + virtual void ArgvReceived(int32 argc, char** argv); virtual void ReadyToRun(); virtual void AboutRequested(); + + private: + bool fAutoInstallInDeskbar; }; @@ -61,7 +65,9 @@ our_image(image_info& image) PowerStatus::PowerStatus() - : BApplication(kSignature) + : + BApplication(kSignature), + fAutoInstallInDeskbar(false) { } @@ -71,6 +77,27 @@ PowerStatus::~PowerStatus() } +void +PowerStatus::ArgvReceived(int32 argc, char** argv) +{ + if (argc <= 1) + return; + + if (strcmp(argv[1], "--help") == 0 + || strcmp(argv[1], "-h") == 0) { + const char* str = "PowerStatus options:\n" + "\t--deskbar\tautomatically add replicant to Deskbar\n" + "\t--help\t\tprint this info and exit"; + puts(str); + Quit(); + return; + } + + if (strcmp(argv[1], "--deskbar") == 0) + fAutoInstallInDeskbar = true; +} + + void PowerStatus::ReadyToRun() { @@ -83,7 +110,8 @@ PowerStatus::ReadyToRun() B_TRANSLATE("No supported battery detected. PowerStatus " "cannot be used on your system."), B_TRANSLATE("Too bad!"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); - alert->Go(); + if (!fAutoInstallInDeskbar) + alert->Go(); Quit(); return; } @@ -93,20 +121,18 @@ PowerStatus::ReadyToRun() // if the Deskbar is not alive at this point, it might be after having // acknowledged the requester below BDeskbar deskbar; -#ifdef HAIKU_TARGET_PLATFORM_HAIKU isDeskbarRunning = deskbar.IsRunning(); -#endif isInstalled = deskbar.HasItem(kDeskbarItemName); } if (isDeskbarRunning && !isInstalled) { - BAlert* alert = new BAlert("", + BAlert* alert = new BAlert("", B_TRANSLATE("You can run PowerStatus in a window " "or install it in the Deskbar."), B_TRANSLATE("Run in window"), B_TRANSLATE("Install in Deskbar"), NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); - if (alert->Go()) { + if (fAutoInstallInDeskbar || alert->Go()) { image_info info; entry_ref ref; @@ -147,11 +173,10 @@ PowerStatus::AboutRequested() int -main(int, char**) +main(int argc, char* argv[]) { PowerStatus app; app.Run(); return 0; } -