Skip to content
This repository has been archived by the owner on Oct 30, 2020. It is now read-only.

Commit

Permalink
feat: add sysprefs app including configureGeneral, configureDock, con…
Browse files Browse the repository at this point in the history
…figureMissionControl, configureSpotlight (#89)

- add sysprefs.configureDock
- add sysprefs.configureGeneral
- add sysprefs.configureMissionControl
- add sysprefs.configureSpotlight
  • Loading branch information
phuctm97 authored Apr 25, 2020
1 parent e1f85f5 commit 89cf7e9
Show file tree
Hide file tree
Showing 12 changed files with 361 additions and 396 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
autoHideMenuBar: false
showScrollBars: auto
clickScrollBar: jumpToNextPage
defaultWebBrowser: Safari
defaultWebBrowser: Google Chrome.app
askWhenClosingDocuments: true
closeWindowsWhenQuittingApp: true
recentItems: 0
Expand Down
54 changes: 54 additions & 0 deletions example.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,58 @@
jobs:
- uses: sysprefs.configureGeneral
args:
appearance: dark
accentColor: blue
highlightColor: blue
sidebarIconSize: small
autoHideMenuBar: false
showScrollBars: auto
clickScrollBar: jumpToNextPage
defaultWebBrowser: Google Chrome.app
askWhenClosingDocuments: true
closeWindowsWhenQuittingApp: true
recentItems: 0
allowHandoff: true
useFontSmoothing: true
- uses: sysprefs.configureDock
args:
size: 0.25
magnification: false
magnificationSize: 0
location: left
minimizeEffect: genie
preferTabsWhenOpeningDocuments: inFullScreenOnly
doubleClickTitleBar: zoom
minimizeToAppIcon: false
animate: true
autohide: true
showOpenIndicators: true
showRecentApps: false
- uses: sysprefs.configureMissionControl
args:
autoRearrangeSpaces: false
switchSpaceWhenSwithToApp: true
groupWindowsByApp: false
displaysHaveSeparateSpaces: true
missionControlKeyShortcut: "[control][up]"
appWindowsKeyShortcut: "[control][down]"
showDesktopKeyShortcut: F11
- uses: sysprefs.configureSpotlight
args:
searchResults:
- Applications
- System Preferences
- Calculator
- Conversion
- Definition
- Contacts
- Movies
- Music
- PDF Documents
- Presentations
- Spreadsheets
- Spotlight Suggestions
allowSpotlightInLookup: true
- uses: desktops.changePicture
args:
picture: Catalina Rock
Expand Down
116 changes: 101 additions & 15 deletions src/apps/sysprefs/dock/index.js → src/apps/sysprefs/configureDock.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
import { isUndefined } from 'lodash';
import { isUndefined, isObject } from 'lodash';
import { join } from '@utils';
import { createStepper } from '@core/workflow';
import sysEvents from '@core/sysEvents';
import { selectPopUpButton, selectCheckbox } from '@core/uiAutomation';
import runInSysPrefs from '@apps/sysprefs/app';
import { TabsWhenOpeningDocumentsPreferences, DoubleClickTitleBarActions } from '@apps/sysprefs/dock/options';

export * from '@apps/sysprefs/dock/options';
const ScreenEdges = {
BOTTOM: 'bottom',
LEFT: 'left',
RIGHT: 'right',
};

const MinimizeEffects = {
GENIE: 'genie',
SCALE: 'scale',
};

const TabsWhenOpeningDocumentsPreferences = {
ALWAYS: 'always',
IN_FULL_SCREEN_ONLY: 'inFullScreenOnly',
MANUALLY: 'manually',
};

const DoubleClickTitleBarActions = {
NONE: 'none',
ZOOM: 'zoom',
MINIMIZE: 'minimize',
};

// Map tabsWhenOpeningDocumentsPreferences input values to query values.
const tabsWhenOpeningDocumentsPreferencesMap = {
Expand All @@ -14,17 +35,7 @@ const tabsWhenOpeningDocumentsPreferencesMap = {
[TabsWhenOpeningDocumentsPreferences.MANUALLY]: 'Manually',
};

/**
* @typedef {import('./options').SysPrefsDockSettings} SysPrefsDockSettings
*/

/**
* Configure _System Preferences/Dock_ settings.
*
* @param {SysPrefsDockSettings} settings The settings object.
* @param {object} opts Options.
*/
export function configureDock(settings, opts = {}) {
function run(args, opts = {}) {
const {
size,
magnification,
Expand All @@ -38,7 +49,7 @@ export function configureDock(settings, opts = {}) {
autohide,
showOpenIndicators,
showRecentApps,
} = settings;
} = args;

return runInSysPrefs('Dock', ({ window }) => {
const stepper = createStepper(opts);
Expand Down Expand Up @@ -105,3 +116,78 @@ export function configureDock(settings, opts = {}) {
return stepper.run();
});
}

function inclusion(vals) {
return {
within: isObject(vals) ? Object.values(vals) : vals,
message: `is invalid, must be within [${join(vals)}]`,
};
}

/**
* Configure System Preferences Dock command.
*/
const configureDock = {
description: 'Configure System Preferences/Dock',
run,
args: {
size: {
numericality: {
noStrings: true,
greaterThanOrEqualTo: 0,
lessThanOrEqualTo: 1,
},
description: 'Size/height of the items (between 0.0 (minimum) and 1.0 (maximum))',
},
magnification: {
type: 'boolean',
description: 'Is magnification on or off?',
},
magnificationSize: {
numericality: {
noStrings: true,
greaterThanOrEqualTo: 0,
lessThanOrEqualTo: 1,
},
description: 'Maximum magnification size when magnification is on (between 0.0 (minimum) and 1.0 (maximum))',
},
location: {
inclusion: inclusion(ScreenEdges),
description: 'Location on screen',
},
minimizeEffect: {
inclusion: inclusion(MinimizeEffects),
description: 'Minimization effect',
},
preferTabsWhenOpeningDocuments: {
inclusion: inclusion(TabsWhenOpeningDocumentsPreferences),
description: 'Prefer tabs when opening documents',
},
doubleClickTitleBar: {
inclusion: inclusion(DoubleClickTitleBarActions),
description: 'Double-click window\'s title bar to',
},
minimizeToAppIcon: {
type: 'boolean',
description: 'Minimize windows to application icon',
},
animate: {
type: 'boolean',
description: 'Is the animation of opening applications on or off?',
},
autohide: {
type: 'boolean',
description: 'Is autohiding the dock on or off?',
},
showOpenIndicators: {
type: 'boolean',
description: 'Show indicators for opening applications',
},
showRecentApps: {
type: 'boolean',
description: 'Show recent applications in Dock',
},
},
};

export default configureDock;
Original file line number Diff line number Diff line change
@@ -1,15 +1,56 @@
import { isUndefined, capitalize } from 'lodash';
import { isObject, isUndefined, capitalize } from 'lodash';
import { join } from '@utils';
import { createStepper } from '@core/workflow';
import sysEvents from '@core/sysEvents';
import {
selectCheckbox, selectPopUpButton, selectRadio, selectToggle,
} from '@core/uiAutomation';
import runInSysPrefs from '@apps/sysprefs/app';
import {
Appearances, AccentColors, ClickScrollBarActions, ShowScrollBarsTriggers,
} from '@apps/sysprefs/general/options';

export * from '@apps/sysprefs/general/options';
const Appearances = {
LIGHT: 'light',
DARK: 'dark',
AUTO: 'auto',
};

const AccentColors = {
BLUE: 'blue',
PURPLE: 'purple',
PINK: 'pink',
RED: 'red',
ORANGE: 'orange',
YELLOW: 'yellow',
GREEN: 'green',
GRAPHITE: 'graphite',
};

const HighlightColors = {
BLUE: 'blue',
PURPLE: 'purple',
PINK: 'pink',
RED: 'red',
ORANGE: 'orange',
YELLOW: 'yellow',
GREEN: 'green',
GRAPHITE: 'graphite',
};

const SidebarIconSizes = {
SMALL: 'small',
MEDIUM: 'medium',
LARGE: 'large',
};

const ShowScrollBarsTriggers = {
AUTO: 'auto',
WHEN_SCROLLING: 'whenScrolling',
ALWAYS: 'always',
};

const ClickScrollBarActions = {
JUMP_TO_NEXT_PAGE: 'jumpToNextPage',
JUMP_TO_SPOT_CLICKED: 'jumpToSpotClicked',
};

// Map appearances from input values to query values.
const appearancesMap = {
Expand Down Expand Up @@ -43,17 +84,7 @@ const clickScrollBarActionsMap = {
[ClickScrollBarActions.JUMP_TO_NEXT_PAGE]: 'jump to next page',
};

/**
* @typedef {import('./options').SysPrefsGeneralSettings} SysPrefsGeneralSettings
*/

/**
* Configure _System Preferences/General_ settings.
*
* @param {SysPrefsGeneralSettings} settings The settings object.
* @param {object} opts Options.
*/
export function configureGeneral(settings, opts = {}) {
function run(args, opts = {}) {
const {
appearance,
accentColor,
Expand All @@ -68,7 +99,7 @@ export function configureGeneral(settings, opts = {}) {
recentItems,
allowHandoff,
useFontSmoothing,
} = settings;
} = args;

return runInSysPrefs('General', ({ window }) => {
const stepper = createStepper(opts);
Expand Down Expand Up @@ -133,3 +164,74 @@ export function configureGeneral(settings, opts = {}) {
return stepper.run();
});
}

function inclusion(vals) {
return {
within: isObject(vals) ? Object.values(vals) : vals,
message: `is invalid, must be within [${join(vals)}]`,
};
}

/**
* Configure System Preferences/General command.
*/
const configureGeneral = {
description: 'Configure System Preferences/General',
run,
args: {
appearance: {
inclusion: inclusion(Appearances),
description: 'Appearance',
},
accentColor: {
inclusion: inclusion(AccentColors),
description: 'Accent color',
},
highlightColor: {
inclusion: inclusion(HighlightColors),
description: 'Highlight color',
},
sidebarIconSize: {
inclusion: inclusion(SidebarIconSizes),
description: 'Sidebar icon size',
},
autoHideMenuBar: {
type: 'boolean',
description: 'Automatically hide and show menu bar',
},
showScrollBars: {
inclusion: inclusion(ShowScrollBarsTriggers),
description: 'Show scroll bars trigger',
},
clickScrollBar: {
inclusion: inclusion(ClickScrollBarActions),
description: 'Click scroll bar to',
},
defaultWebBrowser: {
type: 'string',
description: 'Default web browser',
},
askWhenClosingDocuments: {
type: 'boolean',
description: 'Ask to keep changes when closing documents',
},
closeWindowsWhenQuittingApp: {
type: 'boolean',
description: 'Close windows when quitting an app',
},
recentItems: {
inclusion: inclusion([0, 5, 10, 15, 20, 30, 50]),
description: 'Number of items to show in Recent items',
},
allowHandoff: {
type: 'boolean',
description: 'Allow Handoff between this Mac and your iCloud devices',
},
useFontSmoothing: {
type: 'boolean',
description: 'Use font smoothing when available',
},
},
};

export default configureGeneral;
Loading

0 comments on commit 89cf7e9

Please sign in to comment.