bool KwmExecuteHotkey(modifiers Mod, CGKeyCode Keycode) { hotkey Hotkey = {}; if(HotkeyExists(Mod, Keycode, &Hotkey)) { if(KWMHotkeys.Prefix.Enabled) { CheckPrefixTimeout(); if((Hotkey.Prefixed || KWMHotkeys.Prefix.Global) && !KWMHotkeys.Prefix.Active) return false; if((Hotkey.Prefixed || KWMHotkeys.Prefix.Global) && KWMHotkeys.Prefix.Active) KWMHotkeys.Prefix.Time = std::chrono::steady_clock::now(); } if(IsHotkeyStateReqFulfilled(&Hotkey)) { if(Hotkey.Command.empty()) return true; if(Hotkey.IsSystemCommand) system(Hotkey.Command.c_str()); else KwmInterpretCommand(Hotkey.Command, 0); return true; } } return false; }
void KwmDaemonHandleConnection() { int ClientSockFD; struct sockaddr_in ClientAddr; socklen_t SinSize = sizeof(struct sockaddr); ClientSockFD = accept(KwmSockFD, (struct sockaddr*)&ClientAddr, &SinSize); if(ClientSockFD != -1) { std::string Message = KwmReadFromSocket(ClientSockFD); KwmInterpretCommand(Message, ClientSockFD); close(ClientSockFD); } }
internal void KwmExecuteHotkey(hotkey *Hotkey) { if(Hotkey->Command.empty()) return; std::vector<std::string> Commands = SplitString(Hotkey->Command, ';'); DEBUG("KwmExecuteHotkey: Number of commands " << Commands.size()); for(int CmdIndex = 0; CmdIndex < Commands.size(); ++CmdIndex) { std::string &Command = TrimString(Commands[CmdIndex]); if(!Command.empty()) { DEBUG("KwmExecuteHotkey() " << Command); if(IsPrefixOfString(Command, "exec")) KwmExecuteThreadedSystemCommand(Command); else KwmInterpretCommand(Command, 0); if(KWMHotkeys.ActiveMode->Prefix) KWMHotkeys.ActiveMode->Time = std::chrono::steady_clock::now(); } } }