|
1 | | -# rwlogouts |
| 1 | +# rwlogout |
2 | 2 |
|
3 | | -wlougout2 is a software to help wm users shut down. |
| 3 | +A modern logout/shutdown dialog for Linux desktop environments, built with Rust and GTK4. This application provides a clean interface for system power management operations. |
4 | 4 |
|
5 | | -## BUILD |
| 5 | +## Features |
6 | 6 |
|
7 | | -Use Cargo: |
| 7 | +✨ **Modern UI Framework**: Built with [relm4](https://github.com/Relm4/Relm4) and GTK4 |
| 8 | +🔧 **Configurable**: KDL-based configuration for easy customization |
| 9 | +⌨️ **Keyboard Support**: Configurable keybindings for all actions |
| 10 | +🖱️ **Mouse Friendly**: Hover-to-focus and click interactions |
| 11 | +🏷️ **Layer Shell**: Uses gtk4-layer-shell for proper overlay display |
| 12 | +🎨 **Themeable**: CSS-based styling support |
| 13 | + |
| 14 | +## Supported Operations |
| 15 | + |
| 16 | +- **Lock** - Lock the current session |
| 17 | +- **Logout** - Terminate user session |
| 18 | +- **Shutdown** - Power off the system |
| 19 | +- **Reboot** - Restart the system |
| 20 | +- **Suspend** - Suspend to RAM |
| 21 | +- **Hibernate** - Suspend to disk |
| 22 | + |
| 23 | +## Installation |
| 24 | + |
| 25 | +### Using Cargo |
| 26 | + |
| 27 | +```bash |
| 28 | +# Install dependencies (Debian/Ubuntu) |
| 29 | +sudo apt install libgtk-4-dev libglib2.0-dev pkg-config |
| 30 | + |
| 31 | +# Install dependencies (Arch Linux) |
| 32 | +sudo pacman -S gtk4 glib2 pkg-config |
| 33 | + |
| 34 | +# Clone and build |
| 35 | +git clone https://github.com/dwapp/rwlogout.git |
| 36 | +cd rwlogout |
| 37 | +cargo build --release |
| 38 | +``` |
| 39 | + |
| 40 | +### Using Nix |
| 41 | + |
| 42 | +```bash |
| 43 | +# Build with Nix |
| 44 | +nix build |
| 45 | + |
| 46 | +# Or run directly |
| 47 | +nix run |
| 48 | +``` |
| 49 | + |
| 50 | +### Development Environment |
| 51 | + |
| 52 | +```bash |
| 53 | +# Enter development shell (Nix) |
| 54 | +nix develop |
| 55 | + |
| 56 | +# Or use traditional method |
| 57 | +nix-shell -p glib.dev pkg-config zlib cargo pango gdk-pixbuf gtk4 gtk4-layer-shell |
| 58 | +``` |
| 59 | + |
| 60 | +## Configuration |
| 61 | + |
| 62 | +The application is configured via the `layout.kdl` file using the [KDL](https://kdl.dev/) format: |
| 63 | + |
| 64 | +```kdl |
| 65 | +// Layout configuration for rwlogout |
| 66 | +button "lock" { |
| 67 | + action "loginctl lock-session" |
| 68 | + text "Lock" |
| 69 | + keybind "l" |
| 70 | +} |
| 71 | +
|
| 72 | +button "shutdown" { |
| 73 | + action "systemctl poweroff" |
| 74 | + text "Shutdown" |
| 75 | + keybind "s" |
| 76 | +} |
| 77 | +
|
| 78 | +// Add more buttons as needed... |
| 79 | +``` |
| 80 | + |
| 81 | +### Configuration Fields |
| 82 | + |
| 83 | +- **`label`**: Internal identifier for the button |
| 84 | +- **`action`**: System command to execute |
| 85 | +- **`text`**: Display text shown on the button |
| 86 | +- **`keybind`**: Single character keyboard shortcut |
| 87 | + |
| 88 | +### Environment Variables |
| 89 | + |
| 90 | +Commands support environment variable expansion: |
| 91 | +- `$USER` - Current username |
| 92 | +- Standard shell environment variables |
| 93 | + |
| 94 | +## Usage |
| 95 | + |
| 96 | +### Running the Application |
8 | 97 |
|
9 | 98 | ```bash |
10 | | -nix-shell -p glib.dev pkg-config zlib cargo pango gdk-pixbuf gtk4 |
| 99 | +# Run directly |
11 | 100 | cargo run |
| 101 | + |
| 102 | +# Or run the built binary |
| 103 | +./target/release/rwlogout |
12 | 104 | ``` |
13 | | -Use Nix: |
| 105 | + |
| 106 | +### Keyboard Shortcuts |
| 107 | + |
| 108 | +- **L** - Lock screen |
| 109 | +- **E** - Logout |
| 110 | +- **S** - Shutdown |
| 111 | +- **R** - Reboot |
| 112 | +- **U** - Suspend |
| 113 | +- **H** - Hibernate |
| 114 | +- **Escape** - Exit application |
| 115 | + |
| 116 | +### Mouse Interaction |
| 117 | + |
| 118 | +- **Click** - Execute the button's action |
| 119 | +- **Hover** - Automatically focus the button |
| 120 | +- **Background Click** - Exit application |
| 121 | + |
| 122 | +## Architecture |
| 123 | + |
| 124 | +The application uses a modern Rust architecture: |
| 125 | + |
| 126 | +- **relm4**: Reactive GUI framework built on GTK4 |
| 127 | +- **KDL**: Human-friendly configuration format |
| 128 | +- **gtk4-layer-shell**: Wayland layer shell support for overlay display |
| 129 | +- **Dynamic UI**: Buttons generated from configuration file |
| 130 | + |
| 131 | +### Key Components |
14 | 132 |
|
15 | 133 | ``` |
16 | | -nix build --no-update-lock-file |
| 134 | +src/ |
| 135 | +├── main.rs # Main application and UI logic |
| 136 | +├── config.rs # Configuration parsing and command execution |
| 137 | +└── style.css # UI styling |
| 138 | +layout.kdl # Button configuration |
17 | 139 | ``` |
18 | 140 |
|
19 | | -## TODO |
| 141 | +## Styling |
| 142 | + |
| 143 | +The application supports CSS-based theming via `src/style.css`. You can customize: |
| 144 | + |
| 145 | +- Button appearance and colors |
| 146 | +- Layout spacing and sizing |
| 147 | +- Hover and focus effects |
| 148 | +- Font and typography |
| 149 | + |
| 150 | +## Wayland Support |
| 151 | + |
| 152 | +The application uses gtk4-layer-shell for proper integration with Wayland compositors. It will: |
| 153 | + |
| 154 | +- Display as an overlay on all screens |
| 155 | +- Grab keyboard focus when shown |
| 156 | +- Handle layer shell protocols correctly |
| 157 | + |
| 158 | +On X11 systems, it falls back to standard fullscreen window behavior. |
| 159 | + |
| 160 | +## Development |
| 161 | + |
| 162 | +### Architecture Overview |
| 163 | + |
| 164 | +The application follows the Model-View-Update (MVU) pattern via relm4: |
| 165 | + |
| 166 | +1. **Model**: Application state and configuration |
| 167 | +2. **View**: Declarative UI definition |
| 168 | +3. **Update**: Message handling for user interactions |
| 169 | + |
| 170 | +### Key Features |
| 171 | + |
| 172 | +- **Dynamic UI Generation**: Buttons are created based on configuration |
| 173 | +- **Message-Driven**: All interactions go through the message system |
| 174 | +- **Automatic Cleanup**: Application exits after executing commands |
| 175 | + |
| 176 | +### Contributing |
| 177 | + |
| 178 | +1. Fork the repository |
| 179 | +2. Create a feature branch |
| 180 | +3. Make your changes |
| 181 | +4. Test thoroughly |
| 182 | +5. Submit a pull request |
| 183 | + |
| 184 | +## Similar Projects |
| 185 | + |
| 186 | +- [wlogout](https://github.com/ArtsyMacaw/wlogout) - Original inspiration |
| 187 | +- [wleave](https://github.com/AMNatty/wleave) - Alternative Wayland logout menu |
| 188 | +- [pwrmenu](https://github.com/kamilernerd/pwrmenu) - Power menu for window managers |
| 189 | +- [rlogout](https://github.com/MarcusBoay/rlogout) - Rust-based logout utility |
20 | 190 |
|
21 | | -- [x] shutdown |
22 | | -- [x] logout |
23 | | -- [x] reboot |
24 | | -- [x] hibernate |
25 | | -- [x] sleep |
26 | | -- [ ] optimize GUI |
27 | | -- [ ] systemd unit |
| 191 | +## License |
28 | 192 |
|
29 | | -[info](https://www.reddit.com/r/rust/comments/ec59eg/new_rust_library_to_shut_down_reboot_or_log_out/) |
| 193 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
30 | 194 |
|
| 195 | +## Acknowledgments |
31 | 196 |
|
32 | | -## Similar projects |
| 197 | +- Built with [relm4](https://github.com/Relm4/Relm4) reactive GUI framework |
| 198 | +- Uses [KDL](https://kdl.dev/) for configuration |
| 199 | +- Inspired by the original [wlogout](https://github.com/ArtsyMacaw/wlogout) project |
33 | 200 |
|
34 | | -- [wlogout](https://github.com/ArtsyMacaw/wlogout) |
35 | | -- [wleave](https://github.com/AMNatty/wleave) |
36 | | -- [pwrmenu](https://github.com/kamilernerd/pwrmenu) |
37 | | -- [rlogout](https://github.com/MarcusBoay/rlogout) |
| 201 | +--- |
38 | 202 |
|
39 | | -> This project is only used as a practice for learning rust and gtk |
| 203 | +> This project serves as both a practical utility and a learning exercise for Rust and modern GTK4 development. |
0 commit comments