Notices


Reply
Thread Tools
Posts: 188 | Thanked: 234 times | Joined on May 2015 @ Italy
#1
Hi meamians,
I would like to start trying to create some scripts for Sailfish before a proper app (Btw, I downloaded the Sailfish SDK, but Windows 7 is not supported).

My idea is to create a simple script doing this:
1. Checks if there is an usb stick device conected to the phone (maybe just checking if the folders in the usbstick folder are not all empty)
2. Copies the content of the usb stick to a new folder on the phone memory (or compress it to a zip)

Could someone show me where can I find useful informations about the commands I need?
 

The Following 2 Users Say Thank You to claustn For This Useful Post:
coderus's Avatar
Posts: 6,044 | Thanked: 11,160 times | Joined on Nov 2011 @ Open Mobile Platform, Innopolis, Russia
#2
sound like usb data stealer to me
do you want to steal right answers from your teacher's usb stick or you want to steal government plans?
__________________
Twitter | Openrepos | GitHub | PayPal.Me
 

The Following 4 Users Say Thank You to coderus For This Useful Post:
Posts: 188 | Thanked: 234 times | Joined on May 2015 @ Italy
#3
Ahah, yes it sounds something like this! But no, I just want to have a useful tool to copy all the photos on memory cards in a fast way. It would be very nice to implement a sort of functions to do the inverse process, creating a quick backup of photos videos etc. on a usb stick.
 

The Following 2 Users Say Thank You to claustn For This Useful Post:
Posts: 992 | Thanked: 3,224 times | Joined on Oct 2014
#4
You would fill up Phone memory very fast by this.
__________________
You can still support my work by donation - click here

ETH: 0xf7544913017653719259c92d38d50d9d55f7c6cd
 

The Following User Says Thank You to nieldk For This Useful Post:
Posts: 188 | Thanked: 234 times | Joined on May 2015 @ Italy
#5
It is not intended to be used several times in a row, but just somethink tthat would be useful to have on the phone if needed.
Anyway, I'm going to try and report back here.
 

The Following User Says Thank You to claustn For This Useful Post:
Posts: 812 | Thanked: 1,123 times | Joined on Jul 2010 @ Brittany, France
#6
Well that would actually be very helpful to empty full SD card when out doing photography. I have no USB-OTG on my phone, but otherwise I would definitely use this on occasions.
 

The Following 3 Users Say Thank You to Kabouik For This Useful Post:
pichlo's Avatar
Community Council | Posts: 4,749 | Thanked: 14,049 times | Joined on Sep 2012 @ UK
#7
Empty a full SD? How many pictures do you take? I have a 4 GB memory stick in mine that takes me about 6 months to fill to more than 50%.
__________________
In particle accelerators atoms are indeed not only touching each others. But banging together in a massive explosive orgasm.
-- nieldk in a TMO post
 

The Following User Says Thank You to pichlo For This Useful Post:
Posts: 1,130 | Thanked: 1,782 times | Joined on Feb 2011 @ The Netherlands
#8
Originally Posted by pichlo View Post
Empty a full SD? How many pictures do you take? I have a 4 GB memory stick in mine that takes me about 6 months to fill to more than 50%.
He said: When doing photography. For me that means more than just snapping a picture with your phone.
If you shoot 18Mpix RAWs thats 25MB a photo.
4GB / 25MB = 160 photos
If you shoot a sunset where you bracket to do HDR, that means it fills even quicker.

In the three years I stepped up my photography game, I shot about 14000 photos. That's around 350GB.

I definitely could see the use of this. Maybe even as backup solution when travelling.
__________________
N900 loaded with:
CSSU-T (Thumb)
720p recording,
Pierogi, Lanterne, Cooktimer, Frogatto
N9 16GB loaded with:
Kernel-Plus
--
[TCPdump & libpcap | ngrep]
--
donate
 

The Following 3 Users Say Thank You to mr_pingu For This Useful Post:
Feathers McGraw's Avatar
Posts: 523 | Thanked: 1,667 times | Joined on Jul 2014 @ UK
#9
Originally Posted by claustn View Post
Could someone show me where can I find useful informations about the commands I need?
I would start by looking at udev - you can use the RUN part of a rule to run a script when a device is inserted (in this case, you would want to mount the device and then run a sync tool, possibly unmount it afterwards).

With udev rules you can match one specific drive (by manufacturer, model, size etc.), or write a loose rule that matches all usb sticks, for example.

This is a great guide for writing rules:

http://reactivated.net/writing_udev_rules.html

The major downside for you of this approach is that adding new udev rules is a system level change that requires root, so it's not ideal for use with an app. Maybe someone else has ideas about how you can get around this.

And just for fun, here is a rule I wrote to mount a known drive containing media files at a consistent mount point, so that it can be shared using NFS (on an ubuntu box running kodi):

Code:
SUBSYSTEM=="block",ATTR{partition}=="1",ATTR{size}=="1953521664",ATTRS{model}=="MQ01ABD100",ATTRS{vendor}=="TOSHIBA",SYMLINK+="SLICE",RUN+="/bin/mount -o defaults,user,noexec /dev/SLICE /srv/nfs/SLICE"
Good luck!
 

The Following 5 Users Say Thank You to Feathers McGraw For This Useful Post:
Posts: 75 | Thanked: 320 times | Joined on Dec 2014 @ Earth
#10
In SailfishOS' specific configuration, the mounting of sd cards is handled by the "sd-utils" RPM package.

- /lib/udev/rules.d/90-mount-sd.rules
is the udev rule file that reacts to new block devices.

- /lib/systemd/system/mount-sd@.service
is the systemd service template that is called (WANTed) for each new block device

- /usr/sbin/mount-sd.sh
is the script started by the service, that is in charge of detecting and auto-mounting partitions.
(That's the one I patched to get swapdevices).

---

I would propose :

- either go for a sysremd service, "Type= oneshot", using "WantedBy=" and "After=" parameters


- or as proposed above :
write you own udev rule, but pay attention to have it with a number higher than 90 (so its called after the mount).

Originally Posted by nieldk View Post
You would fill up Phone memory very fast by this.
Unless he has a 64GB or 128GB (or even 256GB*) microSD card in his phone.

---

*: If any one know a good brand of 256GB microSD cards that has static-wear-leveling, ECC, and can survive to swap ?
 

The Following 4 Users Say Thank You to DrYak For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 14:39.