10bbfda8aSnia/* 20bbfda8aSnia * Copyright 1992 Claude Lecommandeur. 30bbfda8aSnia */ 40bbfda8aSnia 50bbfda8aSnia#include <stdio.h> 60bbfda8aSnia#include <stdlib.h> 70bbfda8aSnia#include <string.h> 80bbfda8aSnia 90bbfda8aSnia#include <X11/Xlib.h> 100bbfda8aSnia#include <X11/Xatom.h> 110bbfda8aSnia 120bbfda8aSniaAtom _XA_WM_CURRENTWORKSPACE, _XA_WM_OCCUPATION; 130bbfda8aSniaDisplay *dpy; 140bbfda8aSnia 150bbfda8aSniavoid gotoWorkspace(char *name); 160bbfda8aSniavoid changeOccupation(Window w, char *occup); 170bbfda8aSnia 180bbfda8aSniaint 190bbfda8aSniamain(int argc, char **argv) 200bbfda8aSnia{ 210bbfda8aSnia Window w; 220bbfda8aSnia 230bbfda8aSnia dpy = XOpenDisplay(NULL); 240bbfda8aSnia if(dpy == NULL) { 250bbfda8aSnia fprintf(stderr, "Can't open display\n"); 260bbfda8aSnia exit(1); 270bbfda8aSnia } 280bbfda8aSnia 290bbfda8aSnia switch(argc) { 300bbfda8aSnia case 2: 310bbfda8aSnia gotoWorkspace(argv [1]); 320bbfda8aSnia break; 330bbfda8aSnia 340bbfda8aSnia case 3: 350bbfda8aSnia sscanf(argv [1], "%x", (unsigned int *)&w); 360bbfda8aSnia changeOccupation(w, argv [2]); 370bbfda8aSnia break; 380bbfda8aSnia 390bbfda8aSnia default: 400bbfda8aSnia fprintf(stderr, "usage %s name\n", argv [0]); 410bbfda8aSnia break; 420bbfda8aSnia 430bbfda8aSnia } 440bbfda8aSnia} 450bbfda8aSnia 460bbfda8aSniavoid 470bbfda8aSniagotoWorkspace(char *name) 480bbfda8aSnia{ 490bbfda8aSnia _XA_WM_CURRENTWORKSPACE = XInternAtom(dpy, "WM_CURRENTWORKSPACE", True); 500bbfda8aSnia if(_XA_WM_CURRENTWORKSPACE == None) { 510bbfda8aSnia fprintf(stderr, "Can't get WM_CURRENTWORKSPACE atom\n"); 520bbfda8aSnia exit(1); 530bbfda8aSnia } 540bbfda8aSnia 550bbfda8aSnia XChangeProperty(dpy, RootWindow(dpy, 0), _XA_WM_CURRENTWORKSPACE, XA_STRING, 8, 560bbfda8aSnia PropModeReplace, (unsigned char *) name, strlen(name)); 570bbfda8aSnia XFlush(dpy); 580bbfda8aSnia} 590bbfda8aSnia 600bbfda8aSniavoid 610bbfda8aSniachangeOccupation(Window w, char *occup) 620bbfda8aSnia{ 630bbfda8aSnia _XA_WM_OCCUPATION = XInternAtom(dpy, "WM_OCCUPATION", True); 640bbfda8aSnia if(_XA_WM_OCCUPATION == None) { 650bbfda8aSnia fprintf(stderr, "Can't get WM_WORKSPACES atom\n"); 660bbfda8aSnia exit(1); 670bbfda8aSnia } 680bbfda8aSnia 690bbfda8aSnia XChangeProperty(dpy, w, _XA_WM_OCCUPATION, XA_STRING, 8, 700bbfda8aSnia PropModeReplace, (unsigned char *) occup, strlen(occup)); 710bbfda8aSnia XFlush(dpy); 720bbfda8aSnia} 73