fixed a bug in token to integer conversion -> spacings in the config might be smaller now

This commit is contained in:
FelixKratz 2021-08-21 15:11:52 +02:00
parent bc006b5d41
commit 026b2eda0a
5 changed files with 39 additions and 24 deletions

16
plugins/windowTitle.sh Executable file
View file

@ -0,0 +1,16 @@
#!/usr/bin/env bash
WINDOW_INFO=$(osascript -e '
global frontApp, frontAppName, windowTitle
tell application "System Events"
set frontApp to first application process whose frontmost is true
set frontAppName to name of frontApp
tell process frontAppName
tell (1st window whose value of attribute "AXMain" is true)
set windowTitle to value of attribute "AXTitle"
end tell
end tell
end tell
return {frontAppName, windowTitle}')
sketchybar -m set windowTitle label "$WINDOW_INFO"

View file

@ -85,8 +85,8 @@ sketchybar -m set vimSeparator icon_font "Hack Nerd Font:Bold:15.0"
sketchybar -m set vimSeparator icon 
sketchybar -m set vimSeparator associated_space 1
sketchybar -m set vimSeparator associated_space 2
sketchybar -m set vimSeparator icon_padding_right 15
sketchybar -m set vimSeparator icon_padding_left 15
sketchybar -m set vimSeparator icon_padding_right 20
sketchybar -m set vimSeparator icon_padding_left 20
sketchybar -m add item vimIndicator left
sketchybar -m set vimIndicator associated_space 1
@ -102,19 +102,19 @@ sketchybar -m add item clock right
sketchybar -m set clock update_freq 10
sketchybar -m set clock script "~/.config/sketchybar/plugins/clock.sh"
sketchybar -m set clock icon_font "Hack Nerd Font:Bold:17.0"
sketchybar -m set clock label_padding_left 10
sketchybar -m set clock label_padding_left 15
sketchybar -m add item mailIndicator right
# Items can be associated to multiple spaces / displays
sketchybar -m set mailIndicator associated_space 1
sketchybar -m set mailIndicator associated_space 2
sketchybar -m set mailIndicator associated_space 3
sketchybar -m set mailIndicator update_freq 10
sketchybar -m set mailIndicator update_freq 15
sketchybar -m set mailIndicator script "~/.config/sketchybar/plugins/mailIndicator.sh"
sketchybar -m set mailIndicator icon_font "Hack Nerd Font:Bold:20.0"
sketchybar -m set mailIndicator icon 
sketchybar -m set mailIndicator label_padding_left 4
sketchybar -m set mailIndicator icon_padding_left 10
sketchybar -m set mailIndicator icon_padding_left 15
sketchybar -m set mailIndicator click_script "osascript -e 'tell application \"Mail\" to activate'"
sketchybar -m add item githubIndicator right
@ -124,10 +124,11 @@ sketchybar -m set githubIndicator update_freq 1000
sketchybar -m set githubIndicator icon_font "Hack Nerd Font:Bold:18.0"
sketchybar -m set githubIndicator icon  #
sketchybar -m set githubIndicator label_padding_left 4
sketchybar -m set githubIndicator icon_padding_left 10
sketchybar -m set githubIndicator icon_padding_left 15
sketchybar -m set githubIndicator click_script "open https://github.com"
sketchybar -m subscribe githubIndicator system_woke
sketchybar -m add component graph cpu_user right 99 nospace
sketchybar -m add component graph cpu_user right 200 nospace
sketchybar -m set cpu_user script "~/.config/sketchybar/plugins/cpu_graph.sh"
sketchybar -m set cpu_user graph_color 0xffffffff
sketchybar -m set cpu_user update_freq 1
@ -136,14 +137,14 @@ sketchybar -m set cpu_user icon_font "Hack Nerd Font:Bold:17.0"
sketchybar -m set cpu_user icon 
sketchybar -m set cpu_user icon_padding_left 4
sketchybar -m add component graph cpu_sys right 99
sketchybar -m add component graph cpu_sys right 200
sketchybar -m set cpu_sys graph_color 0xff48aa2a
sketchybar -m set cpu_sys associated_space 1
sketchybar -m set cpu_sys icon_font "Hack Nerd Font:Bold:17.0"
sketchybar -m set cpu_sys icon 
sketchybar -m set cpu_sys icon_padding_left 4
sketchybar -m add component graph network_down right 99 nospace
sketchybar -m add component graph network_down right 200 nospace
sketchybar -m set network_down associated_space 3
sketchybar -m set network_down icon_font "Hack Nerd Font:Bold:17.0"
sketchybar -m set network_down icon 
@ -152,7 +153,7 @@ sketchybar -m set network_down update_freq 1
sketchybar -m set network_down graph_color 0xffffffff
sketchybar -m set network_down script "~/.config/sketchybar/plugins/network_graph.sh"
sketchybar -m add component graph network_up right 99
sketchybar -m add component graph network_up right 200
sketchybar -m set network_up icon_font "Hack Nerd Font:Bold:17.0"
sketchybar -m set network_up icon 
sketchybar -m set network_up icon_padding_left 4
@ -164,12 +165,16 @@ sketchybar -m set topmem associated_space 1
sketchybar -m set topmem script "~/.config/sketchybar/plugins/topmem.sh"
sketchybar -m set topmem update_freq 15
#sketchybar -m add component title windowTitle center
#sketchybar -m set windowTitle associated_space 3
sketchybar -m add item spotifyIndicator center
sketchybar -m set spotifyIndicator update_freq 10
sketchybar -m set spotifyIndicator script "~/.config/sketchybar/plugins/spotifyIndicator.sh"
sketchybar -m set spotifyIndicator click_script "osascript -e 'tell application \"Spotify\" to pause'"
#sketchybar -m add item windowTitle center
#sketchybar -m set windowTitle script "~/.config/sketchybar/plugins/windowTitle.sh"
#sketchybar -m subscribe windowTitle window_focus
#sketchybar -m subscribe windowTitle front_app_switched
#sketchybar -m subscribe windowTitle space_change
sketchybar -m add item topproc right
sketchybar -m set topproc associated_space 1
@ -183,7 +188,7 @@ sketchybar -m set topproc update_freq 15
#sketchybar -m add item random center
#sketchybar -m set random label test
#sketchybar -m set random click_script "~/.config/sketchybar/plugins/random.sh"
#sketchybar -m set random script "/Users/felix/.config/sketchybar/plugins/random.sh"
#sketchybar -m set random script "~/.config/sketchybar/plugins/random.sh"
#sketchybar -m subscribe random front_app_switched
#sketchybar -m subscribe random title_change
#sketchybar -m subscribe random space_change

View file

@ -175,8 +175,7 @@ int bar_get_center_length(struct bar_manager* bar_manager) {
for (int i = 0; i < bar_manager->bar_item_count; i++) {
struct bar_item* bar_item = bar_manager->bar_items[i];
if (bar_item->position == BAR_POSITION_CENTER) {
total_length += bar_item->label_line.bounds.size.width + bar_item->icon_line.bounds.size.width + bar_item->icon_spacing_right + bar_item->label_spacing_left;
// TODO: Hier fehlt definitiv noch die breite des graphen
total_length += bar_item->label_line.bounds.size.width + bar_item->icon_line.bounds.size.width + bar_item->icon_spacing_right + bar_item->label_spacing_left + (bar_item->has_graph ? bar_item->graph_data.graph_width : 0);
if (i > 0) {
total_length += bar_manager->bar_items[i-1]->label_spacing_right + bar_item->icon_spacing_left;
}

View file

@ -250,8 +250,7 @@ out:
return EVENT_SUCCESS;
}
bool is_bar_at_point(CGPoint point)
{
bool is_bar_at_point(CGPoint point) {
CGPoint window_point;
uint32_t window_id;
int window_cid;

View file

@ -102,14 +102,11 @@ static char *token_to_string(struct token token)
return result;
}
static uint32_t token_to_uint32t(struct token token)
{
uint32_t result = 0;
static uint32_t token_to_uint32t(struct token token) {
char buffer[token.length + 1];
memcpy(buffer, token.text, token.length);
buffer[token.length] = '\0';
sscanf(buffer, "%x", &result);
return result;
return strtoul(buffer, NULL, 0);
}
static float token_to_float(struct token token)
@ -220,7 +217,6 @@ static void handle_domain_add(FILE* rsp, struct token domain, char* message) {
bar_item->identifier = token_to_string(identifier);
if (strcmp(bar_item->identifier, BAR_COMPONENT_GRAPH) == 0) {
struct token width = get_token(&message);
printf("%i \n", token_to_uint32t(width));
graph_data_init(&bar_item->graph_data, token_to_uint32t(width));
if (message != NULL) {
struct token modifier = get_token(&message);