Jump to content

Yet another window layout workflow


Recommended Posts

You do it pretty much the same way that I mentioned before.

 

Look at the difference between the script filters for "lay" and "layother"

 

"lay" is

/usr/bin/python layout_select.py "{query}"

And "layother" is

/usr/bin/python layout_select.py "{query}" +1

So, if the hotkey argument for the "full" was "set:0,0,1,1" then the argument should just be "set:0,0,1,1 +1"

 

I'm not using multiple monitors, so I can't test this out. But, theoretically, that should be it.

Link to comment

Sorry, I was quite busy the last week and kind of lost track of this thread.

 

 

Thanks for the feedback, I just forgot to update the "documentation". You can now find the details of this little ":+1" here: https://github.com/untoldwind/alfred2-layout/wiki/Hacking-the-Mavericks-version

 

I also found an issue: For some reason the new Activity Monitor of Mavericks does not react to the layout events (i.e. it just won't move). I'll have to investigate a bit if there is a way to fix this.

Edited by untoldwind
Link to comment

Just pushed a new version that should fix the problem.

 

On a side note: in the Apple developer documentation ruby-cocoa and python PyObjC have both moved to legacy with a hint that Object-C is the preferred language for Cocoa applications: https://developer.apple.com/legacy/library/documentation/Cocoa/Conceptual/RubyPythonCocoa/Introduction/Introduction.html#//apple_ref/doc/uid/TP40005422-SW1

 

For the time being there should not be a problem ... but ... well ... um ...

Edited by untoldwind
Link to comment

Great workflow. I will use it to replace 'Moom'. But i have a litte feature request for the Full an Center Views. Can you please make it possible to change the value of the border. In Center it is a default of 10 % in Full view none. It like 15 % and maybe 20 px.

 

Nevertheless, your Workflow is fantastic.

 

Efty

Link to comment

Actually you can do that by yourself - more or less - easily.

 

Just open the layout_select.py with the text editor of your choice and tweak the following lines:

layouts = [
....
    Layout("full",             "Full",                         True,  "set:0,0,1,1"),
....
    Layout("center",           "Center",                       True,  "set:0.1,0.1,0.9,0.9"),

In your case to

layouts = [
....
    Layout("full",             "Full",                         True,  "set:0.01,0.01,0.99,0.99"),
....
    Layout("center",           "Center",                       True,  "set:0.15,0.15,0.85,0.85"),

(I translated the "20px" border to 1% border since the layouter just works with relative numbers at the moment.

 

The drawback is that these changes would be overwritten with the next "release". May I should add some kind of configuration (nothing fancy) were people can set their own preferences.

Link to comment

 

The drawback is that these changes would be overwritten with the next "release". May I should add some kind of configuration (nothing fancy) were people can set their own preferences.

 

Probably the easiest way to do that would be to set up a folder in the appropriate data location for your workflow and then just have a text file that can be parsed for extra arguments (with a syntax guide commented out at the top of the document). Then just setup another keyword "lay config" to open the file. If you want to make it a bit fancier, then you could also add in a "lay reset" to reset the config file in case someone accidentally breaks the document syntax.

 

s

Link to comment

I know you will hate me for this, but since I was kind of unhappy with the recent developments of Ruby's and Python's Cocoa-binding I just remembered this old comic: http://xkcd.com/224/

 

... so in short: I redid everything with Perl, which is so low level that Apple will not mess with it (hopefully). On the plus side, it is also the fastest binding.

 

An experimental version is available here: https://github.com/untoldwind/alfred2-layout/raw/master/Layout.alfredworkflow

 

New feature:

  • With "lay_config" you should now be able to edit your own configuration file (format described below)
    • Hopefully this will open the "TextEdit" if there are no other editors available (that's hard to test for me, since I have so many editors on my system)
  • If the editor does not open you can also use "lay_config" with Cmd-Enter/Cmd-Click, which should open the configuration directory in Finder.
  • If it all fails: The configuration file should be this one: ~/Library/Application Support/Alfred 2/Workflow Data/de.leanovate.alfred.layout/layout.yaml
  • Of course there is a default-version in the workflow itself (i.e. to reset the workflow to default, just remove the file above)
  • Note: The keywords are NOT merged, i.e. if you do not like some keywords, you are actually able to remove them

The configuration file itself is YAML, which should be easily understandable:

- { name: "togglefullscreen", display: "Toggle full screen mode",      forOtherScreen: No,  command: "fullscreen:toggle" }
- { name: "full",             display: "Full",                         forOtherScreen: Yes, command: "set:0,0,1,1" }
- { name: "left",             display: "Left",                         forOtherScreen: Yes, command: "set:0,0,0.5,1" }

... well lets see if it all works as intended.

 

 

PS: If this is too spooky for you (or simply not working), the previous release is still available here: https://github.com/untoldwind/alfred2-layout/raw/1.1_Mavericks/Layout.alfredworkflow (in case I forgot to update links in the previous posts)

Edited by untoldwind
Link to comment

I know you will hate me for this, but since I was kind of unhappy with the recent developments of Ruby's and Python's Cocoa-binding I just remembered this old comic: http://xkcd.com/224/

 

... so in short: I redid everything with Perl, which is so low level that Apple will not mess with it (hopefully). On the plus side, it is also the fastest binding.

 

An experimental version is available here: https://github.com/untoldwind/alfred2-layout/raw/master/Layout.alfredworkflow

 

New feature:

  • With "lay_config" you should now be able to edit your own configuration file (format described below)
    • Hopefully this will open the "TextEdit" if there are no other editors available (that's hard to test for me, since I have so many editors on my system)
  • If the editor does not open you can also use "lay_config" with Cmd-Enter/Cmd-Click, which should open the configuration directory in Finder.
  • If it all fails: The configuration file should be this one: ~/Library/Application Support/Alfred 2/Workflow Data/de.leanovate.alfred.layout/layout.yaml
  • Of course there is a default-version in the workflow itself (i.e. to reset the workflow to default, just remove the file above)
  • Note: The keywords are NOT merged, i.e. if you do not like some keywords, you are actually able to remove them

The configuration file itself is YAML, which should be easily understandable:

- { name: "togglefullscreen", display: "Toggle full screen mode",      forOtherScreen: No,  command: "fullscreen:toggle" }
- { name: "full",             display: "Full",                         forOtherScreen: Yes, command: "set:0,0,1,1" }
- { name: "left",             display: "Left",                         forOtherScreen: Yes, command: "set:0,0,0.5,1" }

... well lets see if it all works as intended.

 

 

PS: If this is too spooky for you (or simply not working), the previous release is still available here: https://github.com/untoldwind/alfred2-layout/raw/1.1_Mavericks/Layout.alfredworkflow (in case I forgot to update links in the previous posts)

 

I've been using it for a while now and i have noticed increase in overall snappyness and speed. Seems to be working as expected! :) 

 

Can you do any resizing of VLC.app? I can't get VLC.app to do anything. Maybe a bug?

 

Thanks for sharing

Link to comment

Hmm ... what version of VLC are you using. I just tested the most recent 2.1.1 and was able to resize the playlist window and the player itself quite nicely.

 

Uh ... just for clarification: We are talking about the VideoLan player, right?

 

Yes, its the VideoLan player. Im using the latest, 2.1.1 just as you. That's weird. I cant get alfred to interact at all with VLC. Everything else seems to be working just fine. Hmm... :x

Link to comment
Ok, lets see if there is a way to figure this out.
 
I hacked a little test script that should explicitly move the the current window of VLC: https://dl.dropboxusercontent.com/u/3815280/tester.pl
(in its core that's what the workflow is doing via the scripting bridge.)
 
To run it you need to have an open VLC window somewhere (obviously) and open a terminal:
cd <where-ever you downloaded the script above>
/usr/bin/perl tester.pl

Please note, you have to temporarily grant UI-Scripting rights to the Terminal.app (or iTerm) for this to work:

 
The output should look like this:
└──➤ perl tester.pl
Found process
Name: VLC
ID: org.videolan.vlc
Active window: VLC media player
Position: 1083, 425
Size: 1365, 950
Alternative:
Alternative Position: 1083, 425
Alternative Size: 1365, 950
Try set position to 0,0 ...

... and the current VLC window should be moved to the top-left corner.

 

Edited by untoldwind
Link to comment

 

Ok, lets see if there is a way to figure this out.
 
I hacked a little test script that should explicitly move the the current window of VLC: https://dl.dropboxusercontent.com/u/3815280/tester.pl
(in its core that's what the workflow is doing via the scripting bridge.)
 
To run it you need to have an open VLC window somewhere (obviously) and open a terminal:
cd <where-ever you downloaded the script above>
/usr/bin/perl tester.pl

Please note, you have to temporarily grant UI-Scripting rights to the Terminal.app (or iTerm) for this to work:

 
The output should look like this:
└──➤ perl tester.pl
Found process
Name: VLC
ID: org.videolan.vlc
Active window: VLC media player
Position: 1083, 425
Size: 1365, 950
Alternative:
Alternative Position: 1083, 425
Alternative Size: 1365, 950
Try set position to 0,0 ...

... and the current VLC window should be moved to the top-left corner.

 

 

 

Thanks for helping out mate. I tried to do as described and here's the error;

 

Dahls-MacBook-Air:Downloads Dahl$ /usr/bin/perl tester.pl

Found process

Name: VLC

ID: org.videolan.vlc

Can't call method "name" on unblessed reference at tester.pl line 28.

Dahls-MacBook-Air:Downloads Dahl$ 

 
I'm no developer so i have no clue to fix line 28 by myself
Link to comment

Believe it or not, but this was actually helpful and let me to an ugly little error. Instead of

if ( !$window ) { ...

one actually has to write

if ( !$$window ) { ...

Just the little wonders of perl that are really (really really) hard to get ;)

 

Anyhow, I just updated the workflow with that fix: https://github.com/untoldwind/alfred2-layout/raw/master/Layout.alfredworkflow

 

Not sure if that actually fixes your problem, so I've updated the "tester.pl" as well. Maybe you can try it again if VLC still refuses to move.

Link to comment

Believe it or not, but this was actually helpful and let me to an ugly little error. Instead of

if ( !$window ) { ...

one actually has to write

if ( !$$window ) { ...

Just the little wonders of perl that are really (really really) hard to get ;)

 

Anyhow, I just updated the workflow with that fix: https://github.com/untoldwind/alfred2-layout/raw/master/Layout.alfredworkflow

 

Not sure if that actually fixes your problem, so I've updated the "tester.pl" as well. Maybe you can try it again if VLC still refuses to move.

 

Awesome dude. With the recent update VLC finally moves ;)

I was happy with your workflow before - now i can't express myself in words - thanks man!

Link to comment
  • 7 months later...
  • 3 weeks later...
  • 2 weeks later...

FYI the Mavericks version seems to be working with Yosemite.

Hm, I'm trying it on Yosemite Dp6 and see this getting logged:

[ERROR: alfred.workflow.action.script] Code 127: /bin/bash: line 4: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: No such file or directory

 

 

[EDIT]

Never mind, I found that installing the "Experimental" mavericks version works.

Edited by gerryh
Link to comment

S

 

If you look at the path, you'll see that it's looking for Ruby 1.8. Yosemite has Ruby 2.0 on it, so you could just change those paths if something else like this comes up.

Actually you can't use Ruby 2.0 with this Workflow.  One of the underlying Ruby libraries the workflow uses is not compatible with Ruby 2.0.   You can use the experimental version (there's a link in the first post) which uses Perl instead of Ruby.

Link to comment
  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...