Runs Scripts on Mac/Linux remotely.
I was setting up homebridge (iOS HomeKit Accesory Protocol) on my rasberryPi and after hooking up my IR Blaster, RF Transmitter and other wake-on-lan devices. I wanted my always-on OSX Laptop to also be remotely controlled by my iOS Device. So i ended up writing up a small plugin for Homebridge plugin.
I use this to play itunes, search google and bookmark search results, restart my system, get room temperature using MBP in-build Temp Sensor and adjust airconditioning accordingly, monitor my ec-2 instance stats, sync Spotify Playlist etc.
Homebridge Plugin => homebridge-unixcontrol
This library is directly injected into homebridge with a plugin wrapper => homebridge-unixcontrol
The plugin queries the system using HTTP API and run shell scripts. The shell requires sudo access to shutdown/reboot the system. More commands can be easily be injected. Feel free to PR.
You can ask Siri to execute commands :
Hey Siri, Shutdown my laptop
Hey Siri, play iTunes Playlist
Hey Siri, Good Morning ! // Plays Music, Backups OSX, Search for Google Alerts, Turns Off Air Conditioner
Hey Siri, Capture Laptop Webcam
Hey Siri, Who's using my laptop
$ npm install -g unix-remotecontrol
$ unixremote
$ npm install -g forever
$ git clone https://github.com/sahilchaddha/unix-remoteControl.git && cd unix-remoteControl
$ forever start src/server.js
Configuration containing sudo password, port number, logLevel & sessionToken are stored in environment.js
in root/src.
To Open Configuration for global module :
$ unixremote --config
Sample Configuration :
//environment.js
var env = {
port: '3000',
pass: 'lol', //sudo password TODO: Secure
logLevel: 'info',
sessionToken: 'f64f2940-fae4-11e7-8c5f-ef356f279131'
}
module.exports = env
Fields | Description |
---|---|
port | Port Number to run HTTP Server. |
pass | System Sudo Password |
logLevel | Log Level (debug, info, error) |
sessionToken | Random Session Token for API Authentication. |
NOTE: sessionToken
needs to be set as Request Header token
After Running the server, You can request
localhost:portNumber/commandType/command
e.g.
POST localhost:3000/power/shutdown
{
"time": 10
}
curl --header "token: f64f2940-fae4-11e7-8c5f-ef356f27913" -X POST localhost:3000/power/logout
curl --header "token: f64f2940-fae4-11e7-8c5f-ef356f27913" "Content-Type: application/json" -X POST -d '{"time":10}' localhost:3000/power/restart
curl --header "token: f64f2940-fae4-11e7-8c5f-ef356f27913" "Content-Type: application/json" -X POST -d '{"destination":"AppleMusic"}' localhost:3000/music/syncSpotify
Usage:-
localhost:3000/power/displaySleep
POST localhost:3000/power/restart
{
"time": 10
}
Command | Method | Description | Params | Sudo |
---|---|---|---|---|
/ping | GET | Pings to get server state (on/off) | None | false |
/halt | POST | Shutdowns immediately & forcibly (Can cause data loss) | None | true |
/shutdown | POST | Shut downs the system | time (minutes) : Delays Shutdown in minutes |
true |
/restart | POST | Restarts the system | time (minutes) : Delays Shutdown in minutes |
true |
/logout | POST | Logs Out the user (OSX Only) | None | false |
/sleep | POST | Turns the System to Sleep | None | false |
/displaySleep | POST | Turns the Display to Sleep | None | false |
/cancelShutdown | POST | Cancels Scheduled Shutdown/Restart Task | None | true |
Usage:-
localhost:3000/systemStats/temperature
localhost:3000/systemStats/ram
Command | Method | Description | Params | Sudo |
---|---|---|---|---|
/temperature | GET | Returns current Temperature of CPU | None | false |
/cpuLoad | GET | Returns current CPU Load | None | false |
/ram | GET | Returns current Ram Status | None | false |
/storage | GET | Returns current Storage Stats | None | false |
/battery | GET | Returns current Battery Information | None | false |
Usage:-
localhost:3000/browser/googleChromeReset
Command | Method | Description | Params | Sudo |
---|---|---|---|---|
/googleChromeReset | POST | Clear all data of google chrome and reset | None | false |
/safariClearHistory | POST | Clear histroy of safari | None | false |
NOTE: For safariClearHistory you will have to add terminal or whatever command line tool you are using should be added in System Preferences -> Security & Privacy -> Privacy -> Accessibility. When you run this command for the first time there will a prompt to add command line tool in Accessibility.
Usage:-
localhost:3000/wifi/on
Command | Method | Description | Params | Sudo |
---|---|---|---|---|
/status | GET | Returns Wifi Enabled/Disabled Status (OS X Only) | None | false |
/on | POST | Turn on wifi (OS X Only) | None | false |
/off | POST | Turn off wifi (OS X Only) | None | false |
/connect | POST | Connect to wifi (OS X Only) | name : wifi name, password : wifi password |
false |
Usage:-
localhost:3000/bluetooth/status
Command | Method | Description | Params | Sudo |
---|---|---|---|---|
/status | GET | Returns Bluetooth Enabled/Disabled Status (OS X Only) | None | false |
/on | POST | Turn on Bluetooth (OS X Only) | None | false |
/off | POST | Turn off Bluetooth (OS X Only) | None | false |
/showPairingAlert | POST | Show pairing alert or pair with any BLE enabled device (OS X Only) | deviceName : Bluetooth name of device with percentage encoding |
false |
/toggle | POST | Toggle device bluetooth connection (OS X Only) | deviceName : Bluetooth name of device with percentage encoding |
false |
NOTE: blueutil is added as a depedancy for Bluetooth Connections. It will be automatically installed during npm install
. Its added as postInstall Script in package.json
. If for some reason installation of blueutil fails, you can manually install blueutil brew install blueutil
Usage:-
localhost:3000/systemSpy/screenshot
localhost:3000/systemSpy/camRecord
localhost:3000/systemSpy/alert
{
"message": "Heeeyyy !!! Hooooo !!!"
}
localhost:3000/systemSpy/notify
{
"title": "heyyy",
"message": "hooo"
}
Command | Method | Description | Params | Sudo |
---|---|---|---|---|
/screenshot | POST | Screenshots Current Screen, Saves & returns image (OSX Only) | None | false |
/webcamCapture | POST | Clicks Camera Still, Saves & returns image (OSX Only) | None | false |
/screenRecord | POST | Starts Screen Recording (OSX Only) | time (In Minutes): Start recording for specific time. Here time is optional if you want to run this command forever than do not pass any arguments |
false |
/camRecord | POST | Starts Camera Recording (OSX Only) | time (In Minutes): Start recording for specific time. Here time is optional if you want to run this command forever than do not pass any arguments |
false |
/alert | POST | Shows Alert to User | message : Message to Show Alert |
false |
/notify | POST | Shows Notification to User | title : Title For Notification, message : Message |
false |
/isRecording | GET | Returns Recording Status (OSX Only) | type : screen or cam type of recording |
false |
Usage:-
localhost:3000/music/itunesPlaylist
localhost:3000/music/setVolume
{
"volume": 10
}
Command | Method | Description | Params | Sudo |
---|---|---|---|---|
/youtubePlaylist | POST | Opens Youtube & Starts Playing Playlist defined in environment.js (OSX Only) |
None | false |
/itunesPlaylist | POST | Opens iTunes & Starts Playing Playlist defined in environment.js (OSX Only) |
None | false |
/setVolume | POST | Sets New Volume (OSX Only) | volume : volume to be set. Should be between 0 to 10 |
false |
/getVolume | GET | Returns Current Volume (OSX Only) | None | false |
/mute | POST | Mutes the System (OSX Only) | None | false |
/unmute | POST | UnMutes the System (OSX Only) | None | false |
/isMuted | GET | Returns Mute Status (OSX Only) | None | false |
Cloning the Repo :
$ git clone https://github.com/sahilchaddha/unix-remoteControl.git && cd unix-remoteControl
$ node src/server.js
or
$ npm start
Creating Your Router :
You can create your custom router inside Routes
folder.
//DummyRouter.js
var router = require('express').Router() // Create New Router
var commandService = require('../Services/CommandService.js')
router.get('/hello', function (req, res) {
res.send('Hello')
// Run Your npm commands
// or call Shell Scripts using Command Service
commandService.execute('dummy', 'sayHello', options, function(){})
})
module.exports = router
Adding your Router to Valid Routes :
Add your custom router inside routes.js
var powerRouter = require('./Routes/PowerRouter.js')
var dummyRouter = require('./Routes/DummyRouter.js')
var routes = [
{
url: '/power',
routerClass: powerRouter
},
{
url: '/dummy',
routerClass: dummyRouter
}
]
module.exports = routes
Adding Your Shell Scripts :
You can use Command Service to execute commands :
To add Commands, you can inject your commands inside Commands/commands.js
var dummyCommands = {
sayHello: {
command: ['say', 'hello'],
sudo: false // Set as true if command need sudo access
}
}
module.exports = {
// power: powerCommands,
dummy: dummyCommands
}
Apple scripts in format .scpt
are to be injected inside AppleScripts
folder.
You can add command inside commands.js
var dummyCommands = {
sayHello: {
command: ['say', 'hello'],
sudo: false // Set as true if command need sudo access
},
runAppleScript: {
command: ['osascript', 'src/Commands/AppleScripts/dummyAS.scpt'],
sudo: false
}
}
module.exports = {
// power: powerCommands,
dummy: dummyCommands
}
WIP
$ ssh pi@192.168.1.2 // Your Pi Local Address
$ npm install -g homebridge
$ npm install -g homebridge-unixcontrol
// Configure Homebridge config.json
$ npm install -g unix-remotecontrol
$ unixremote --config //Setup Your Configuration
$ unixremote
Sahil Chaddha (mail@sahilchaddha.com)
Sumit Chudasama (imsrc21@gmail.com)
linux远程控制 图形界面(Linux remote control graphical interface) linux远程控制 图形界面(Linux remote control graphical interface) Abstract do you want to remotely access the Windows system in the Linux system and rem
source address: http://pdos.csail.mit.edu/6.828/2009/readings/ritchie79evolution.html Dennis M. Ritchie Bell Laboratories, Murray Hill, NJ, 07974 ABSTRACT This paper presents a brief history of the ea
本文转载自:UNIX TOOLBOX - 中文版 按照自己的理解,增删了部分内容。 这是一份收集Unix/Linux/BSD命令和任务的文档,它有助于高级用户或IT工作。它是一份简明扼要的实用指南,当然读者应该知道他/她在干什么。 Unix Toolbox 版本:12 你可以到 http://cb.vu/unixtoolbox.xhtml 找到本文档的最新版。PDF版本可以替换链接中的.xhtml
unix进程间通信方式(IPC) 管道(Pipe):管道可用于具有亲缘关系进程间的通信,允许一个进程和另一个与它有共同祖先的进程之间进行通信。 命名管道(named pipe):命名管道克服了管道没有名字的限制,因此,除具有管道所具有的功能外,它还允许无亲缘关系进程间的通信。命名管道在文件系统中有对应的文件名。命名管道通过命令mkfifo或系统调用mkfifo来创建。 信号(Signal):信号是
Modern Unix bat A cat clone with syntax highlighting and Git integration. exa A modern replacement for ls. lsd The next gen file listing command. Backwards compatible with ls. delta A viewer for git a
seismic unix 是科罗拉多矿院开发的一套开源地球物理数据处理系统 。此项目得到了 The Center for Wave Phenomena (CWP)财团项目的部分支持;之前接受过 Gas Research Institute (GRI)和 the Society of Exploration Geophysicists Foundation 的支持。
UNIX的历史开始于1969年ken Thompson,Dennis Ritchie(即著名的K&G,C语言的发明人)与一群人在一部PDP-7上进行的一些工作,后来这个系统变成了UNIX。它主要的几个版本为: V1(1971):第一版的UNIX,以PDP-11/20的汇编语言写成。包括文件系统,fork、roff、ed等软件。 V4(1973):以C语言从头写过,这使得UNIX修改容易,可以在几个
以下是显示Unix系统支持的所有字体示例的行。 您可能没有计算机上的所有可用字体。 此示例显示Charter字体的外观 此示例显示了Clean字体的外观 此示例显示Courier字体的外观 此示例显示Fixed字体的外观 此示例显示了Helvetica字体的外观 此示例显示了Lucida字体的外观 此示例显示了Lucida bright字体的外观 此示例显示了Lucida Typewriter字体
以下是显示Unix系统支持的所有字体示例的行。 您可能没有计算机上的所有可用字体。 此示例显示Charter字体的外观 此示例显示了Clean字体的外观 此示例显示Courier字体的外观 此示例显示Fixed字体的外观 此示例显示了Helvetica字体的外观 此示例显示了Lucida字体的外观 此示例显示了Lucida bright字体的外观 此示例显示了Lucida Typewriter字体