Hypr, move from xonsh to python3
This commit is contained in:
parent
b57482b98b
commit
7e81e09ca4
4 changed files with 97 additions and 54 deletions
36
hmModules/apps/hypr/scripts/changesecondary.py
Executable file
36
hmModules/apps/hypr/scripts/changesecondary.py
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env python3
|
||||
import shelve
|
||||
import copy
|
||||
|
||||
# Usage:
|
||||
# ./changesecondary.xsh
|
||||
# cycles through the secondary workspaces
|
||||
|
||||
def cyclesecondary(monitor, dbpath):
|
||||
current_secondary = ""
|
||||
|
||||
with shelve.open(dbpath) as db:
|
||||
workspaces = db.get("secondaries").copy()
|
||||
current_primary = db.get("primary")
|
||||
current_secondary = db.get("secondary")
|
||||
|
||||
if current_primary in workspaces:
|
||||
workspaces.remove(current_primary)
|
||||
|
||||
current_secondary = workspaces[
|
||||
(workspaces.index(current_secondary)+1) % len(workspaces)
|
||||
]
|
||||
db["secondary"] = current_secondary
|
||||
|
||||
# Change primary to bind
|
||||
hyprctl dispatch moveworkspacetomonitor name:@(current_secondary) $HYPR_MON_SECONDARY
|
||||
hyprctl dispatch workspace name:@(current_secondary)
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
monitor=os.environ["HYPR_MON_SECONDARY"]
|
||||
db=os.environ["HYPR_WORK_DB"]
|
||||
cyclesecondary(monitor, db)
|
||||
except KeyError:
|
||||
print("Please set HYPR_MON_PRIMARY and HYPR_WORK_DB")
|
||||
sys.exit(1)
|
||||
Loading…
Add table
Add a link
Reference in a new issue