mirror of
https://github.com/elkowar/dots-of-war.git
synced 2024-11-06 03:12:24 +00:00
eww
This commit is contained in:
parent
f1c5d20edc
commit
8ff7b16d0b
3 changed files with 93 additions and 52 deletions
|
@ -11,15 +11,15 @@
|
|||
(bottom :screen screen))))
|
||||
|
||||
(defwidget top [screen]
|
||||
(workspaces :screen screen))
|
||||
(workspaces :screen {screen == 1 ? "DP-2" : "HDMI-A-1"}))
|
||||
;(workspaces :wsp_yuck {screen == 1 ? workspaces_1_yuck : workspaces_2_yuck}))
|
||||
|
||||
(defwidget workspaces [screen]
|
||||
(box :orientation "v"
|
||||
(box :orientation "v" :class "workspaces"
|
||||
(for wsp in {workspaces[screen]}
|
||||
(button :class "${wsp.occupied ? "occupied" : "empty"} ${wsp.focused ? "active" : "inactive"}"
|
||||
(button :class "${wsp.focused ? "active" : "inactive"}"
|
||||
:onclick "swaymsg workspace ${wsp.name}"
|
||||
{wsp.occupied ? "◆" : "◇"}))))
|
||||
{wsp.name}))))
|
||||
|
||||
|
||||
;(defwidget workspaces [wsp_yuck]
|
||||
|
@ -96,7 +96,7 @@
|
|||
(defvar audio_sink "")
|
||||
|
||||
(deflisten volume :initial "0" "./audio.sh volume")
|
||||
(deflisten workspaces :initial '{"0": [], "1": []}' "./swayspaces.py")
|
||||
(deflisten workspaces :initial '{"DP-2": [], "HDMI-A-1": []}' "./swayspaces.py")
|
||||
|
||||
|
||||
(defpoll hour :interval "1s" "date +%H")
|
||||
|
|
|
@ -3,38 +3,26 @@
|
|||
import subprocess
|
||||
import json
|
||||
|
||||
WSP_COUNT = 5
|
||||
MONITOR_COUNT = 2
|
||||
|
||||
|
||||
def get_workspaces():
|
||||
output = subprocess.check_output(["swaymsg", "-t", "get_workspaces"])
|
||||
return json.loads(output.decode("utf-8"))
|
||||
|
||||
|
||||
def generate_workspace_data_for_monitor(monitor: int) -> list[dict]:
|
||||
workspaces = {w["name"]: w for w in get_workspaces()}
|
||||
data = []
|
||||
for i in range(WSP_COUNT):
|
||||
name = f"{monitor+1}{i+1}"
|
||||
wsp_data = workspaces.get(name)
|
||||
entry = {
|
||||
"name": name,
|
||||
"monitor": monitor,
|
||||
"occupied": False,
|
||||
"focused": False,
|
||||
"visible": False,
|
||||
}
|
||||
if wsp_data is not None:
|
||||
entry["focused"] = wsp_data["focused"]
|
||||
entry["visible"] = wsp_data["visible"]
|
||||
entry["occupied"] = True
|
||||
data.append(entry)
|
||||
return data
|
||||
|
||||
|
||||
def generate_workspace_data() -> dict:
|
||||
return {i: generate_workspace_data_for_monitor(i) for i in range(MONITOR_COUNT)}
|
||||
data = {}
|
||||
for wsp in get_workspaces():
|
||||
if wsp["output"] not in data:
|
||||
data[wsp["output"]] = []
|
||||
data[wsp["output"]].append(
|
||||
{
|
||||
"name": wsp["name"],
|
||||
"monitor": wsp["output"],
|
||||
"focused": wsp["focused"],
|
||||
"visible": wsp["visible"],
|
||||
}
|
||||
)
|
||||
return data
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -50,3 +38,56 @@ if __name__ == "__main__":
|
|||
line = process.stdout.readline().decode("utf-8")
|
||||
if line == "":
|
||||
break
|
||||
|
||||
# #!/usr/bin/env python3
|
||||
#
|
||||
# import subprocess
|
||||
# import json
|
||||
#
|
||||
# WSP_COUNT = 5
|
||||
# MONITOR_COUNT = 2
|
||||
#
|
||||
#
|
||||
# def get_workspaces():
|
||||
# output = subprocess.check_output(["swaymsg", "-t", "get_workspaces"])
|
||||
# return json.loads(output.decode("utf-8"))
|
||||
#
|
||||
#
|
||||
# def generate_workspace_data_for_monitor(monitor: int) -> list[dict]:
|
||||
# workspaces = {w["name"]: w for w in get_workspaces()}
|
||||
# data = []
|
||||
# for i in range(WSP_COUNT):
|
||||
# name = f"{monitor+1}{i+1}"
|
||||
# wsp_data = workspaces.get(name)
|
||||
# entry = {
|
||||
# "name": name,
|
||||
# "monitor": monitor,
|
||||
# "occupied": False,
|
||||
# "focused": False,
|
||||
# "visible": False,
|
||||
# }
|
||||
# if wsp_data is not None:
|
||||
# entry["focused"] = wsp_data["focused"]
|
||||
# entry["visible"] = wsp_data["visible"]
|
||||
# entry["occupied"] = True
|
||||
# data.append(entry)
|
||||
# return data
|
||||
#
|
||||
#
|
||||
# def generate_workspace_data() -> dict:
|
||||
# return {i: generate_workspace_data_for_monitor(i) for i in range(MONITOR_COUNT)}
|
||||
#
|
||||
#
|
||||
# if __name__ == "__main__":
|
||||
# process = subprocess.Popen(
|
||||
# ["swaymsg", "-t", "subscribe", "-m", '["workspace"]', "--raw"],
|
||||
# stdout=subprocess.PIPE,
|
||||
# )
|
||||
# if process.stdout is None:
|
||||
# print("Error: could not subscribe to sway events")
|
||||
# exit(1)
|
||||
# while True:
|
||||
# print(json.dumps(generate_workspace_data()), flush=True)
|
||||
# line = process.stdout.readline().decode("utf-8")
|
||||
# if line == "":
|
||||
# break
|
||||
|
|
|
@ -113,27 +113,27 @@ input "type:keyboard" {
|
|||
# Workspaces:
|
||||
#
|
||||
# Switch to workspace
|
||||
# bindsym $mod+1 workspace number 1
|
||||
# bindsym $mod+2 workspace number 2
|
||||
# bindsym $mod+3 workspace number 3
|
||||
# bindsym $mod+4 workspace number 4
|
||||
# bindsym $mod+5 workspace number 5
|
||||
# bindsym $mod+6 workspace number 6
|
||||
# bindsym $mod+7 workspace number 7
|
||||
# bindsym $mod+8 workspace number 8
|
||||
# bindsym $mod+9 workspace number 9
|
||||
# bindsym $mod+0 workspace number 10
|
||||
# # Move focused container to workspace
|
||||
# bindsym $mod+Shift+1 move container to workspace number 1
|
||||
# bindsym $mod+Shift+2 move container to workspace number 2
|
||||
# bindsym $mod+Shift+3 move container to workspace number 3
|
||||
# bindsym $mod+Shift+4 move container to workspace number 4
|
||||
# bindsym $mod+Shift+5 move container to workspace number 5
|
||||
# bindsym $mod+Shift+6 move container to workspace number 6
|
||||
# bindsym $mod+Shift+7 move container to workspace number 7
|
||||
# bindsym $mod+Shift+8 move container to workspace number 8
|
||||
# bindsym $mod+Shift+9 move container to workspace number 9
|
||||
# bindsym $mod+Shift+0 move container to workspace number 10
|
||||
bindsym $mod+1 workspace number 1
|
||||
bindsym $mod+2 workspace number 2
|
||||
bindsym $mod+3 workspace number 3
|
||||
bindsym $mod+4 workspace number 4
|
||||
bindsym $mod+5 workspace number 5
|
||||
bindsym $mod+6 workspace number 6
|
||||
bindsym $mod+7 workspace number 7
|
||||
bindsym $mod+8 workspace number 8
|
||||
bindsym $mod+9 workspace number 9
|
||||
bindsym $mod+0 workspace number 10
|
||||
# Move focused container to workspace
|
||||
bindsym $mod+Shift+1 move container to workspace number 1
|
||||
bindsym $mod+Shift+2 move container to workspace number 2
|
||||
bindsym $mod+Shift+3 move container to workspace number 3
|
||||
bindsym $mod+Shift+4 move container to workspace number 4
|
||||
bindsym $mod+Shift+5 move container to workspace number 5
|
||||
bindsym $mod+Shift+6 move container to workspace number 6
|
||||
bindsym $mod+Shift+7 move container to workspace number 7
|
||||
bindsym $mod+Shift+8 move container to workspace number 8
|
||||
bindsym $mod+Shift+9 move container to workspace number 9
|
||||
bindsym $mod+Shift+0 move container to workspace number 10
|
||||
# Note: workspaces can have any name you want, not just numbers.
|
||||
# We just use 1-10 as the default.
|
||||
#
|
||||
|
@ -198,7 +198,7 @@ mode "resize" {
|
|||
# }
|
||||
# }
|
||||
|
||||
include ~/.config/sway/config.d/*
|
||||
# include ~/.config/sway/config.d/*
|
||||
|
||||
# required for flameshot
|
||||
exec systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK
|
||||
|
|
Loading…
Reference in a new issue