1620 | 1620 |
x_set_i3_atoms();
|
1621 | 1621 |
/* Send an IPC event just in case the ws names have changed */
|
1622 | 1622 |
ipc_send_workspace_event("reload", NULL, NULL);
|
1623 | |
/* Send an update event for the barconfig just in case it has changed */
|
1624 | |
update_barconfig();
|
|
1623 |
/* Send an update event for each barconfig just in case it has changed */
|
|
1624 |
Barconfig *current;
|
|
1625 |
TAILQ_FOREACH (current, &barconfigs, configs) {
|
|
1626 |
ipc_send_barconfig_update_event(current);
|
|
1627 |
}
|
1625 | 1628 |
|
1626 | 1629 |
// XXX: default reply for now, make this a better reply
|
1627 | 1630 |
ysuccess(true);
|
|
2074 | 2077 |
* Implementation of 'bar mode dock|hide|invisible|toggle [<bar_id>]'
|
2075 | 2078 |
*
|
2076 | 2079 |
*/
|
2077 | |
static bool cmd_bar_mode(const char *bar_mode, const char *bar_id) {
|
|
2080 |
void cmd_bar_mode(I3_CMD, const char *bar_mode, const char *bar_id) {
|
2078 | 2081 |
int mode = M_DOCK;
|
2079 | 2082 |
bool toggle = false;
|
2080 | 2083 |
if (strcmp(bar_mode, "dock") == 0)
|
|
2087 | 2090 |
toggle = true;
|
2088 | 2091 |
else {
|
2089 | 2092 |
ELOG("Unknown bar mode \"%s\", this is a mismatch between code and parser spec.\n", bar_mode);
|
2090 | |
return false;
|
2091 | |
}
|
2092 | |
|
2093 | |
bool changed_sth = false;
|
|
2093 |
assert(false);
|
|
2094 |
}
|
|
2095 |
|
2094 | 2096 |
Barconfig *current = NULL;
|
2095 | 2097 |
TAILQ_FOREACH (current, &barconfigs, configs) {
|
2096 | |
if (bar_id && strcmp(current->id, bar_id) != 0)
|
|
2098 |
if (strcmp(current->id, bar_id) != 0) {
|
2097 | 2099 |
continue;
|
2098 | |
|
2099 | |
if (toggle)
|
|
2100 |
}
|
|
2101 |
|
|
2102 |
if (toggle) {
|
2100 | 2103 |
mode = (current->mode + 1) % 2;
|
2101 | |
|
2102 | |
DLOG("Changing bar mode of bar_id '%s' to '%s (%d)'\n", current->id, bar_mode, mode);
|
2103 | |
current->mode = mode;
|
2104 | |
changed_sth = true;
|
2105 | |
|
2106 | |
if (bar_id)
|
2107 | |
break;
|
2108 | |
}
|
2109 | |
|
2110 | |
if (bar_id && !changed_sth) {
|
2111 | |
DLOG("Changing bar mode of bar_id %s failed, bar_id not found.\n", bar_id);
|
2112 | |
return false;
|
2113 | |
}
|
2114 | |
|
2115 | |
return true;
|
|
2104 |
}
|
|
2105 |
|
|
2106 |
DLOG("Changing bar mode of bar_id '%s' from '%d' to '%s (%d)'\n",
|
|
2107 |
current->id, current->mode, bar_mode, mode);
|
|
2108 |
if ((int)current->mode != mode) {
|
|
2109 |
current->mode = mode;
|
|
2110 |
ipc_send_barconfig_update_event(current);
|
|
2111 |
}
|
|
2112 |
|
|
2113 |
ysuccess(true);
|
|
2114 |
return;
|
|
2115 |
}
|
|
2116 |
|
|
2117 |
yerror("Changing bar mode of bar_id %s failed, bar_id not found.\n", bar_id);
|
2116 | 2118 |
}
|
2117 | 2119 |
|
2118 | 2120 |
/*
|
2119 | 2121 |
* Implementation of 'bar hidden_state hide|show|toggle [<bar_id>]'
|
2120 | 2122 |
*
|
2121 | 2123 |
*/
|
2122 | |
static bool cmd_bar_hidden_state(const char *bar_hidden_state, const char *bar_id) {
|
|
2124 |
void cmd_bar_hidden_state(I3_CMD, const char *bar_hidden_state, const char *bar_id) {
|
2123 | 2125 |
int hidden_state = S_SHOW;
|
2124 | 2126 |
bool toggle = false;
|
2125 | 2127 |
if (strcmp(bar_hidden_state, "hide") == 0)
|
|
2130 | 2132 |
toggle = true;
|
2131 | 2133 |
else {
|
2132 | 2134 |
ELOG("Unknown bar state \"%s\", this is a mismatch between code and parser spec.\n", bar_hidden_state);
|
2133 | |
return false;
|
2134 | |
}
|
2135 | |
|
2136 | |
bool changed_sth = false;
|
|
2135 |
assert(false);
|
|
2136 |
}
|
|
2137 |
|
2137 | 2138 |
Barconfig *current = NULL;
|
2138 | 2139 |
TAILQ_FOREACH (current, &barconfigs, configs) {
|
2139 | |
if (bar_id && strcmp(current->id, bar_id) != 0)
|
|
2140 |
if (strcmp(current->id, bar_id) != 0) {
|
2140 | 2141 |
continue;
|
2141 | |
|
2142 | |
if (toggle)
|
|
2142 |
}
|
|
2143 |
|
|
2144 |
if (toggle) {
|
2143 | 2145 |
hidden_state = (current->hidden_state + 1) % 2;
|
2144 | |
|
2145 | |
DLOG("Changing bar hidden_state of bar_id '%s' to '%s (%d)'\n", current->id, bar_hidden_state, hidden_state);
|
2146 | |
current->hidden_state = hidden_state;
|
2147 | |
changed_sth = true;
|
2148 | |
|
2149 | |
if (bar_id)
|
2150 | |
break;
|
2151 | |
}
|
2152 | |
|
2153 | |
if (bar_id && !changed_sth) {
|
2154 | |
DLOG("Changing bar hidden_state of bar_id %s failed, bar_id not found.\n", bar_id);
|
2155 | |
return false;
|
2156 | |
}
|
2157 | |
|
2158 | |
return true;
|
2159 | |
}
|
2160 | |
|
2161 | |
/*
|
2162 | |
* Implementation of 'bar (hidden_state hide|show|toggle)|(mode dock|hide|invisible|toggle) [<bar_id>]'
|
2163 | |
*
|
2164 | |
*/
|
2165 | |
void cmd_bar(I3_CMD, const char *bar_type, const char *bar_value, const char *bar_id) {
|
2166 | |
bool ret;
|
2167 | |
if (strcmp(bar_type, "mode") == 0)
|
2168 | |
ret = cmd_bar_mode(bar_value, bar_id);
|
2169 | |
else if (strcmp(bar_type, "hidden_state") == 0)
|
2170 | |
ret = cmd_bar_hidden_state(bar_value, bar_id);
|
2171 | |
else {
|
2172 | |
ELOG("Unknown bar option type \"%s\", this is a mismatch between code and parser spec.\n", bar_type);
|
2173 | |
ret = false;
|
2174 | |
}
|
2175 | |
|
2176 | |
ysuccess(ret);
|
2177 | |
if (!ret)
|
2178 | |
return;
|
2179 | |
|
2180 | |
update_barconfig();
|
|
2146 |
}
|
|
2147 |
|
|
2148 |
DLOG("Changing bar hidden_state of bar_id '%s' from '%d' to '%s (%d)'\n",
|
|
2149 |
current->id, current->hidden_state, bar_hidden_state, hidden_state);
|
|
2150 |
if ((int)current->hidden_state != hidden_state) {
|
|
2151 |
current->hidden_state = hidden_state;
|
|
2152 |
ipc_send_barconfig_update_event(current);
|
|
2153 |
}
|
|
2154 |
|
|
2155 |
ysuccess(true);
|
|
2156 |
return;
|
|
2157 |
}
|
|
2158 |
|
|
2159 |
yerror("Changing bar hidden_state of bar_id %s failed, bar_id not found.\n", bar_id);
|
2181 | 2160 |
}
|
2182 | 2161 |
|
2183 | 2162 |
/*
|