# KShutdown™ - README

A graphical shutdown utility for Linux and Windows

© Konrad Twardowski

Visit KShutdown Home Page and Wiki for more info.

## Table of Contents

- What's KF5/Qt Build?
- KF5 Build @ Linux
- Qt Build @ Linux
- Qt Build @ Windows
- Qt Build @ Haiku
- Common Compilation Errors
- Supported Functions/Platforms
- Known Issues/FAQ
- Credits | Support | License (GNU GPL, version 2)

## What's KF5/Qt Build?

| KF5 Build | Qt Build | Qt Build (Windows)
Summary | A KShutdown version compiled using KDE Frameworks 5 libraries | A KShutdown version compiled without any KDE libraries (Qt only)
Additional Features | Better visual and functional integration with KDE, better User Interface elements and standard dialog windows, global and local keyboard shortcuts configuration, customizable notifications (e.g. sounds), improved localization, a more reliable system tray/notification icon (KF5 only). | None (just plain Qt)
Compilation Script | ./Setup-kf5.sh | ./Setup-qt4.sh or ./Setup-qt5.sh | Setup-qt4.bat or ./Setup-wine.sh
Required Libraries | Qt5Widgets, Qt5DBus, base KF5 libraries (see "src/CMakeLists.txt" for details) | Qt 4: QtGui, QtDBus, QtCore (Ubuntu packages: libqtgui4, libqt4-dbus) Qt 5: Qt5Widgets, Qt5DBus, Qt5Gui, Qt5Core | See: Qt Build @ Windows
Menu Shortcut Name | KShutdown | KShutdown/Qt | KShutdown
Configuration Files | ~/.local/share/kshutdown/extras/ ~/.config/kshutdown.notifyrc ~/.config/kshutdownrc Note: You can manually import existing configuration from ~/.kde directory: ~/.kde/share/apps/kshutdown/extras/ ~/.kde/share/config/kshutdown.notifyrc ~/.kde/share/config/kshutdownrc | ~/.config/kshutdown.sf.net/KShutdown.conf ~/.local/share/data/kshutdown.sf.net/KShutdown/extras/ (Qt 4) ~/.local/share/kshutdown.sf.net/KShutdown/extras/ (Qt 5) Note: Does not apply to the portable version. | %localappdata%\kshutdown.sf.net\KShutdown\extras\ (Tip: You can open this %localappdata%... path directly in Explorer) Windows Registry (HKEY_CURRENT_USER\SOFTWARE\kshutdown.sf.net\KShutdown) Note: Does not apply to the portable version.
Installed Files | /usr/share/applications/kshutdown.desktop /usr/share/icons/hicolor/*/actions/kshutdown.* /usr/share/knotifications5/kshutdown.notifyrc /usr/share/kshutdown/extras/** /usr/share/locale/**/kshutdown.mo Note: After migration from KDE 4 version to KF 5 version, you can optionally remove the old files (if any): /usr/share/applications/kde4/kshutdown.desktop /usr/share/kde4/apps/kshutdown/extras/** /usr/share/kde4/apps/kshutdown/kshutdown.notifyrc | /usr/share/applications/kshutdown-qt.desktop /usr/share/icons/hicolor/*/actions/kshutdown.* | %ProgramFiles(x86)%\KShutdown or %ProgramFiles%\KShutdown (as installed by NSIS)
Default Program Location | /usr/bin/kshutdown | /usr/bin/kshutdown-qt | kshutdown.exe
| Developer Info
C++ #define | `KS_NATIVE_KDE` and `KS_KF5` | `KS_PURE_QT`
Build System | CMake (CMakeLists.txt files) | QMake (src/src.pro file) or CMake (experimental)
Language Translation System (input: po/*.po) | Gettext (output: build.tmp/po/*.mo) | Gettext (output: src/i18n/*.qm), kshutdown.qrc | TODO:

See Supported Functions/Platforms table for more info.

## TODO: KDE Build @ Linux

### Minimal Requirements

1. KDE 4.7+
2. Qt 4.8+ or Qt 5.x

### Compilation & Installation

1. Additional requirements: installed `"kdelibs-dev"` package, CMake, and Gettext Utilities
2. To compile and install KShutdown run: `./Setup-kde4.sh`
3. To change the installation directory (prefix) run: `./Setup-kde4.sh "/your/prefix/dir"`
4. Clang support (an alternative C++ compiler):
   - `export CXX=/usr/bin/clang++`
   - `export CXXFLAGS=-march=i686` (in case of Illegal Instruction errors on some hardware)
   - Go to step 2.

### Compilation & Installation (alternative method; for geeks and nerds only)

BUILDTYPE can be `Release` or `Debug`. You can change the installation directory (prefix) by setting the `CMAKE_INSTALL_PREFIX` environment variable. To display default prefix for KDE applications, run `kde4-config --prefix`.

1. Create output directory: `mkdir build && cd build`
2. Generate Makefiles: `cmake -DCMAKE_BUILD_TYPE=BUILDTYPE -DCMAKE_INSTALL_PREFIX="/usr/local" ..`
3. Compile: `make`
4. Make coffee
5. Install: `make install`

## Qt Build @ Linux

Note: Some functions may be unavailable in this build. See Qt Build table for more info.

### Minimal Requirements

1. Qt 4.8+ or Qt 5.x (KDE libraries are not required)

### Compilation & Installation

1. To compile KShutdown run: `./Setup-qt4.sh`
2. Installation is not required
3. Clang support (an alternative C++ compiler):
   1. `cd src; qmake -spec /usr/share/qt4/mkspecs/unsupported/linux-clang/`
   2. `make`

### Using CMake instead of QMake (experimental, Patch #4)

1. `mkdir build-qt5.tmp` (use separated "build-qt5.tmp" directory to avoid mess in source tree)
2. `cd build-qt5.tmp`
3. `cmake -DKS_PURE_QT=true -DCMAKE_INSTALL_PREFIX=/usr ..`
4. `make && ./src/kshutdown-qt`

### Using an alternate Qt version (Qt 5.x example)

1. `cd src`
2. `/usr/lib/$YOUR_VERSION-linux-gnu/qt5/bin/qmake`
3. `make`

## Qt Build @ Windows

Note: You can download a binary (already compiled) KShutdown version for Windows.

### Minimal Requirements (for compilation)

1. Qt 4.8.x (`qt-opensource-windows-x86-mingw*.exe`, minGW, LGPL version)

1. When asked about MinGW (Minimalist GNU for Windows) click download link and unpack archive into `C:\mingw32`
2. Continue Qt installation

2. Nullsoft Scriptable Install System (NSIS)
3. Windows XP/Vista/7/8/10 or compatible (including Wine)

### Compilation & Installation

- To compile and install KShutdown run: `Setup-qt4.bat` (this will rebuild both portable and installable version)
- To quick compile and test:
  1. Launch "Command Prompt" (`cmd.exe`)
  2. `cd your-kshutdown-source-dir\src`
  3. Run `c:\qt\<your-qt-version>\bin\qtvars.bat` (it should print Setting up a MinGW/Qt only environment...)
  4. Run `make && release\kshutdown-qt.exe`
  5. Right-click `kshutdown.nsi` and select Compile NSIS Script to build and test installer
- Experimental: To compile/test KShutdown under Wine/Linux run: `./Setup-wine.sh` or `wineconsole tools/test-wine.bat`

## Qt Build @ Haiku

### Compilation

1. Download and install Qt for Haiku
2. Download and unpack KShutdown source
3. Open terminal with KShutdown source: `cd src`
4. Change the default C++ compiler to GCC 4: `setgcc gcc4`
5. Create Makefiles: `qmake`
6. Build "kshutdown-qt" binary: `make`

## Common Compilation Errors

### cmake

#### CMake Error at /usr/share/cmake-2.6/Modules/FindKDE4.cmake:72

    CMake Error at /usr/share/cmake-2.6/Modules/FindKDE4.cmake:72 (MESSAGE):
    ERROR: cmake/modules/FindKDE4Internal.cmake not found in
    ...;/usr/lib/kde4/share/kde4/apps

Install "kdelibs-dev" (sometimes called kdelibs5-dev) packages for your KDE version.

#### CMake Error at (...) Phonon library or includes NOT found!

This may happen after Ubuntu upgrade even if required Phonon files are already installed. [Solution]

#### make[2]: *** No rule to make target `/usr/lib/libknotifyconfig.so.4.xx', needed by `src/kshutdown'. Stop.

This may happen after KDE upgrade. Run `./Setup-kde4.sh` to refresh Makefiles.

#### CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
QT_QT_INCLUDE_DIR (...)

This may happen if both Qt 4 and 5 qmake is installed. Try to uninstall `qt5-qmake` package.

### Setup

#### "pushd: not found" error

Try to run `./Setup-kde4.sh` and `cd build.tmp; sudo make install` instead of `sudo sh Setup-kde4.sh`

## Supported Functions/Platforms

Desktop Environment/Platform | Turn Off Computer1 2 | Restart Computer1 2 | Suspend2 | Hibernate2 | Lock Screen | Logout | Extras | Waiting for a selected application | Inactivity Monitor
Legend
Test | Should work, still testing ;)
OK | Done (hover an item to display implementation details)
N/A | Function is not available on this platform/KShutdown version
TODO/FIXME | Work In Progress - to be implemented in a future...
CLI | Function available via Command Line (example: kshutdown --lock)
1 D-Bus commands should work with GDM, KDM, LightDM, and other Display Managers
2 systemd (org.freedesktop.login1 D-Bus interface) is supported since KShutdown 3.2
3 some features may work
Plasma 5 (KF5 Build) | OK | OK | OK | Test | OK | OK | Test | Test, no CLI | OK
Windows XP/Vista/7/8/10 | OK | OK | OK | OK | OK | OK | OK | OK, no CLI | OK
Xfce 4.8+ | OK | OK | OK | OK | OK | Test | Test | OK, no CLI | TODO
Plasma 5 (Qt Build) | Test | Test | Test | Test | Test | Test | Test | Test, no CLI | FIXME
MATE | OK | OK | OK | Test | OK | OK | OK | OK, no CLI | TODO
Trinity | Test | Test | Test | Test | OK | OK | Test | Test | TODO
GNOME Shell (3.x) | OK | OK | OK | Test | OK | OK | Test | OK, no CLI | OK
Unity | Test | Test | Test | Test | Test | Test | Test | OK, no CLI | TODO
Enlightenment | Test | Test | OK | OK | OK | OK | Test | OK, no CLI | TODO
LXQt | Test | Test | Test | Test | OK | OK | Test | OK, no CLI | TODO
LXDE | OK | OK | OK | OK | OK | OK | Test | OK, no CLI | TODO
Razor-qt | OK | OK | OK | OK | OK | OK | OK | OK, no CLI | TODO
Haiku | OK | OK | N/A | N/A | OK | N/A | Test | TODO | TODO
Cinnamon | OK | OK | OK | OK | OK | OK | Test | OK, no CLI | TODO
Openbox | TODO (?)3 | OK | TODO (?)
Mac OS X | TODO (?)
GNOME 2 | Unsupported3
KDE 3 | Unsupported3 (use old KShutDown 1.0.x instead)

## Known Issues/FAQ

### Linux: Hibernate/Suspend does not work

If your Linux distribution supports systemd then try to install KShutdown 3.2+; otherwise install "upower" package.

As a workaround you can try to create a custom action with a `systemctl` command.

### Linux: Turn Off Computer/Restart Computer does not work

If your Linux distribution supports systemd then try to install KShutdown 3.2+; otherwise install "consolekit" package.

### Linux: "KShutdown is already running" message

If no main window (and no system tray icon) is visible, kill "kshutdown" process and try to run it again.

This may be caused by a buggy system tray implementation. You can disable it in KShutdown settings.

### Linux: Various system tray icon issues

Depending on desktop environment, KShutdown may sometimes fail to display the system tray icon correctly.

### Windows: No system tray icon

Sometimes the system tray icon may disappear randomly. Press Ctrl+Shift+Esc, end `kshutdown.exe` process, and restart KShutdown.

### KShutdown 1.0.x

Some configuration and command line options in KShutdown 2.x+ may be not fully compatible with the old KShutdown 1.0.x.