rename spree

This commit is contained in:
FelixKratz 2021-08-13 15:58:00 +02:00
parent f28d18c265
commit 44a0156c3e
15 changed files with 75 additions and 50 deletions

View file

@ -4,8 +4,8 @@ BUILD_FLAGS = -std=c99 -Wall -DDEBUG -g -O0 -fvisibility=hidden -mmacosx-vers
BUILD_PATH = ./bin
DOC_PATH = ./doc
SMP_PATH = ./examples
SPACEBAR_SRC = ./src/manifest.m
BINS = $(BUILD_PATH)/spacebar
SKETCHYBAR_SRC = ./src/manifest.m
BINS = $(BUILD_PATH)/sketchybar
.PHONY: all clean install man
@ -18,12 +18,12 @@ stats: BUILD_FLAGS=-std=c99 -Wall -DSTATS -DNDEBUG -O2 -fvisibility=hidden -mmac
stats: clean $(BINS)
man:
asciidoctor -b manpage $(DOC_PATH)/spacebar.asciidoc -o $(DOC_PATH)/spacebar.1 && \
sed -i 's/1980-01-01/$(shell date "+%Y-%m-%d")/g' $(DOC_PATH)/spacebar.1
asciidoctor -b manpage $(DOC_PATH)/sketchybar.asciidoc -o $(DOC_PATH)/sketchybar.1 && \
sed -i 's/1980-01-01/$(shell date "+%Y-%m-%d")/g' $(DOC_PATH)/sketchybar.1
clean:
rm -rf $(BUILD_PATH)
$(BUILD_PATH)/spacebar: $(SPACEBAR_SRC)
$(BUILD_PATH)/sketchybar: $(SKETCHYBAR_SRC)
mkdir -p $(BUILD_PATH)
clang $^ $(BUILD_FLAGS) $(FRAMEWORK_PATH) $(FRAMEWORK) -o $@

0
plugins/calendarIndicator.sh Normal file → Executable file
View file

2
plugins/clock.sh Normal file → Executable file
View file

@ -1,4 +1,4 @@
#!/usr/bin/env bash
spacebar -m set clock label "$(date '+%d/%m %H:%M')"
sketchybar -m set clock label "$(date '+%d/%m %H:%M')"

View file

@ -16,7 +16,7 @@ dnd_enabled=$(
)
if [ $dnd_enabled -eq 1 ]; then
spacebar -m set dndIndicator icon 
sketchybar -m set dndIndicator icon 
else
spacebar -m set dndIndicator icon ""
sketchybar -m set dndIndicator icon ""
fi

View file

@ -1,9 +1,15 @@
#!/usr/bin/env bash
COUNT=0
COUNT=$(curl https://github.com/users/FelixKratz/contributions | grep $(date '+%Y-%m-%d') | sed -nr 's/.*data-count=\"([^"]+).*/\1/p')
echo $COUNT
if [ $COUNT -gt 0 ]; then
spacebar -m set githubIndicator icon_color 0xaa48aa2a
sketchybar -m set githubIndicator icon_color 0xff48aa2a
sketchybar -m set githubIndicator label_padding_left 4
sketchybar -m set githubIndicator label $COUNT
else
spacebar -m set githubIndicator icon_color 0xaaffffff
sketchybar -m set githubIndicator icon_color 0xaaffffff
sketchybar -m set githubIndicator label_padding_left 0
sketchybar -m set githubIndicator label ""
fi

View file

@ -3,11 +3,9 @@ RUNNING=$(osascript -e 'if application "Mail" is running then return 0')
COUNT=0
if [ $RUNNING == 0 ]; then
COUNT=$(osascript -e 'if application "Mail" is running then tell application "Mail" to return the unread count of inbox')
fi
if [ $RUNNING == 0 ] && [ $COUNT -gt 0 ]; then
echo "$COUNT | "
COUNT=$(osascript -e 'tell application "Mail" to return the unread count of inbox')
sketchybar -m set mailIndicator label "$COUNT"
else
echo " "
sketchybar -m set mailIndicator label 
fi

2
plugins/power.sh Normal file → Executable file
View file

@ -1,3 +1,3 @@
#!/usr/bin/env bash
spacebar -m set powerIndicator label $(pmset -g batt)
sketchybar -m set powerIndicator label $(pmset -g batt)

View file

@ -15,10 +15,10 @@ if [ "$(osascript -e 'if application "Spotify" is running then tell application
fi
if [ $RUNNING -eq 0 ] && [ $PLAYING -eq 0 ]; then
if [ "$ARTIST" == "" ]; then
echo "$TRACK$ALBUM"
sketchybar -m set spotifyIndicator label "$TRACK$ALBUM"
else
echo "$TRACK$ARTIST"
sketchybar -m set spotifyIndicator label "$TRACK$ARTIST"
fi
else
echo " "
sketchybar -m set spotifyIndicator label ""
fi

10
plugins/topmem.sh Executable file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env bash
TOPMEM=$(ps axo "rss,ucomm" | sort -nr | tail +1 | head -n1 | awk '{printf "%.0fMB %s\n", $1 / 1024, $2}' | sed -e 's/com.apple.//g')
MEM=$(echo $TOPMEM | sed -nr 's/([^MB]+).*/\1/p')
if [ $MEM -gt 2048 ]; then
sketchybar -m set topmem label "$TOPMEM"
else
sketchybar -m set topmem label ""
fi

11
plugins/topproc.sh Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env bash
TOPPROC=$(ps axo "%cpu,ucomm" | sort -nr | tail +1 | head -n1 | awk '{printf "%.0f%% %s\n", $1, $2}' | sed -e 's/com.apple.//g')
CPUP=$(echo $TOPPROC | sed -nr 's/([^\%]+).*/\1/p')
if [ $CPUP -gt 75 ]; then
sketchybar -m set topproc label "$TOPPROC"
else
sketchybar -m set topproc label ""
fi

View file

@ -132,8 +132,8 @@ bool event_loop_init(struct event_loop *event_loop)
#ifdef STATS
setlocale(LC_ALL, ""); // For fprintf digit grouping
#endif
event_loop->semaphore = sem_open("spacebar_event_loop_semaphore", O_CREAT, 0600, 0);
sem_unlink("spacebar_event_loop_semaphore");
event_loop->semaphore = sem_open("skybar_event_loop_semaphore", O_CREAT, 0600, 0);
sem_unlink("skybar_event_loop_semaphore");
return event_loop->semaphore != SEM_FAILED;
}

View file

@ -68,4 +68,4 @@
#include "bar_manager.c"
#include "application_manager.c"
#include "spacebar.c"
#include "sketchybar.c"

View file

@ -13,11 +13,11 @@ extern bool g_verbose;
// TODO: Rewrite these horrible interfaces
#define DOMAIN_ADD "add"
// Syntax: spacebar -m add item <name> <position>
// Syntax: sketchybar -m add item <name> <position>
#define COMMAND_ADD_ITEM "item"
// Syntax: spacebar -m add component <identifier> <name> <position>
// Syntax: sketchybar -m add component <identifier> <name> <position>
#define COMMAND_ADD_COMPONENT "component"
// Syntax: spacebar -m add plugin <identifier> <name> <position>
// Syntax: sketchybar -m add plugin <identifier> <name> <position>
#define COMMAND_ADD_PLUGIN "plugin"
#define DOMAIN_SET "set"
@ -26,7 +26,7 @@ extern bool g_verbose;
/* --------------------------------DOMAIN SET-------------------------------- */
// Syntax: spacebar -m set <name> <property> <value>
// Syntax: sketchybar -m set <name> <property> <value>
#define COMMAND_SET_POSITION "position"
#define COMMAND_SET_ASSOCIATED_DISPLAY "associated_display"
#define COMMAND_SET_ASSOCIATED_SPACE "associated_space"
@ -138,7 +138,7 @@ static void daemon_fail(FILE *rsp, char *fmt, ...)
view_flush(view); \
}
// Syntax: spacebar -m add <item|component|plugin> (<identifier>) <name> <position>
// Syntax: sketchybar -m add <item|component|plugin> (<identifier>) <name> <position>
static void handle_domain_add(FILE* rsp, struct token domain, char* message) {
struct token command = get_token(&message);
struct token name;
@ -175,7 +175,7 @@ static void handle_domain_add(FILE* rsp, struct token domain, char* message) {
bar_manager_refresh(&g_bar_manager);
}
// Syntax: spacebar -m set <name> <property> <value>
// Syntax: sketchybar -m set <name> <property> <value>
static void handle_domain_set(FILE* rsp, struct token domain, char* message) {
struct token name = get_token(&message);
struct token property = get_token(&message);

View file

@ -8,7 +8,7 @@ static NSImage *g_notify_img;
- (NSString *)fake_bundleIdentifier
{
if (self == [NSBundle mainBundle]) {
return @"ae.cmacr.spacebar";
return @"de.fk.sketchybar";
} else {
return [self fake_bundleIdentifier];
}
@ -35,7 +35,7 @@ static void notify(const char *subtitle, const char *format, ...)
va_list args;
va_start(args, format);
NSUserNotification *notification = [[NSUserNotification alloc] init];
notification.title = @"spacebar";
notification.title = @"sketchybar";
notification.subtitle = [NSString stringWithUTF8String:subtitle];
notification.informativeText = [[[NSString alloc] initWithFormat:[NSString stringWithUTF8String:format] arguments:args] autorelease];
[notification setValue:g_notify_img forKey:@"_identityImage"];

View file

@ -1,5 +1,5 @@
#define SOCKET_PATH_FMT "/tmp/spacebar_%s.socket"
#define LCFILE_PATH_FMT "/tmp/spacebar_%s.lock"
#define SOCKET_PATH_FMT "/tmp/sketchybar_%s.socket"
#define LCFILE_PATH_FMT "/tmp/sketchybar_%s.lock"
#define CLIENT_OPT_LONG "--message"
#define CLIENT_OPT_SHRT "-m"
@ -12,7 +12,7 @@
#define CONFIG_OPT_SHRT "-c"
#define MAJOR 1
#define MINOR 3
#define MINOR 0
#define PATCH 0
extern int SLSMainConnectionID(void);
@ -38,12 +38,12 @@ bool g_verbose;
static int client_send_message(int argc, char **argv)
{
if (argc <= 1) {
error("spacebar-msg: no arguments given! abort..\n");
error("sketchybar-msg: no arguments given! abort..\n");
}
char *user = getenv("USER");
if (!user) {
error("spacebar-msg: 'env USER' not set! abort..\n");
error("sketchybar-msg: 'env USER' not set! abort..\n");
}
int sockfd;
@ -51,7 +51,7 @@ static int client_send_message(int argc, char **argv)
snprintf(socket_file, sizeof(socket_file), SOCKET_PATH_FMT, user);
if (!socket_connect_un(&sockfd, socket_file)) {
error("spacebar-msg: failed to connect to socket..\n");
error("sketchybar-msg: failed to connect to socket..\n");
}
int message_length = argc;
@ -73,7 +73,7 @@ static int client_send_message(int argc, char **argv)
*temp++ = '\0';
if (!socket_write_bytes(sockfd, message, message_length)) {
error("spacebar-msg: failed to send data..\n");
error("sketchybar-msg: failed to send data..\n");
}
shutdown(sockfd, SHUT_WR);
@ -113,7 +113,7 @@ static void acquire_lockfile(void)
{
int handle = open(g_lock_file, O_CREAT | O_WRONLY, 0600);
if (handle == -1) {
error("spacebar: could not create lock-file! abort..\n");
error("sketchybar: could not create lock-file! abort..\n");
}
struct flock lockfd = {
@ -125,7 +125,7 @@ static void acquire_lockfile(void)
};
if (fcntl(handle, F_SETLK, &lockfd) == -1) {
error("spacebar: could not acquire lock-file! abort..\n");
error("sketchybar: could not acquire lock-file! abort..\n");
}
}
@ -133,14 +133,14 @@ static bool get_config_file(char *restrict filename, char *restrict buffer, int
{
char *xdg_home = getenv("XDG_CONFIG_HOME");
if (xdg_home && *xdg_home) {
snprintf(buffer, buffer_size, "%s/spacebar/%s", xdg_home, filename);
snprintf(buffer, buffer_size, "%s/sketchybar/%s", xdg_home, filename);
if (file_exists(buffer)) return true;
}
char *home = getenv("HOME");
if (!home) return false;
snprintf(buffer, buffer_size, "%s/.config/spacebar/%s", home, filename);
snprintf(buffer, buffer_size, "%s/.config/sketchybar/%s", home, filename);
if (file_exists(buffer)) return true;
snprintf(buffer, buffer_size, "%s/.%s", home, filename);
@ -149,7 +149,7 @@ static bool get_config_file(char *restrict filename, char *restrict buffer, int
static void exec_config_file(void)
{
if (!*g_config_file && !get_config_file("spacebarrc", g_config_file, sizeof(g_config_file))) {
if (!*g_config_file && !get_config_file("sketchybarrc", g_config_file, sizeof(g_config_file))) {
notify("configuration", "could not locate config file..");
return;
}
@ -176,7 +176,7 @@ static inline void init_misc_settings(void)
{
char *user = getenv("USER");
if (!user) {
error("spacebar: 'env USER' not set! abort..\n");
error("sketchybar: 'env USER' not set! abort..\n");
}
snprintf(g_socket_file, sizeof(g_socket_file), SOCKET_PATH_FMT, user);
@ -199,7 +199,7 @@ static void parse_arguments(int argc, char **argv)
{
if ((string_equals(argv[1], VERSION_OPT_LONG)) ||
(string_equals(argv[1], VERSION_OPT_SHRT))) {
fprintf(stdout, "spacebar-v%d.%d.%d\n", MAJOR, MINOR, PATCH);
fprintf(stdout, "sketchybar-v%d.%d.%d\n", MAJOR, MINOR, PATCH);
exit(EXIT_SUCCESS);
}
@ -217,10 +217,10 @@ static void parse_arguments(int argc, char **argv)
} else if ((string_equals(opt, CONFIG_OPT_LONG)) ||
(string_equals(opt, CONFIG_OPT_SHRT))) {
char *val = i < argc - 1 ? argv[++i] : NULL;
if (!val) error("spacebar: option '%s|%s' requires an argument!\n", CONFIG_OPT_LONG, CONFIG_OPT_SHRT);
if (!val) error("sketchybar: option '%s|%s' requires an argument!\n", CONFIG_OPT_LONG, CONFIG_OPT_SHRT);
snprintf(g_config_file, sizeof(g_config_file), "%s", val);
} else {
error("spacebar: '%s' is not a valid option!\n", opt);
error("sketchybar: '%s' is not a valid option!\n", opt);
}
}
}
@ -232,18 +232,18 @@ int main(int argc, char **argv)
}
if (is_root()) {
error("spacebar: running as root is not allowed! abort..\n");
error("sketchybar: running as root is not allowed! abort..\n");
}
if (!ax_privilege()) {
error("spacebar: could not access accessibility features! abort..\n");
error("sketchybar: could not access accessibility features! abort..\n");
}
init_misc_settings();
acquire_lockfile();
if (!event_loop_init(&g_event_loop)) {
error("spacebar: could not initialize event_loop! abort..\n");
error("sketchybar: could not initialize event_loop! abort..\n");
}
process_manager_init(&g_process_manager);
@ -260,7 +260,7 @@ int main(int argc, char **argv)
SLSRegisterConnectionNotifyProc(g_connection, connection_handler, 1204, NULL);
if (!socket_daemon_begin_un(&g_daemon, g_socket_file, message_handler)) {
error("spacebar: could not initialize daemon! abort..\n");
error("sketchybar: could not initialize daemon! abort..\n");
}
exec_config_file();