Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
infra
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
James Vasile
infra
Commits
4c125f08
Commit
4c125f08
authored
4 months ago
by
James Vasile
Browse files
Options
Downloads
Patches
Plain Diff
Make Windows a UserList
parent
33865141
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/launch
+11
-9
11 additions, 9 deletions
bin/launch
with
11 additions
and
9 deletions
bin/launch
+
11
−
9
View file @
4c125f08
...
...
@@ -7,6 +7,7 @@ Run-or-raise launcher
"""
import
argparse
from
collections
import
UserList
import
i3ipc
# would that we could make this optional
import
os
from
pathlib
import
Path
...
...
@@ -265,11 +266,12 @@ class Sway():
print
(
ret
)
return
ret
class
Windows
:
class
Windows
(
UserList
)
:
wmctrl
=
None
"
Model a list of windows, regardless of whether they
'
re xwindows or wayland windows
"
def
__init__
(
self
):
self
.
windows
=
[]
UserList
.
__init__
(
self
)
self
.
data
=
[]
# UserList stores data here, but we just access via self
if
SWAY
:
self
.
sway
=
Sway
()
...
...
@@ -278,7 +280,7 @@ class Windows:
self
.
curr_desktop
=
self
.
curr_win
.
desktop
# Build a list of windows
self
.
windows
.
extend
(
self
.
sway
.
get_window_list
())
self
.
extend
(
self
.
sway
.
get_window_list
())
elif
WAYLAND
:
raise
Exception
(
"
On wayland, but not Sway. No way to get window info
"
)
...
...
@@ -293,7 +295,7 @@ class Windows:
parts
[
1
]
=
int
(
parts
[
1
])
if
parts
[
1
]
<
0
:
continue
self
.
windows
.
append
(
self
.
append
(
Window
(
parts
[
0
],
parts
[
1
],
parts
[
2
],
parts
[
3
],
"
"
.
join
(
parts
[
5
:]))
)
...
...
@@ -315,12 +317,12 @@ class Windows:
def
get_win_by_id
(
self
,
ident
:
int
)
->
list
[
Window
]:
"""
This returns a list of windows matching the id, but it shouldn
'
t. It
should return a window or None
"""
return
[
w
for
w
in
self
.
windows
if
w
.
id
==
ident
]
return
[
w
for
w
in
self
if
w
.
id
==
ident
]
def
get_win_by_class
(
self
,
wm_class
):
if
VERBOSE
:
pp
(
self
.
windows
)
return
[
w
for
w
in
self
.
windows
if
w
.
wm_class
==
wm_class
]
pp
(
self
)
return
[
w
for
w
in
self
if
w
.
wm_class
==
wm_class
]
def
get_closest_win_by_class
(
self
,
wm_class
,
skip_current
:
bool
=
True
)
->
list
:
print
(
f
"
get_closest_win_by_class:
{
wm_class
}
"
)
...
...
@@ -340,7 +342,7 @@ class Windows:
return
wins
def
get_win_by_desktop
(
self
,
desktop
):
return
[
w
for
w
in
self
.
windows
if
w
.
desktop
==
desktop
]
return
[
w
for
w
in
self
if
w
.
desktop
==
desktop
]
def
switch_to
(
self
,
win
):
Log
().
write_win
(
win
)
...
...
@@ -359,7 +361,7 @@ class Windows:
def
__str__
(
self
):
return
"
\n
"
.
join
([
str
(
w
)
for
w
in
self
.
windows
])
return
"
\n
"
.
join
([
str
(
w
)
for
w
in
self
])
class
Launcher
():
env
:
dict
[
str
,
str
]
=
{}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment