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
e989b9f9
Commit
e989b9f9
authored
4 months ago
by
James Vasile
Browse files
Options
Downloads
Patches
Plain Diff
Handle multiple targets
parent
1c12eafc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/launch
+18
-24
18 additions, 24 deletions
bin/launch
with
18 additions
and
24 deletions
bin/launch
+
18
−
24
View file @
e989b9f9
...
...
@@ -340,12 +340,13 @@ class Windows(UserList):
print
(
f
"
get_closest_win_by_class:
{
classes
}
"
)
# Remove current window, if it's there
wins
=
[]
for
w
in
self
.
get_win_by_class
(
wm_class
):
if
VERBOSE
:
print
(
f
"
Win by class
{
wm_class
}
:
"
,
w
)
if
skip_current
and
w
.
id
==
self
.
curr_win_id
:
continue
wins
.
append
(
w
)
for
wm_class
in
classes
:
for
w
in
self
.
get_win_by_class
(
wm_class
):
if
VERBOSE
:
print
(
f
"
Win by class
{
wm_class
}
:
"
,
w
)
if
skip_current
and
w
.
id
==
self
.
curr_win_id
:
continue
wins
.
append
(
w
)
desktop
=
self
.
curr_desktop
curr
=
[
w
for
w
in
wins
if
w
.
desktop
==
desktop
and
w
.
id
!=
self
.
curr_win_id
]
...
...
@@ -382,15 +383,19 @@ class Windows(UserList):
class
Launcher
():
env
:
dict
[
str
,
str
]
=
{}
key
=
''
target
=
''
target
s
:
list
[
str
]
=
[]
launch
=
''
def
__init__
(
self
,
key
:
str
=
""
,
target
:
str
=
""
,
launch
:
str
=
""
)
->
None
:
def
__init__
(
self
,
key
:
str
=
""
,
target
s
:
Union
[
str
,
list
[
str
]]
=
[]
,
launch
:
str
=
""
)
->
None
:
self
.
key
=
key
or
self
.
key
self
.
target
=
target
or
self
.
target
self
.
target
=
self
.
target
.
split
(
'
.
'
)[
0
]
# x has the . and some more stuff. sway doesn't
if
isinstance
(
targets
,
str
):
targets
=
[
targets
]
self
.
targets
=
targets
or
self
.
targets
for
target
in
self
.
targets
:
if
"
.
"
in
target
:
self
.
targets
.
extend
(
target
.
split
(
"
.
"
))
self
.
launch
=
launch
or
self
.
launch
def
__repr__
(
self
)
->
str
:
return
(
f
"
Launcher(
{
self
.
key
}
,
{
self
.
target
}
,
{
self
.
launch
}
)
"
)
return
(
f
"
Launcher(
{
self
.
key
}
,
{
self
.
target
s
}
,
{
self
.
launch
}
)
"
)
def
__str__
(
self
)
->
str
:
return
self
.
__repr__
()
class
Launchers
(
dict
[
str
,
Launcher
]):
...
...
@@ -511,24 +516,13 @@ def main(args):
runner
.
run
()
# Non-window launcher. Only launch if not already launched.
if
'
/
'
in
launcher
.
target
:
if
'
/
'
in
launcher
.
target
s
[
0
]
:
runner
=
Runner
(
launcher
.
target
)
runner
.
already_exit
(
full
=
True
)
runner
.
run
(
launcher
.
launch
)
# try:
# subprocess.check_call(f"pgrep -fxa {launcher.target}", shell=True)
# Log().write("Already running.")
# except subprocess.CalledProcessError:
# parts = shlex.split(launcher.launch)
# subprocess.Popen(launcher.launch,
# stdout=open(f'/tmp/launch/{args[1]}.stdout.log', 'a'),
# stderr=open(f'/tmp/launch/{args[1]}.stderr.log', 'a'),
# preexec_fn=os.setpgrp,
# )
sys
.
exit
()
win
=
wins
.
get_closest_win_by_class
(
launcher
.
target
,
skip_current
=
False
)
win
=
wins
.
get_closest_win_by_class
(
launcher
.
target
s
,
skip_current
=
False
)
if
VERBOSE
:
sys
.
stdout
.
write
(
"
Closest windows by class:
"
)
pp
(
win
)
...
...
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