Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1031d5590b |
11
README.md
11
README.md
@@ -29,6 +29,7 @@ Check out [the demo](https://typofelho.ddns.net/TypoMustakes/hyprland-toggle-til
|
|||||||
Let's say you switched to tiling mode. From that point on, new windows will open in tiling mode as well.
|
Let's say you switched to tiling mode. From that point on, new windows will open in tiling mode as well.
|
||||||
Switch to floating mode again and newly opened windows will be in floating mode.
|
Switch to floating mode again and newly opened windows will be in floating mode.
|
||||||
- Floating/tiling window rules are isolated between workspaces. You can set one workspace to be floating, and all the rest to tiling for example.
|
- Floating/tiling window rules are isolated between workspaces. You can set one workspace to be floating, and all the rest to tiling for example.
|
||||||
|
- Returns applied rule for the current workspace. Useful for scripting.
|
||||||
- Useful for workflows that require both tiling and floating window management.
|
- Useful for workflows that require both tiling and floating window management.
|
||||||
- Lightweight and easy to integrate with your Hyprland setup.
|
- Lightweight and easy to integrate with your Hyprland setup.
|
||||||
|
|
||||||
@@ -75,7 +76,15 @@ or go nuts and...
|
|||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
```shell
|
```shell
|
||||||
./htt <config-file-path>
|
./htt <config-file-path> (-q)
|
||||||
|
```
|
||||||
|
- `-q`: Print the rule applied on the current workspace to STDOUT, but don't change anything. If there isn't an active rule for the current workspace, it returns a tiling rule. The returned string is a valid Hyprland window rule configuration line, like so:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
# (On workspace 2...)
|
||||||
|
$ ./htt ~/.cache/htt/rules -q
|
||||||
|
|
||||||
|
windowrule = tile on, match:workspace 2
|
||||||
```
|
```
|
||||||
- If the specified configuration file does not exist, it will be created.
|
- If the specified configuration file does not exist, it will be created.
|
||||||
- If the configuration contains existing rules, this should still work, but your existing configuration will probably get a bit messy, syntax-wise. I advise against it.
|
- If the configuration contains existing rules, this should still work, but your existing configuration will probably get a bit messy, syntax-wise. I advise against it.
|
||||||
|
|||||||
@@ -23,5 +23,6 @@ class HyprlandService {
|
|||||||
static void setClientTiled(Client&);
|
static void setClientTiled(Client&);
|
||||||
static void toggleClientFloating(Client&);
|
static void toggleClientFloating(Client&);
|
||||||
static bool isFloatingRulePresent();
|
static bool isFloatingRulePresent();
|
||||||
|
static WindowRule getActiveWorkspaceRule();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -134,4 +134,18 @@ bool HyprlandService::isFloatingRulePresent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
WindowRule HyprlandService::getActiveWorkspaceRule() {
|
||||||
|
std::list<WindowRule> rules = getWindowRules();
|
||||||
|
int id = getCurrentWorkspace().id;
|
||||||
|
|
||||||
|
for (auto& rule : rules) {
|
||||||
|
if (rule.workspaceID == id) {
|
||||||
|
return rule;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//If no rule is found, return a default rule (tiled)
|
||||||
|
return WindowRule {.tile = true, .workspaceID = id};
|
||||||
};
|
};
|
||||||
40
src/main.cpp
40
src/main.cpp
@@ -1,23 +1,37 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "../include/HyprlandService.h"
|
#include "../include/HyprlandService.h"
|
||||||
|
|
||||||
int main(int argc, char** argv){
|
void help(char* execPath) {
|
||||||
if (argc < 2) {
|
std::cerr << "Usage: " << execPath << " <config_file_path> (-q)\n\n";
|
||||||
std::cerr << "Usage: " << argv[0] << " <config_file_path>\n";
|
std::cerr << "-q:\tQuery current windowing mode, don't change anything.\n\tReturns Hyprland window rule active on current workspace.\n\tIf no rule is active, returns a default tiled rule.\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
if (argc < 2) {
|
||||||
|
help(argv[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
HyprlandService::setConfigFilePath(argv[1]);
|
HyprlandService::setConfigFilePath(argv[1]);
|
||||||
|
|
||||||
if (HyprlandService::isFloatingRulePresent()) {
|
if (argc == 3 && argv[2] == std::string("-q")) {
|
||||||
for (auto& c : HyprlandService::getClientsOnActiveWorkspace()) {
|
WindowRule rule = HyprlandService::getActiveWorkspaceRule();
|
||||||
HyprlandService::setClientTiled(c);
|
std::cout << rule.toString() << std::endl;
|
||||||
}
|
|
||||||
HyprlandService::setFloatingRule(false);
|
|
||||||
} else {
|
|
||||||
for (auto& c : HyprlandService::getClientsOnActiveWorkspace()) {
|
|
||||||
HyprlandService::setClientFloating(c);
|
|
||||||
}
|
|
||||||
HyprlandService::setFloatingRule(true);
|
|
||||||
}
|
}
|
||||||
|
else if (argc == 2) {
|
||||||
|
if (HyprlandService::isFloatingRulePresent()) {
|
||||||
|
for (auto& c : HyprlandService::getClientsOnActiveWorkspace()) {
|
||||||
|
HyprlandService::setClientTiled(c);
|
||||||
|
}
|
||||||
|
HyprlandService::setFloatingRule(false);
|
||||||
|
} else {
|
||||||
|
for (auto& c : HyprlandService::getClientsOnActiveWorkspace()) {
|
||||||
|
HyprlandService::setClientFloating(c);
|
||||||
|
}
|
||||||
|
HyprlandService::setFloatingRule(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else (help(argv[0]));
|
||||||
|
|
||||||
|
exit(0);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user