mirror of
https://github.com/tomru/switchmon.git
synced 2026-03-03 06:27:23 +01:00
add list support
This commit is contained in:
31
cli.js
31
cli.js
@@ -17,16 +17,31 @@ and place them from left to right in the order given. If a provided monitor is
|
|||||||
not connected it will be skipped.
|
not connected it will be skipped.
|
||||||
|
|
||||||
If no monitors are specified all connected monitors will be turned on and
|
If no monitors are specified all connected monitors will be turned on and
|
||||||
placed from left to right in alphabetical order of their name.`
|
placed from left to right in alphabetical order of their name.
|
||||||
|
|
||||||
|
'swm -l' or 'swm --list'
|
||||||
|
|
||||||
|
List all devices with the connectivity status.`
|
||||||
);
|
);
|
||||||
|
|
||||||
process.exit(2);
|
process.exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
swm.getDevices()
|
if (argv.list || argv.l) {
|
||||||
.then(swm.generateXrandrOptions.bind(null, argv._))
|
swm.getDevices()
|
||||||
.then(swm.switchDevices)
|
.then(devices => {
|
||||||
.then(swm.executePostCmd.bind(null, argv.postCmd))
|
console.log('Detected devices:\n');
|
||||||
.catch(err => {
|
Object.keys(devices)
|
||||||
console.error(err);
|
.sort(key => !devices[key].connected)
|
||||||
});
|
.forEach(key => console.log(key + ':', devices[key].connected ? 'Connected' : 'Disconnected'));
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
swm.getDevices()
|
||||||
|
.then(swm.generateXrandrOptions.bind(null, argv._))
|
||||||
|
.then(swm.switchDevices)
|
||||||
|
.then(swm.executePostCmd.bind(null, argv.postCmd))
|
||||||
|
.catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user