-
-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Programname and Windowname to logs #152
Open
t0mOURCSSn
wants to merge
12
commits into
kernc:master
Choose a base branch
from
t0mOURCSSn:windowname
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
40d43bf
copied modifications i made to an on older version to the current one
t0mOURCSSn 7475d35
code cleaned up. ready to test.
t0mOURCSSn 982e23f
added improved commands for finding window names. changed logging mes…
t0mOURCSSn 2a46348
Final resume:
t0mOURCSSn dc7690b
usage info now includes voice "--programinfo"
t0mOURCSSn d5bec79
fixed bug where window title got truncated
t0mOURCSSn 6126a01
Update logkeys.cc
t0mOURCSSn a037bc7
changed --programinfo flag to --window-title
t0mOURCSSn 85c8f39
Update usage.cc
t0mOURCSSn cc9510a
changed programinfo flag to window-title
t0mOURCSSn b2e44dc
Changed the command strings for slight performance improvement
t0mOURCSSn 6268cc7
moved window-info update code into EV_MAKE if clause, since we are on…
t0mOURCSSn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,8 +52,6 @@ | |
|
||
// active window id, title, name | ||
#define COMMAND_STR_AWID "xprop -root 32x '\\t$0' _NET_ACTIVE_WINDOW | cut -f 2" | ||
#define COMMAND_STR_AWTITLE "xprop -id $(" COMMAND_STR_AWID ") _NET_WM_NAME | cut -d '=' -f 2" | ||
#define COMMAND_STR_AWPNAME "xprop -id $(" COMMAND_STR_AWID ") WM_CLASS | awk '{print $4}' | sed 's:^.\\(.*\\).$:\\1:'" | ||
|
||
#define INPUT_EVENT_PATH "/dev/input/" // standard path | ||
#define DEFAULT_LOG_FILE "/var/log/logkeys.log" | ||
|
@@ -77,8 +75,8 @@ std::string execute(const char* cmd) | |
char buffer[128]; | ||
std::string result = ""; | ||
while(!feof(pipe)) | ||
if(fgets(buffer, 128, pipe) != NULL) | ||
result += buffer; | ||
if(fgets(buffer, 128, pipe) != NULL) | ||
result += buffer; | ||
pclose(pipe); | ||
return result; | ||
} | ||
|
@@ -533,11 +531,11 @@ int main(int argc, char **argv) | |
|
||
fflush(out); | ||
|
||
//// programinfo | ||
// programinfo | ||
std::string window_id; | ||
std::string old_window_id; | ||
std::string cur_process_name; | ||
std::string cur_window_name; | ||
std::string process_name; | ||
std::string window_title; | ||
std::string program_info; | ||
bool program_changed = false; | ||
|
||
|
@@ -560,15 +558,17 @@ int main(int argc, char **argv) | |
continue; | ||
} | ||
|
||
//// on processid change update program_info write '[process name] "process title" > ' | ||
//// on process title change (like firefox tabs) would be better. possibly more ressource intensive? | ||
// on processid change, update window-title write '[process name] "window title" > ' | ||
if (args.flags & FLAG_WINDOW_TITLE) { | ||
window_id = execute(COMMAND_STR_AWID); | ||
|
||
//// really ugly! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. really ugly this part! |
||
if (window_id.compare(old_window_id) != 0) { | ||
cur_process_name = execute(COMMAND_STR_AWPNAME); | ||
cur_window_name = execute(COMMAND_STR_AWTITLE); | ||
program_info = "[" + cur_process_name.erase(cur_process_name.size() - 1) + "] " + cur_window_name.erase(cur_window_name.size() - 1) + " > "; // delete newline (why are newlines) | ||
process_name = sprintf("xprop -id $(%s) 0s '\\t$1' WM_CLASS | cut -f2-", window_id.c_str()); | ||
window_title = sprintf("xprop -id $(%s) _NET_WM_NAME | cut -d'=' -f2-", window_id.c_str()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps |
||
window_title = execute(window_title.c_str()); | ||
process_name = execute(process_name.c_str()); | ||
program_info = "[" + process_name.erase(process_name.size() - 1) + "] " + window_title.erase(window_title.size() - 1) + " > "; // delete newline (why are newlines) | ||
program_changed = true; | ||
} | ||
} | ||
|
@@ -612,8 +612,6 @@ int main(int argc, char **argv) | |
} | ||
} | ||
|
||
////possible conflict if key repeated and program changed??? | ||
|
||
// on key repeat ; must check before on key press | ||
if (event.value == EV_REPEAT) { | ||
++count_repeats; | ||
|
@@ -630,7 +628,7 @@ int main(int argc, char **argv) | |
|
||
// on key press | ||
if (event.value == EV_MAKE) { | ||
// on ENTER key or Ctrl+C/Ctrl+D event append timestamp and programinfo | ||
// on ENTER key or Ctrl+C/Ctrl+D event append timestamp and window-title | ||
if (scan_code == KEY_ENTER || scan_code == KEY_KPENTER) { | ||
inc_size += newline(out, event, program_changed, program_info); | ||
} | ||
|
@@ -661,7 +659,7 @@ int main(int argc, char **argv) | |
} | ||
|
||
// update program id | ||
if (args.flags & FLAG_PROGRAMINFO) { | ||
if (args.flags & FLAG_WINDOW_TITLE) { | ||
old_window_id = window_id; | ||
program_changed = false; | ||
} | ||
|
@@ -691,4 +689,3 @@ int main(int argc, char** argv) | |
{ | ||
return logkeys::main(argc, argv); | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This spawns three new processes on each keypress. This indeed feels somewhat intensive. Did you perhaps investigate how cumbersome the use of relevant Xlib function calls would be?