-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ItzSelenux
authored and
ItzSelenux
committed
Sep 17, 2024
1 parent
b240f61
commit f82c314
Showing
12 changed files
with
328 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,56 @@ | ||
# gxcapindicator | ||
# GXCapIndicator | ||
|
||
<img src="https://raw.githubusercontent.com/ItzSelenux/ItzSelenux.github.io/main/res/projects/gxcapindicator.svg" alt="Description of Image" width="111px" /> | ||
<img src="https://raw.githubusercontent.com/ItzSelenux/ItzSelenux.github.io/main/res/projects/gxcapindicator.svg" alt="GXCapIndicator Logo" width="111px" /> | ||
|
||
**GXCapIndicator** is a simple tool for indicating the status of Caps Lock and Num Lock keys in the system tray. | ||
|
||
Simple Cap/Num lock key indicator for x11 tray | ||
## Features | ||
|
||
## Features: | ||
- [x] Monitor Caps Lock and Num Lock keys | ||
- [x] Toggle Caps Lock and Num Lock with an on-screen button | ||
- [x] Hideable indicators | ||
- [x] Adjustable update rate | ||
- [x] Wayland support (with `Evdev`) | ||
|
||
- [x] Monitor Cap/Num Keys | ||
- [x] Toggle Cap/Num Keys with a on-screen button | ||
- [x] Hiddeable indicators | ||
- [x] Choose update rate | ||
- [ ] Wayland support | ||
## Installation | ||
|
||
## Configuration | ||
|
||
| Item | Description | Possible values| Default Value| example | ||
| --- | --- | --- | --- | --- | | ||
| showcap | Enables "Caps Lock" key indicator | 0, 1 | 1 | showcap=1| | ||
| shownum | Enables "Num Lock" key indicator | 0, 1 | 1 | shownum=1 | | ||
| updrate | Set update rate | (Number) | 0 | updrate=0 | | ||
To build GXCapIndicator, choose the backend you want to use: | ||
|
||
## Build | ||
### With Evdev Backend | ||
|
||
```sh | ||
make | ||
``` | ||
make gxcapindicator | ||
|
||
### With X11 Backend | ||
|
||
```sh | ||
make WITHX11=1 | ||
``` | ||
|
||
## Backend Differences | ||
|
||
GXCapIndicator supports two backends for fetching key status: X11 and Evdev. Each backend has its own capabilities and limitations. | ||
|
||
### X11 Backend | ||
- Uses `XkbGetState` to fetch the key status. | ||
- Some options are not available: | ||
- **Initial Visual State**: Cannot set the initial visual state of Caps Lock/Num Lock (unnecessary with XkbGetState). | ||
|
||
### Evdev Backend | ||
- Uses `libinput_event_get_keyboard_event` to fetch the key status. | ||
- Some options are not available: | ||
- **Update Rate**: Polling rate is fixed and cannot be adjusted. | ||
- **Toggle Functionality**: Can't be implemented without root access. | ||
|
||
## Configuration | ||
|
||
You can configure GXCapIndicator with the integrated GUI (`settings` in indicator menu) or by editing` $HOME/.config/gxcapindicator` using the following options: | ||
|
||
| Item | Description | Possible Values | Default Value | Example | Scope | | ||
|-------------|--------------------------------------|-----------------|---------------|-------------|---------| | ||
| `showcap` | Enables the Caps Lock key indicator | `0`, `1` | `1` | `showcap=1` | All | | ||
| `shownum` | Enables the Num Lock key indicator | `0`, `1` | `1` | `shownum=1` | All | | ||
| `updrate` | Sets the update rate | (Number) | `0` | `updrate=0` | X11 | | ||
| `vcapstate` | Sets the initial visual state of Caps Lock | `0`, `1` | `0` | `vcapstate=0` | Evdev | | ||
| `vnumstate` | Sets the initial visual state of Num Lock | `0`, `1` | `0` | `vnumstate=0` | Evdev | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.1 | ||
1.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Restricted file access functions for libinput | ||
int open_restricted(const char *path, int flags, void *user_data) | ||
{ | ||
int fd = open(path, flags); | ||
if (fd < 0) | ||
{ | ||
perror("Failed to open restricted path"); | ||
} | ||
return fd < 0 ? -errno : fd; | ||
} | ||
|
||
void close_restricted(int fd, void *user_data) | ||
{ | ||
close(fd); | ||
} | ||
|
||
const struct libinput_interface interface = | ||
{ | ||
.open_restricted = open_restricted, | ||
.close_restricted = close_restricted, | ||
}; | ||
|
||
void check_udev() | ||
{ | ||
struct udev *udev = udev_new(); | ||
if (udev == NULL) | ||
{ | ||
g_error("Failed to initialize udev."); | ||
return; | ||
} | ||
|
||
libinput = libinput_udev_create_context(&interface, NULL, udev); | ||
if (!libinput) | ||
{ | ||
g_error("Failed to initialize libinput from udev."); | ||
udev_unref(udev); | ||
return; | ||
} | ||
|
||
if (libinput_udev_assign_seat(libinput, "seat0") != 0) | ||
{ | ||
g_error("Failed to set seat."); | ||
libinput_unref(libinput); | ||
udev_unref(udev); | ||
return; | ||
} | ||
} | ||
|
||
gboolean check_permissions(const gchar* group_name) | ||
{ | ||
gid_t *groups; | ||
int ngroups; | ||
struct group *grp; | ||
gid_t gid; | ||
|
||
ngroups = getgroups(0, NULL); | ||
groups = g_malloc(ngroups * sizeof(gid_t)); | ||
getgroups(ngroups, groups); | ||
|
||
grp = getgrnam(group_name); | ||
if (!grp) { | ||
g_free(groups); | ||
return FALSE; | ||
} | ||
gid = grp->gr_gid; | ||
|
||
for (int i = 0; i < ngroups; i++) { | ||
if (groups[i] == gid) { | ||
g_free(groups); | ||
return TRUE; | ||
} | ||
} | ||
|
||
g_free(groups); | ||
g_error("User is likely not in input group, please add your user to input group or compile this program with -DWITHX11 if you're running X11"); | ||
return FALSE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
[GXCapIndicator Configuration File, place default on /etc/gxcapindicator.conf] | ||
[GXCapIndicator Configuration File] | ||
showcap=1 | ||
shownum=1 | ||
updrate=0 | ||
vcapstate=1 | ||
vnumstate=1 | ||
updrate=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.