Last active
July 22, 2021 09:59
-
-
Save Sidd-Dino/ad52686bf9a9353815135bd1c696cc06 to your computer and use it in GitHub Desktop.
[berrywm] <argument> => <modifier mask value> parser
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
#include <stdio.h> | |
#include <string.h> | |
#define ShiftMask (1<<0) | |
#define LockMask (1<<1) | |
#define ControlMask (1<<2) | |
#define Mod1Mask (1<<3) | |
#define Mod2Mask (1<<4) | |
#define Mod3Mask (1<<5) | |
#define Mod4Mask (1<<6) | |
#define Mod5Mask (1<<7) | |
long | |
main(int argc, char **argv) | |
{ | |
long mask_value = 0; | |
if ( argc == 1 ) return 0; | |
char * mask_str = strtok( argv[1] , "|"); | |
while( mask_str != NULL ) { | |
if( ! strcmp(mask_str,"Shift") ) mask_value = mask_value|ShiftMask; | |
else if( ! strcmp(mask_str,"Lock") ) mask_value = mask_value|LockMask; | |
else if( ! strcmp(mask_str,"Ctrl") ) mask_value = mask_value|ControlMask; | |
else if( ! strcmp(mask_str,"Mod1") ) mask_value = mask_value|Mod1Mask; | |
else if( ! strcmp(mask_str,"Mod2") ) mask_value = mask_value|Mod1Mask; | |
else if( ! strcmp(mask_str,"Mod3") ) mask_value = mask_value|Mod2Mask; | |
else if( ! strcmp(mask_str,"Mod4") ) mask_value = mask_value|Mod3Mask; | |
else if( ! strcmp(mask_str,"Mod5") ) mask_value = mask_value|Mod4Mask; | |
mask_str = strtok(NULL, "|"); | |
} | |
printf("mask_value = %ld\n" , mask_value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment