On 2015-06-16 1902, Nicolas Bercher wrote:
>  why and/or "switch to workspace by name" and "move window to
>  workspace by name" are not implemented?
>  (namely M-t <wpname> / M-S-t <wpname> under wmii.)

Hi Nicholas,

You can use i3-msg to do this from the command line. I use a
combination of i3-msg and dmenu to do this.

I wrote a script (ws_menu.rb) that finds the names of all workspaces
on DisplayPort-1, and lists them in dmenu, and when I type the name of
a workspace it switches to that one. If I type a name which is not
currently a workspace, then it creates a new workspace with that name
on DisplayPort-1.

You simply write this in your i3 config:
bindsym $mod+f exec /home/kareem/script/ws_menu.rb

And here is the script:

#!/usr/bin/env ruby

require 'json'

# Get workspaces on a particular output
workspaces = JSON.parse `i3-msg -t get_workspaces`
workspaces.select! {|ws| ws['output'] == "DisplayPort-1"}

# Build string of names
names = workspaces.map {|ws| ws['name']}
names = names.inject("") {|acc, e| e + "\n" + acc}

result = `echo "#{names}" | dmenu -p "Select Workspace:"`

if names.include? result
  exec "i3-msg -t command workspace #{result}"
  system "i3-msg -t command workspace new"
  exec "i3-msg -t command rename workspace to #{result}"

Hope this helps


Reply via email to