🔁 Scroll Workspace XFCE dengan Mouse Scroll + Super (Cara Cepat dan Efisien)
Tutorial ini menjelaskan cara tercepat mengatur scroll antar workspace (virtual desktop) di XFCE dengan menekan tombol Super + Scroll Mouse.
✅ 1. Pasang Paket yang Dibutuhkan
sudo apt install sxhkd libx11-dev libxtst-dev
✅ 2. Buat Konfigurasi sxhkdrc
mkdir -p ~/.config/sxhkd
nano ~/.config/sxhkd/sxhkdrc
Isi file:
# Scroll workspace kiri
super + button4
~/.script/workspace_scroll right
# Scroll workspace kanan
super + button5
~/.script/workspace_scroll left
🛠️ 3. Buat Program C untuk Menggeser Workspace
nano workspace_scroll.c
Isi file workspace_scroll.c:
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <stdio.h>
#include <stdlib.h>
int get_current_desktop(Display *dpy) {
Atom actual_type;
int actual_format;
unsigned long nitems, bytes_after;
unsigned char *data = NULL;
Atom _NET_CURRENT_DESKTOP = XInternAtom(dpy, "_NET_CURRENT_DESKTOP", True);
if (XGetWindowProperty(dpy, DefaultRootWindow(dpy),
_NET_CURRENT_DESKTOP, 0, 1, False,
XA_CARDINAL, &actual_type, &actual_format,
&nitems, &bytes_after, &data) == Success && data) {
int current = *(unsigned long *)data;
XFree(data);
return current;
}
return -1;
}
int get_num_desktops(Display *dpy) {
Atom actual_type;
int actual_format;
unsigned long nitems, bytes_after;
unsigned char *data = NULL;
Atom _NET_NUMBER_OF_DESKTOPS = XInternAtom(dpy, "_NET_NUMBER_OF_DESKTOPS", True);
if (XGetWindowProperty(dpy, DefaultRootWindow(dpy),
_NET_NUMBER_OF_DESKTOPS, 0, 1, False,
XA_CARDINAL, &actual_type, &actual_format,
&nitems, &bytes_after, &data) == Success && data) {
int total = *(unsigned long *)data;
XFree(data);
return total;
}
return -1;
}
void set_desktop(Display *dpy, int desktop) {
XEvent ev;
Atom _NET_CURRENT_DESKTOP = XInternAtom(dpy, "_NET_CURRENT_DESKTOP", False);
ev.xclient.type = ClientMessage;
ev.xclient.serial = 0;
ev.xclient.send_event = True;
ev.xclient.message_type = _NET_CURRENT_DESKTOP;
ev.xclient.window = DefaultRootWindow(dpy);
ev.xclient.format = 32;
ev.xclient.data.l[0] = desktop;
ev.xclient.data.l[1] = CurrentTime;
XSendEvent(dpy, DefaultRootWindow(dpy), False,
SubstructureNotifyMask | SubstructureRedirectMask, &ev);
XFlush(dpy);
}
int main(int argc, char *argv[]) {
if (argc != 2) {
fprintf(stderr, "Usage: %s [left|-1|right|1]\n", argv[0]);
return 1;
}
Display *dpy = XOpenDisplay(NULL);
if (!dpy) {
fprintf(stderr, "Failed to open display\n");
return 1;
}
int current = get_current_desktop(dpy);
int total = get_num_desktops(dpy);
int new = current;
if ((argv[1][0] == 'l' || argv[1][0] == '-') && current > 0)
new = current - 1;
else if ((argv[1][0] == 'r' || argv[1][0] == '+') && current < total - 1)
new = current + 1;
if (new != current)
set_desktop(dpy, new);
XCloseDisplay(dpy);
return 0;
}
🔧 4. Compile dan Pindahkan
gcc -o workspace_scroll workspace_scroll.c -lX11 -lXtst
mkdir -p ~/.script
mv workspace_scroll ~/.script/
⚙️ 5. Autostart sxhkd (Cara GUI - XFCE)
- Buka: Settings → Session and Startup → Application Autostart
- Klik tombol Add
- Isi sebagai berikut:
- Name: sxhkd
- Command: sxhkd
- Comment: Fast scroll workspace
🎉 Selesai!
Sekarang Anda bisa menekan tombol Super + Scroll Up atau Super + Scroll Down untuk berpindah workspace di XFCE seperti di tiling WM.