Browse Source

PSR 2 compliance

master
Simon Vieille 1 month ago
parent
commit
e84de66dfa
  1. 8
      bin/i3_switch_focus_container.php
  2. 3
      bin/i3_switch_window.php
  3. 8
      bin/i3_switch_workspace.php

8
bin/i3_switch_focus_container.php

@ -47,15 +47,15 @@ function getDefaultFocusWindowNumber($container)
function setFocusToWindow($window)
{
shell_exec(sprintf("i3-msg '[con_id=\"%s\"] focus'", $window->id));
shell_exec(sprintf("i3-msg '[con_id=\"%s\"] focus'", $window->id));
}
$container = getFocusedWindowContainer(getTree());
if ($container !== null) {
if (null !== $container) {
$number = getFocusWindowNumber(getDefaultFocusWindowNumber($container), count($container));
foreach ($container as $k => $window) {
foreach ($container as $k => $window) {
if ($k == $number) {
setFocusToWindow($window);
}

3
bin/i3_switch_window.php

@ -45,7 +45,7 @@ function getVisibleWorkspacesNodes(array $tree, array $workspaces): array
$nodes,
$tree['floating_nodes']
);
} elseif ($output === '__i3' && isset($tree['window'])) {
} elseif ('__i3' === $output && isset($tree['window'])) {
$nodes[] = $tree;
}
}
@ -70,7 +70,6 @@ function getVisibleWorkspacesNodes(array $tree, array $workspaces): array
foreach ($n['floating_nodes'] as $node) {
$nodes[] = $node;
}
}
}

8
bin/i3_switch_workspace.php

@ -6,7 +6,7 @@ function getOrderedWorkspaces()
$json = shell_exec('i3-msg -t get_workspaces');
$workspaces = json_decode($json);
$ordered = array();
$ordered = [];
foreach ($workspaces as $w) {
$ordered[] = $w->name;
@ -34,7 +34,7 @@ function getMoveOption()
$argv[1] = 'next';
}
return in_array($argv[1], array('next', 'previous')) ? $argv[1] : 'next';
return in_array($argv[1], ['next', 'previous']) ? $argv[1] : 'next';
}
function getNextWorkspace($workspaces)
@ -61,7 +61,7 @@ function getPreviousWorkspace($workspaces)
}
}
return $workspaces[ --$key >= 0 ? $key : $count - 1 ];
return $workspaces[--$key >= 0 ? $key : $count - 1];
}
function moveToWorkspace($workspace)
@ -70,4 +70,4 @@ function moveToWorkspace($workspace)
}
$workspaces = getOrderedWorkspaces();
moveToWorkspace(getMoveOption() === 'next' ? getNextWorkspace($workspaces) : getPreviousWorkspace($workspaces));
moveToWorkspace('next' === getMoveOption() ? getNextWorkspace($workspaces) : getPreviousWorkspace($workspaces));
Loading…
Cancel
Save