├── .ruby-version ├── .idea ├── .name ├── copyright │ └── profiles_settings.xml ├── scopes │ └── scope_settings.xml ├── encodings.xml ├── vcs.xml ├── modules.xml ├── cssxfire.xml ├── compiler.xml ├── .rakeTasks └── misc.xml ├── workflow ├── Gemfile ├── icon.png ├── resolution-cli ├── reset-resolution-list.rb ├── remove-resolution.rb ├── Gemfile.lock ├── set-resolution.rb ├── feedback.rb ├── workflow_config.rb └── info.plist ├── screenshots ├── list.png ├── remove.png ├── reset.png ├── search.png └── displays.png ├── .gitmodules ├── alfred-set-resolution.alfredworkflow ├── .gitignore ├── config.yml ├── LICENSE ├── alfred-set-resolution-workflow.iml ├── README.md └── Rakefile /.ruby-version: -------------------------------------------------------------------------------- 1 | 2.0.0-p353 2 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | alfred-set-resolution-workflow -------------------------------------------------------------------------------- /workflow/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'plist' 4 | gem 'alfred-workflow' 5 | -------------------------------------------------------------------------------- /workflow/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramiroaraujo/alfred-set-resolution-workflow/HEAD/workflow/icon.png -------------------------------------------------------------------------------- /screenshots/list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramiroaraujo/alfred-set-resolution-workflow/HEAD/screenshots/list.png -------------------------------------------------------------------------------- /screenshots/remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramiroaraujo/alfred-set-resolution-workflow/HEAD/screenshots/remove.png -------------------------------------------------------------------------------- /screenshots/reset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramiroaraujo/alfred-set-resolution-workflow/HEAD/screenshots/reset.png -------------------------------------------------------------------------------- /screenshots/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramiroaraujo/alfred-set-resolution-workflow/HEAD/screenshots/search.png -------------------------------------------------------------------------------- /screenshots/displays.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramiroaraujo/alfred-set-resolution-workflow/HEAD/screenshots/displays.png -------------------------------------------------------------------------------- /workflow/resolution-cli: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramiroaraujo/alfred-set-resolution-workflow/HEAD/workflow/resolution-cli -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "ResolutionMenu"] 2 | path = ResolutionMenu 3 | url = https://github.com/ramiroaraujo/ResolutionMenu.git 4 | -------------------------------------------------------------------------------- /alfred-set-resolution.alfredworkflow: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramiroaraujo/alfred-set-resolution-workflow/HEAD/alfred-set-resolution.alfredworkflow -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | workflow/.bundle 2 | workflow/bundle 3 | .idea/workspace.xml 4 | .idea/tasks.xml 5 | 6 | # avoid continuous changes to iml file 7 | # *.iml 8 | workflow/display_resolutions.yml -------------------------------------------------------------------------------- /.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /workflow/reset-resolution-list.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | require_relative 'workflow_config.rb' 5 | 6 | config = WorkflowConfig.new 7 | config.rebuild_resolutions 8 | 9 | puts 1 10 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/cssxfire.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /workflow/remove-resolution.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | require_relative 'workflow_config.rb' 5 | 6 | config = WorkflowConfig.new 7 | display, id = ARGV[0].match(/(\d+)@(.+)/).captures 8 | display = display.to_i 9 | resolution = config.get_resolution display, id 10 | config.remove_resolution display, id 11 | 12 | print "#{resolution[:width]}x#{resolution[:height]}" 13 | -------------------------------------------------------------------------------- /workflow/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | alfred-workflow (2.0.5) 5 | fuzzy_match (>= 2.0.4) 6 | gyoku (>= 1.1.0) 7 | moneta (>= 0.7.19) 8 | nori (>= 2.3.0) 9 | plist (>= 3.1.0) 10 | terminal-notifier (>= 1.5.0) 11 | builder (3.2.2) 12 | fuzzy_match (2.0.4) 13 | gyoku (1.1.1) 14 | builder (>= 2.1.2) 15 | moneta (0.7.20) 16 | nori (2.3.0) 17 | plist (3.1.0) 18 | terminal-notifier (1.5.1) 19 | 20 | PLATFORMS 21 | ruby 22 | 23 | DEPENDENCIES 24 | alfred-workflow 25 | plist 26 | -------------------------------------------------------------------------------- /workflow/set-resolution.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | query = ARGV[0] 5 | 6 | if query =~ /^\d+$/ 7 | `osascript -e 'tell app "Alfred 2" to search "setresolution #{query} "'` 8 | else 9 | # extract values 10 | display, width, height, bits, hidpi = ARGV[0].match(/(\d+)@(\d+)x(\d+)@(\d+)(h?)/).captures 11 | 12 | `./resolution-cli set #{display} #{width}x#{height}@#{bits}#{hidpi}`; result= $?.success? 13 | 14 | unless result 15 | `/usr/bin/afplay /System/Library/Sounds/Funk.aiff` 16 | exit 1 17 | end 18 | 19 | print "#{width}x#{height}" 20 | end -------------------------------------------------------------------------------- /config.yml: -------------------------------------------------------------------------------- 1 | ## workflow build config 2 | 3 | # id and name for the workflow (bundle id = domain.id) 4 | id: alfred-set-resolution-workflow 5 | 6 | # base domain 7 | domain: com.tumblr.ramiroaraujo 8 | 9 | name: Set Resolution 10 | description: A workflow to change between available resolutions on your display, specially handy for Retina displays. 11 | created_by: Ramiro Araujo 12 | website: https://github.com/ramiroaraujo/alfred-set-resolution-workflow 13 | readme: readme 14 | 15 | ## development config 16 | 17 | # path is the relative path to the workflow in the project root 18 | path: workflow 19 | 20 | # If you are using Alfred's advanced Dropbox sync, indicate the path shown in 21 | # Alfred Preferences > Advanced > Syncing: 22 | dropbox: ~/Dropbox -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Ramiro Araujo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /.idea/.rakeTasks: -------------------------------------------------------------------------------- 1 | 2 | 8 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | Bash 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | ruby-2.0.0-p247 OSX 28 | 29 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /alfred-set-resolution-workflow.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Set Resolution Workflow for Alfred App 2 | 3 | Handy workflow to change between available screen resolutions, even between normal and HiDPI mode (Retina). 4 | 5 | It allows you to list and search available resolutions for each connected display, and action the result to do the change. The change persists between logout (ex: restart, shutdown, etc). 6 | 7 | It filter's out duplicated resolutions where a retina resolution is available, for example, if you have available 1280x960 in both retina and non-retina, you'll only see the retina option; no need to set the pixelated one. 8 | 9 | ## Usage 10 | 11 | Type the keyword ```setresolution``` to show a list of resolutions. You'll see that the first result is actually a non-actionable result which shows the current resolution. 12 | 13 | ![list](https://raw.github.com/ramiroaraujo/alfred-set-resolution-workflow/master/screenshots/list.png) 14 | 15 | If you have more than one display, you'll see instead the displays to select, and by actioning on any display the workflow will reload with the display index and after the keyword, and ready to search/select the proper resolutions. When using multiple displays, the display index _is_ needed, but you can write it down yourself to make it faster, like ```setresolution 1 1280``` to search for 1280 on display index 1 (the second from the list) 16 | 17 | ![displays](https://raw.github.com/ramiroaraujo/alfred-set-resolution-workflow/master/screenshots/displays.png) 18 | 19 | You can also type after the space to search for resolutions (searches the numbers). 20 | 21 | ![search](https://raw.github.com/ramiroaraujo/alfred-set-resolution-workflow/master/screenshots/search.png) 22 | 23 | The available resolutions list is usually quite large. You can delete available resolutions from the list by actioning the result while holding the ```⌥ (alt)``` key. 24 | 25 | ![remove](https://raw.github.com/ramiroaraujo/alfred-set-resolution-workflow/master/screenshots/remove.png) 26 | 27 | If you connect a different display, or want to undo a deleted resolution you need to reset the list by actioning the keyword ```resetresolution``` 28 | 29 | ![reset](https://raw.github.com/ramiroaraujo/alfred-set-resolution-workflow/master/screenshots/reset.png) 30 | 31 | 32 | ## Installation 33 | For OS X 10.9 Mavericks, Download the [alfred-set-resolution.alfredworkflow](https://github.com/ramiroaraujo/alfred-set-resolution-workflow/raw/master/alfred-set-resolution.alfredworkflow) and import to Alfred 2. 34 | 35 | For Previous OS X Versions, Download the [alfred-set-resolution.alfredworkflow](https://github.com/ramiroaraujo/alfred-set-resolution-workflow/raw/pre-mavericks/alfred-set-resolution.alfredworkflow) and import to Alfred 2. 36 | 37 | ## Credits 38 | 39 | Build around a modified version [(my fork)](https://github.com/ramiroaraujo/ResolutionMenu) of a fork of Robbert Klarenbeek's [ResolutionMenu](https://github.com/robbertkl/ResolutionMenu) app, by [Anthony Dervish](https://github.com/antmd/ResolutionMenu). 40 | 41 | ## Changelog 42 | * _2014-02-24_ - Released 43 | -------------------------------------------------------------------------------- /workflow/feedback.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | require_relative 'bundle/bundler/setup' 5 | require_relative 'workflow_config.rb' 6 | require 'alfred' 7 | 8 | filter = ARGV[0].to_s.downcase 9 | 10 | # config / data 11 | config = WorkflowConfig.new 12 | 13 | displays = config.get_displays 14 | 15 | select_display = nil 16 | current_display = nil 17 | 18 | Alfred.with_friendly_error do |alfred| 19 | fb = alfred.feedback 20 | 21 | begin 22 | if displays.length < 2 23 | current_display = 0 24 | select_display = false 25 | else 26 | current_display, noop, filter = filter.match(/^(\d+)(\s+)?(.+)?/).captures 27 | current_display = current_display.to_i 28 | select_display = false 29 | raise Exception unless displays[current_display] 30 | end 31 | rescue 32 | select_display = true 33 | end 34 | 35 | if select_display 36 | displays.each_with_index do |display, index| 37 | fb.add_item({ 38 | #:uid => mode['id'], 39 | :title => "Display: #{display[:name]}", 40 | :subtitle => "Change resolution for display #{display[:name]}", 41 | :arg => index, 42 | :valid => 'yes', 43 | }) 44 | end 45 | else 46 | # get current resolution 47 | current_resolution = config.get_current_resolution current_display 48 | 49 | # get resolution list 50 | resolutions = config.get_resolutions current_display 51 | 52 | # removes current resolution 53 | resolutions = resolutions.delete_if { |mode| mode[:id] == current_resolution[:id] } 54 | 55 | # search filter if present 56 | if filter 57 | resolutions.reject! do |mode| 58 | true unless mode[:id] =~ /#{filter}/ 59 | end 60 | end 61 | 62 | if resolutions.length > 0 63 | # if there's no filter 64 | if filter =~ /^\s*$/ 65 | # adds current resolution as non actionable item 66 | fb.add_item({ 67 | :title => "Current Resolution: #{current_resolution[:width]}x#{current_resolution[:height]} at #{current_resolution[:dpi]}", 68 | :subtitle => 'Select a new resolution from the list or type to search', 69 | :arg => '', 70 | :valid => 'no', 71 | }) 72 | end 73 | 74 | # iterates and performs search filter if present 75 | resolutions.each do |mode| 76 | fb.add_item({ 77 | #:uid => mode['id'], 78 | :title => "Switch to #{mode[:width]}x#{mode[:height]} at #{mode[:dpi]}", 79 | :subtitle => "Change resolution to #{mode[:width]} width and #{mode[:height]} height at #{mode[:dpi]} mode", 80 | :arg => mode[:id], 81 | :valid => 'yes', 82 | }) 83 | end 84 | else 85 | # shows no result message 86 | fb.add_item({ 87 | :uid => '', 88 | :title => 'No results for your search', 89 | :subtitle => 'No screen resolution found for your input search', 90 | :arg => '', 91 | :valid => 'no', 92 | }) 93 | end 94 | end 95 | 96 | puts fb.to_xml() 97 | end -------------------------------------------------------------------------------- /workflow/workflow_config.rb: -------------------------------------------------------------------------------- 1 | require_relative 'bundle/bundler/setup' 2 | require 'alfred' 3 | require 'yaml' 4 | 5 | class WorkflowConfig 6 | 7 | @displays 8 | 9 | @file 10 | 11 | def initialize 12 | @file = 'display_resolutions.yml' 13 | load_display_resolutions 14 | end 15 | 16 | def get_displays 17 | @displays 18 | end 19 | 20 | def get_current_resolution display 21 | current = `./resolution-cli current #{display}` 22 | width, height, bits, hidpi = current.match(/^(\d+) x (\d+) @ (\d+) bits ?(HiDPI)?$/).captures 23 | mode = { 24 | width: width, 25 | height: height, 26 | bits: bits, 27 | hidpi: !!hidpi, 28 | dpi: !!hidpi ? 'HiDPI' : 'normal resolution', 29 | id: "#{display}@#{width}x#{height}@#{bits}#{!!hidpi ? 'h' : ''}" 30 | } 31 | 32 | end 33 | 34 | def get_resolutions display 35 | @displays[display][:modes] 36 | end 37 | 38 | def get_resolution(display, id) 39 | resolution = @displays[display][:modes].detect do |resolution| 40 | resolution[:id] == "#{display}@#{id}" 41 | end 42 | resolution 43 | end 44 | 45 | def remove_resolution(display, id) 46 | @displays[display][:modes].reject! do |resolution| 47 | true if resolution[:id] == "#{display}@#{id}" 48 | end 49 | 50 | # write config back 51 | write_config 52 | end 53 | 54 | 55 | def load_display_resolutions 56 | @displays = YAML.load(File.open @file) if File.exist? @file 57 | rebuild_resolutions if !@displays 58 | end 59 | 60 | def rebuild_resolutions 61 | # get full resolution list from cli app, and parse data into array of hashes 62 | list = `./resolution-cli list` 63 | list.strip! 64 | 65 | @displays = list.scan(/^\d+: (.+)$/).map { |d| {:name => d[0], :modes => [], :current_mode => ''} } 66 | list.split(/^\d+: .+$/)[1..-1].each_with_index do |modes_string, display_index| 67 | modes_string.strip.split("\n").each do |mode_string| 68 | match = /^(?>>>)?\s*(?\d+)\s+x\s+(?\d+) @ (?\d+) bits ?(?HiDPI)?$/.match(mode_string) 69 | mode = { 70 | width: match[:width], 71 | height: match[:height], 72 | bits: match[:bits], 73 | hidpi: !!match[:dpi], 74 | dpi: !!match[:dpi] ? 'HiDPI' : 'normal resolution', 75 | id: "#{display_index}@#{match[:width]}x#{match[:height]}@#{match[:bits]}#{!!match[:dpi] ? 'h' : ''}" 76 | } 77 | @displays[display_index][:modes] << mode 78 | @displays[display_index][:current_mode] = mode[:id] if match[:current] 79 | end 80 | end 81 | 82 | # removes 16 bits resolutions 83 | @displays.each do |display| 84 | display[:modes].reject! do |mode| 85 | true if mode[:bits] == '16' 86 | end 87 | end 88 | 89 | 90 | 91 | # removes normal resolutions that are available as HiDPI 92 | @displays.each do |display| 93 | display[:modes].reject! do |mode| 94 | false if mode[:hidpi] 95 | true if !mode[:hidpi] && display[:modes].any? { |m| m[:id] == "#{mode[:id]}h"} 96 | end 97 | end 98 | 99 | # remove displays with only one option 100 | @displays.reject! { |display| true if display[:modes].length <= 1 } 101 | 102 | # write config back to yaml 103 | write_config 104 | end 105 | 106 | 107 | def write_config 108 | File.open(@file, 'w') { |f| f.write(@displays.to_yaml) } 109 | end 110 | 111 | private :load_display_resolutions, :write_config 112 | end -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' unless defined? Gem # rubygems is only needed in 1.8 2 | 3 | require 'yaml' 4 | require 'plist' 5 | 6 | config_file = 'config.yml' 7 | 8 | workflow_home = File.expand_path('~/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows') 9 | 10 | $config = YAML.load_file(config_file) 11 | $config['bundleid'] = "#{$config['domain']}.#{$config['id']}" 12 | $config['plist'] = File.join($config['path'], 'info.plist') 13 | $config['workflow_dbx'] = File.join(File.expand_path($config['dropbox']), '/Alfred.alfredpreferences/workflows') 14 | 15 | # import sub-rakefiles 16 | FileList['*/Rakefile'].each { |file| 17 | import file 18 | } 19 | 20 | desc 'Update config' 21 | task :config do 22 | modified = false 23 | 24 | info = Plist::parse_xml($config['plist']) 25 | 26 | if info['bundleid'] != $config['bundleid'] 27 | info['bundleid'] = $config['bundleid'] 28 | modified = true 29 | end 30 | if info['createdby'] != $config['created_by'] 31 | info['createdby'] = $config['created_by'] 32 | modified = true 33 | end 34 | if info['description'] != $config['description'] 35 | info['description'] = $config['description'] 36 | modified = true 37 | end 38 | if info['name'] != $config['name'] 39 | info['name'] = $config['name'] 40 | modified = true 41 | end 42 | if info['webaddress'] != $config['website'] 43 | info['webaddress'] = $config['website'] 44 | modified = true 45 | end 46 | if info['readme'] != $config['readme'] 47 | info['readme'] = $config['readme'] 48 | modified = true 49 | end 50 | 51 | if modified 52 | File.open($config['plist'], 'wb') { |file| file.write(info.to_plist) } 53 | end 54 | end 55 | 56 | task :chdir => [:config] do 57 | chdir $config['path'] 58 | end 59 | 60 | desc 'Install Gems' 61 | task 'bundle:install' => [:chdir] do 62 | sh %Q{bundle install --standalone --clean} do |ok, res| 63 | if !ok 64 | puts "fail to install gems (status = #{res.exitstatus})" 65 | end 66 | end 67 | end 68 | 69 | desc 'Update Gems' 70 | task 'bundle:update' => [:chdir] do 71 | sh %Q{bundle update && bundle install --standalone --clean} do |ok, res| 72 | if !ok 73 | puts "fail to update gems (status = #{res.exitstatus})" 74 | end 75 | end 76 | end 77 | 78 | desc 'Install to Alfred' 79 | task :install => [:config] do 80 | ln_sf File.expand_path($config['path']), File.join(workflow_home, $config['bundleid']) 81 | end 82 | 83 | desc 'Unlink from Alfred' 84 | task :uninstall => [:config] do 85 | rm File.join(workflow_home, $config['bundleid']) 86 | end 87 | 88 | desc 'Install to Dropbox' 89 | task :dbxinstall => [:config] do 90 | ln_sf File.expand_path($config['path']), File.join($config['workflow_dbx'], $config['bundleid']) 91 | end 92 | 93 | desc 'Unlink from Dropbox' 94 | task :dbxuninstall => [:config] do 95 | rm File.join($config['workflow_dbx'], $config['bundleid']) 96 | end 97 | 98 | desc 'Clean up all the extras' 99 | task :clean => [:config] do 100 | end 101 | 102 | desc 'Remove any generated file' 103 | task :clobber => [:clean] do 104 | rmtree File.join($config['path'], '.bundle') 105 | rmtree File.join($config['path'], 'bundle') 106 | end 107 | 108 | desc 'Create packed Workflow' 109 | task :export => [:config] do 110 | ruby_version = RbConfig::CONFIG['ruby_version'] 111 | 112 | filename = "#{$config['id'].chomp '-workflow'}.alfredworkflow" 113 | output = 'output' 114 | 115 | FileUtils.rm filename if File.exists? filename 116 | FileUtils.rmtree output if File.exists? output 117 | 118 | FileUtils.cp_r $config['path'], output 119 | 120 | 121 | Dir.chdir output do 122 | 123 | # clean up workflow files for export 124 | Dir.foreach('.') do |file| 125 | FileUtils.rmtree file if %w(Gemfile Gemfile.lock .bundle resolution-cli display_resolutions.yml).include? file 126 | end 127 | 128 | Dir.chdir '../ResolutionMenu' do 129 | `xcodebuild -target resolution-cli` 130 | FileUtils.cp 'build/Release/resolution-cli', '../output' 131 | end 132 | 133 | begin 134 | Dir.chdir('bundle/ruby') do 135 | Dir.foreach('.') do |dir| 136 | next if dir == '.' || dir == '..' 137 | FileUtils.rmtree dir if dir != ruby_version 138 | end 139 | end 140 | Dir.chdir("bundle/ruby/#{ruby_version}") do 141 | Dir.foreach('.') do |dir| 142 | FileUtils.rmtree dir if %w(build_info cache doc specifications).include? dir 143 | end 144 | Dir.chdir('gems') do 145 | Dir.foreach('.') do |dir| 146 | next if dir == '.' || dir == '..' 147 | Dir.chdir(dir) do 148 | Dir.foreach('.') do |subdir| 149 | next if subdir == '.' || subdir == '..' 150 | FileUtils.rmtree subdir if !(%w(. .. lib).include? subdir) 151 | end 152 | end 153 | end 154 | end 155 | end 156 | rescue 157 | FileUtils.rmtree 'bundle' 158 | # nothing 159 | end 160 | 161 | # generates zip 162 | `/usr/bin/zip -r ../#{filename} *` 163 | end 164 | 165 | 166 | FileUtils.rmtree output 167 | 168 | puts 'Workflow exported to project directory' 169 | end -------------------------------------------------------------------------------- /workflow/info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | bundleid 6 | com.tumblr.ramiroaraujo.alfred-set-resolution-workflow 7 | connections 8 | 9 | 3130FCF9-9A30-4FF0-A5EE-BEE3BAEB08F8 10 | 11 | 12 | destinationuid 13 | 3809F4AB-324D-4562-BEB0-9F29187F53AF 14 | modifiers 15 | 0 16 | modifiersubtext 17 | 18 | 19 | 20 | 57B8F7AF-14BD-4774-AF0B-350317829554 21 | 22 | 23 | destinationuid 24 | F0F7A9ED-7E4A-488D-8AA6-92798A8C8A79 25 | modifiers 26 | 0 27 | modifiersubtext 28 | 29 | 30 | 31 | 7FCD3413-2CB3-41C2-9641-62C1DD170A33 32 | 33 | 34 | destinationuid 35 | F356255B-4349-482F-A505-89B0B9D90F14 36 | modifiers 37 | 0 38 | modifiersubtext 39 | 40 | 41 | 42 | destinationuid 43 | 57B8F7AF-14BD-4774-AF0B-350317829554 44 | modifiers 45 | 524288 46 | modifiersubtext 47 | Remove this resolution from the list 48 | 49 | 50 | D146A9A1-2188-4D7F-84DE-68D81BE67E18 51 | 52 | 53 | destinationuid 54 | 3130FCF9-9A30-4FF0-A5EE-BEE3BAEB08F8 55 | modifiers 56 | 0 57 | modifiersubtext 58 | 59 | 60 | 61 | F356255B-4349-482F-A505-89B0B9D90F14 62 | 63 | 64 | destinationuid 65 | 1B27CAC8-7961-491C-BF9D-0878AF61C1DF 66 | modifiers 67 | 0 68 | modifiersubtext 69 | 70 | 71 | 72 | 73 | createdby 74 | Ramiro Araujo 75 | description 76 | A workflow to change between available resolutions on your display, specially handy for Retina displays. 77 | disabled 78 | 79 | name 80 | Set Resolution 81 | objects 82 | 83 | 84 | config 85 | 86 | escaping 87 | 4 88 | script 89 | /usr/bin/ruby set-resolution.rb "{query}" 90 | type 91 | 0 92 | 93 | type 94 | alfred.workflow.action.script 95 | uid 96 | F356255B-4349-482F-A505-89B0B9D90F14 97 | version 98 | 0 99 | 100 | 101 | config 102 | 103 | argumenttype 104 | 1 105 | escaping 106 | 4 107 | keyword 108 | setresolution 109 | runningsubtext 110 | working... 111 | script 112 | /usr/bin/ruby ./feedback.rb "{query}" 113 | subtext 114 | Select between available screen resolutions, type to filter 115 | title 116 | Set Screen Resolution 117 | type 118 | 0 119 | withspace 120 | 121 | 122 | type 123 | alfred.workflow.input.scriptfilter 124 | uid 125 | 7FCD3413-2CB3-41C2-9641-62C1DD170A33 126 | version 127 | 0 128 | 129 | 130 | config 131 | 132 | lastpathcomponent 133 | 134 | onlyshowifquerypopulated 135 | 136 | output 137 | 0 138 | removeextension 139 | 140 | sticky 141 | 142 | text 143 | Resolution changed to {query} 144 | title 145 | Set Resolution 146 | 147 | type 148 | alfred.workflow.output.notification 149 | uid 150 | 1B27CAC8-7961-491C-BF9D-0878AF61C1DF 151 | version 152 | 0 153 | 154 | 155 | config 156 | 157 | lastpathcomponent 158 | 159 | onlyshowifquerypopulated 160 | 161 | output 162 | 0 163 | removeextension 164 | 165 | sticky 166 | 167 | text 168 | removed {query} from the list 169 | title 170 | Resolution removed 171 | 172 | type 173 | alfred.workflow.output.notification 174 | uid 175 | F0F7A9ED-7E4A-488D-8AA6-92798A8C8A79 176 | version 177 | 0 178 | 179 | 180 | config 181 | 182 | escaping 183 | 4 184 | script 185 | /usr/bin/ruby remove-resolution.rb "{query}" 186 | type 187 | 0 188 | 189 | type 190 | alfred.workflow.action.script 191 | uid 192 | 57B8F7AF-14BD-4774-AF0B-350317829554 193 | version 194 | 0 195 | 196 | 197 | config 198 | 199 | escaping 200 | 127 201 | script 202 | /usr/bin/ruby reset-resolution-list.rb 203 | type 204 | 0 205 | 206 | type 207 | alfred.workflow.action.script 208 | uid 209 | 3130FCF9-9A30-4FF0-A5EE-BEE3BAEB08F8 210 | version 211 | 0 212 | 213 | 214 | config 215 | 216 | argumenttype 217 | 2 218 | keyword 219 | resetresolution 220 | subtext 221 | resets the resolution list back to default 222 | text 223 | Reset Resolution list 224 | withspace 225 | 226 | 227 | type 228 | alfred.workflow.input.keyword 229 | uid 230 | D146A9A1-2188-4D7F-84DE-68D81BE67E18 231 | version 232 | 0 233 | 234 | 235 | config 236 | 237 | lastpathcomponent 238 | 239 | onlyshowifquerypopulated 240 | 241 | output 242 | 0 243 | removeextension 244 | 245 | sticky 246 | 247 | text 248 | Resolution list rebuilt 249 | title 250 | Resolution Reset 251 | 252 | type 253 | alfred.workflow.output.notification 254 | uid 255 | 3809F4AB-324D-4562-BEB0-9F29187F53AF 256 | version 257 | 0 258 | 259 | 260 | readme 261 | readme 262 | uidata 263 | 264 | 1B27CAC8-7961-491C-BF9D-0878AF61C1DF 265 | 266 | ypos 267 | 10 268 | 269 | 3130FCF9-9A30-4FF0-A5EE-BEE3BAEB08F8 270 | 271 | ypos 272 | 250 273 | 274 | 3809F4AB-324D-4562-BEB0-9F29187F53AF 275 | 276 | ypos 277 | 250 278 | 279 | 57B8F7AF-14BD-4774-AF0B-350317829554 280 | 281 | ypos 282 | 130 283 | 284 | 7FCD3413-2CB3-41C2-9641-62C1DD170A33 285 | 286 | ypos 287 | 10 288 | 289 | D146A9A1-2188-4D7F-84DE-68D81BE67E18 290 | 291 | ypos 292 | 250 293 | 294 | F0F7A9ED-7E4A-488D-8AA6-92798A8C8A79 295 | 296 | ypos 297 | 130 298 | 299 | F356255B-4349-482F-A505-89B0B9D90F14 300 | 301 | ypos 302 | 10 303 | 304 | 305 | webaddress 306 | https://github.com/ramiroaraujo/alfred-set-resolution-workflow 307 | 308 | 309 | --------------------------------------------------------------------------------