我目前正在研究多媒体机器,我想通过PS4 DS4(使用ds4drv
和一些脚本)来控制。如果通过Bash / Terminal手动启动,一切都像魅力一样。但是,如果通过crontab
启动,几乎没有任何作用。
到目前为止,我已经做了一些研究,看起来错误与我的环境变量有某种关系。
ds4drv
cron
如果以hehxes@PC:~$ env - `cat ~/cronenv` /bin/sh
$ /usr/local/bin/ds4drv
[info][controller 1] Created devices /dev/input/js2 (joystick) /dev/input/event25 (evdev)
[info][controller 1] Connected to Bluetooth Controller (1C:66:6D:64:2F:74 hidraw5)
[info][hidraw] Scanning for devices
[info][controller 1] Battery: 75%
[info][controller 1] Switching to profile: kbmouse
[info][controller 1] Switching to profile: gaming
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "build/bdist.linux-x86_64/egg/ds4drv/__main__.py", line 110, in run
self.loop.run()
File "build/bdist.linux-x86_64/egg/ds4drv/eventloop.py", line 105, in run
callback()
File "build/bdist.linux-x86_64/egg/ds4drv/__main__.py", line 107, in read_report
self.fire_event("device-report", report)
File "build/bdist.linux-x86_64/egg/ds4drv/__main__.py", line 39, in fire_event
self.loop.fire_event(event, *args)
File "build/bdist.linux-x86_64/egg/ds4drv/eventloop.py", line 90, in fire_event
self.process_events()
File "build/bdist.linux-x86_64/egg/ds4drv/eventloop.py", line 96, in process_events
callback(*args)
File "build/bdist.linux-x86_64/egg/ds4drv/action.py", line 73, in _handle_report
self.handle_report(report)
File "build/bdist.linux-x86_64/egg/ds4drv/actions/binding.py", line 105, in handle_report
binding.callback(report, *binding.args)
File "build/bdist.linux-x86_64/egg/ds4drv/actions/binding.py", line 62, in <lambda>
lambda r: self.controller.next_profile())
File "build/bdist.linux-x86_64/egg/ds4drv/__main__.py", line 62, in next_profile
self.load_profile(self.profiles[next_index])
File "build/bdist.linux-x86_64/egg/ds4drv/__main__.py", line 48, in load_profile
self.load_options(profile_options)
File "build/bdist.linux-x86_64/egg/ds4drv/__main__.py", line 94, in load_options
self.fire_event("load-options", options)
File "build/bdist.linux-x86_64/egg/ds4drv/__main__.py", line 39, in fire_event
self.loop.fire_event(event, *args)
File "build/bdist.linux-x86_64/egg/ds4drv/eventloop.py", line 90, in fire_event
self.process_events()
File "build/bdist.linux-x86_64/egg/ds4drv/eventloop.py", line 96, in process_events
callback(*args)
File "build/bdist.linux-x86_64/egg/ds4drv/actions/input.py", line 75, in load_options
self.joystick.device.close()
File "/usr/lib/python2.7/dist-packages/evdev/uinput.py", line 115, in close
self.device.close()
AttributeError: 'NoneType' object has no attribute 'close'
的变量启动,则会一直崩溃:
@reboot /usr/local/bin/ds4drv > /home/hehxes/ds4drv/verbose.log
crontab:
cron
日志只显示以上输出。
我已经尝试指定@reboot /bin/bash; . /home/hehxes/.profile; /usr/bin/screen -dmS ds4drv-screen /usr/local/bin/ds4drv
的环境
angular.module('app', [])
.provider('resourceUrl', function($filterProvider) {
var base = '/';
this.setPrefix = function(prefix) {base = prefix};
$filterProvider.register('resourceUrl', resourceUrlFilter);
this.$get = ??
function resourceUrlFilter(url) { /* returns the new url */ }
})
但没有任何运气。
我做错了什么?
答案 0 :(得分:0)
调用bash后你有一个分号是不正确的。尝试使用以下内容创建脚本(假设 /home/hehxes/run_ds4drv.sh ):
#!/usr/bin/env bash
. /home/hehxes/.profile
/usr/local/bin/ds4drv
然后添加执行文件权限:
chmod a+x /home/hehxes/run_ds4drv.sh
并在cron中调用脚本:
@reboot /home/hehxes/run_ds4drv.sh > /home/hehxes/ds4drv/verbose.log