How to make a tweak which respring the device? - theos

I try to make a tweak which respring the device with theos?
And not with "system("killall -9 SpringBoard");" command.

Related

wpa_supplicant keeping print message to screen

I am start learning Linux(CentOs 5.5 kernel 2.6.35.13).
When I try to install a usb wifi stick(TP-Link TL-WN823N,and "lsusb" will show ID 0bda:8178 Realtek Semiconductor Corp..)
It work fine in the window interface( ctrl+shift+F7).
But when I shift to the command window(ctrl+shift+F1),and try to start wifi connection by
wpa_supplicant -Bw -Dwext -iwlan0 -c/etc/wpa_supplicant.conf
I found it kept print logs to screen before I type the command above.
I use
ps axjf |grep wpa_supplicant
to list all related process and find
there is a process start by user "dbus" with the command
/usr/sbin/wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -u -f /var/log/wpa_supplicant.log
I dont know whether is this dbus' command that lead the problem.
Below is the screen shot.
kept logging msg:(
Partly fix the problem.
There are two things that make the wifi information keep on loging on the screen.
First, if you use NetworkManager, it will automate run the command under /etc/sysconfig/wpa_supplicant, where you can find the default command write there has no -B parameter which will keep the log in the background.So you can either add an -B to that command or stop NetworkManager and start wifi connection with your own command like in the question.
Second, when you install the driver, the default run status is power saving mode, so when you transfer data with wifi, you can see the screen keeping log infomation like "get into the pw_saving","get out pw_saving" etc.
To fix this, you can shut down the power saving mode like this:
create a file /etc/modprobe.d/8192cu.conf with the following contents:
options 8192cu rtw_power_mgnt=0 rtw_enusbss=0
Or you can rewrite driver code to stop print the info to screen, which I still don't know how to do.

How to end a process in another linux terminal

Background Info:
I'm trying to set up a remote display using a raspberry pi.
Currently I'm using fbi (frame buffer image viewer) to display the image.
The device is going to be controlled via ssh or web interface - not sure which, but definitely not from the actual device.
The Problem is I cant seem to find an easy way to "clean" quit the process remotely, clear the screen & generate no errors. The fbi program will exit if the q button is pressed but that seems to do no good over ssh. Ideally I'd prefer a less messy solution then having to look up the pid each time before killing it. I am open to the idea of using another program, however I can't run it in Xorg.
I've tried:
Grep-ing the pid and sending kill -sigterm but it either doesn't quit or doesnt clear the screen
echo "q" > /proc/[pid]/fd/0 - all the iterations i try I either get an access denied or nothing happens
Any Ideas?
How to kill a process without a message?
In one terminal, I started a process:
# sleep 100
Now to kill the process, without a message and without knowing the pid:
# kill -13 (pgrep sleep)
How to remotely clear the screen of a terminal?
First, get the tty # of the terminal you want to clear:
# tty
/dev/pts/1
Now from a different terminal:
# printf '\033c' > /dev/pts/1
Without seeing your code, a solution could be to use fbi to just display an image on fb0 from another terminal:
fbi -T 1 -noverbose -d /dev/fb0 image.png
Then just clear the entire framebuffer (fb0):
dd if=/dev/zero of=/dev/fb0
Or better yet, just write a "blank" image to fb0 to "clear" it.

Using gnu screen to access serial port

I am trying to access a device which is attached to a USB-serial port. The settings are 57600 baud, 8 bit, 1 stop bit, no parity. The device outputs a status line every second and accepts typed commands.
I would like to use GNU screen to initiate 2 way communications, so I am using this command:
screen /dev/ttyS2 57600,cs8
However I just get a blank screen, nothing received from the device.
The communication is fine using teraterm, and I can also do this
stty -F /dev/ttyS2 57600 cs8
cat /dev/ttyS2
to see the status output from the device.
I've tried various combinations of ixon, ixoff, crtscts, and clocal but nothing makes any difference.
How can I determine what the correct command should be?
I am using Cygwin on Windows 10.
I faced the same issue with gnu-screen, I started using plink.exe instead from the PuTTY suite. It's not optimal, but it does the job. In my case serial is just for recovery, not for everyday usage.
Start PuTTY, create a profile with your serial connection.
Name and save the connection.
From cygwin, run: '/cygdrive/c/Program\ Files\ (x86)/PuTTY/plink.exe -load SerialProfile'

Write a bash script that executes a command when a USB device is plugged in/removed [duplicate]

Is there a Bash script and/or daemon that I can write that will detect a specific USB drive and then sync that drive with a directory?
For future reference, here's how to run a bash script upon detection of a USB drive.
Connect your device and run lsusb to retrieve the device's info. You should see something similar to this:
$ lsusb
Bus 002 Device 039: ID 0bc2:2100 Seagate RSS LLC
In this case, the vendor ID of the device is 0bc2 and the product ID is 2100.
Now you can create your UDEV rule using a text editor of your choice.
$sudo vi /etc/udev/rules.d/85-my_usb_device_rule.rules
And add this:
ACTION=="add", SUBSYSTEM=="usb", SYSFS{idVendor}=="0bc2",
SYSFS{idProduct}=="2100", RUN+="/home/myhome/my_script"
/home/myhome/my_script is the path to your script which it would do whatever you want.
To make sure the detection script will execute right away, run this command to reload the UDEV rules:
$sudo udevadm control --reload-rules
This was tested on Fedora 14.
I didn't do it myself, but you can try udev rules like this:
# Hitachi SimpleDrive mini, model HTS545050B9A300 (500 GB USB HDD)
SUBSYSTEM=="block", ATTR{size}=="976768002", ATTRS{product}=="SimpleDrive mini", ATTRS{serial}=="2512009121920487", ACTION=="add", RUN+="/lib/udev/local.usb.hdd.sh add $devpath"
Place it in /etc/udev/rules.d/90-local.rules or similar place, certainly dependable on your OS.
Here is an example python deamon that you could use for the listening part, then copying the files to your directory shouldn't be a problem.
There are excellent answers here already but depending on your use case, it could be as simple as
[ -d /run/media/$USER/USB_STICK ] && do_stuff
USB_STICK here is the label of the usb stick.

How to insert my driver automatically on the insertion of USB mouse in Linux System?

I know that on the insertion of any usb device in the Linux system a specific device driver got loaded. Now I want to insert my driver on the insertion of USB mouse.
I know that I can do this task using two approaches: by using depmod or using udev concept. I have read a few things about it on the Internet but I don't get the exact answer. Can anyone suggest which approach is best to use and for that in the Linux kernel tree where I need to make changes?
Thanks all for your help.
I follow the udev approach to load module automatically on the USB insertion
Below is the procedure to load your Driver automatically on the Insertion of Hot plug-gable device (I experiment with the USB mouse and below procedure is working fine for it)
Run Following command
cmd > udevadm info -a -p $(udevadm info -q path -n /dev/input/mouse)
In place of ?? in the above command user need to add the device ID based on its entry in /dev (e.g.for USB flash drive: sdb1 or sda1 etc. based on the device identity)
Get the Value of the below parameters from the output of above command
KERNEL, ATTRS{idVendor}, ATTRS{idProduct}, ATTRS{serial}
Go to /etc/dev/rule.d directory and Add your rule
cmd > sudo vim 40-usbmouse.rules
ACTION=="add", SUBSYSTEM=="block", KERNEL=="sd?1", ATTRS{idVendor}=="058f", ATTRS{idProduct}=="6387", ATTRS{serial} =="4EPLXAXE", SYMLINK+="usbpd", RUN+="/usr/local/bin/InsertModule.sh"
Save this file.
Above rule is defined for the USB Mouse.
Parameter SYMLINK creates a link of your device in the /dev directory and In RUN+ you can give your script location which is going to execute on your device insertion.
For more info on How to write a rule refer below link
http://hackaday.com/2009/09/18/how-to-write-udev-rules/
Now after you define your rule user need to restart the udev to take your rule in notice by kernel.
cmd > sudo stop udev
cmd > sudo start udev
Insert your USB and validate that your script which you define in your rule shows its effact.
For Mouse user can use below command
cmd > udevadm info -a -p $(udevadm info -q path -n /dev/input/mouse)
P.S.: cmd stands for the command shell (Terminal).The above procedure is working with any USB device.
You may use MODULE_SOFTDEP macro defined in module.h in your driver where you can specify the name of the USB driver which gets loaded when the USB mouse is inserted. This will load your driver automatically. The depmod approach is the way to go.
Use MODULE_DEVICE_TABLE macro. That will export supported device table so that your hotplug tool (whether it udev or something else) can load your module. I've described the loading process in this answer.
To see example usage, refer to drivers/hid/usbhid/usbmouse.c. If this driver compiled as module, it is loaded every time any usb mouse is attached.

Resources