mirror of
https://github.com/anatolykopyl/stardew-sync.git
synced 2026-03-26 12:55:40 +00:00
Added a silent mode
This commit is contained in:
29
start.lua
29
start.lua
@@ -1,6 +1,5 @@
|
|||||||
#!/usr/local/bin/lua
|
#!/usr/local/bin/lua
|
||||||
|
|
||||||
fl = require('moonfltk')
|
|
||||||
lfs = require('lfs')
|
lfs = require('lfs')
|
||||||
require('lib/getOS')
|
require('lib/getOS')
|
||||||
require('settings')
|
require('settings')
|
||||||
@@ -10,8 +9,17 @@ print('Detected OS: ' .. OS)
|
|||||||
|
|
||||||
arg = {...}
|
arg = {...}
|
||||||
|
|
||||||
|
silent_mode = arg[1] == '-s'
|
||||||
|
if silent_mode then
|
||||||
|
print("silent_mode")
|
||||||
|
else
|
||||||
|
fl = require('moonfltk')
|
||||||
|
end
|
||||||
|
|
||||||
function to_pc(button)
|
function to_pc(button)
|
||||||
|
if button then
|
||||||
print(button:label())
|
print(button:label())
|
||||||
|
end
|
||||||
if selected_device ~= '' then
|
if selected_device ~= '' then
|
||||||
if OS ~= 'Windows' then
|
if OS ~= 'Windows' then
|
||||||
os.execute('cp -rv '..selected_path..'/. '..local_dir)
|
os.execute('cp -rv '..selected_path..'/. '..local_dir)
|
||||||
@@ -20,7 +28,10 @@ function to_pc(button)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function to_phone(button)
|
function to_phone(button)
|
||||||
|
if button then
|
||||||
print(button:label())
|
print(button:label())
|
||||||
|
end
|
||||||
|
|
||||||
if selected_device ~= '' then
|
if selected_device ~= '' then
|
||||||
if OS ~= 'Windows' then
|
if OS ~= 'Windows' then
|
||||||
os.execute('cp -rv '..local_dir..'/. '..selected_path)
|
os.execute('cp -rv '..local_dir..'/. '..selected_path)
|
||||||
@@ -47,7 +58,7 @@ function refresh_devices()
|
|||||||
phone_dir[#phone_dir + 1] = i
|
phone_dir[#phone_dir + 1] = i
|
||||||
end
|
end
|
||||||
|
|
||||||
if win then
|
if win then -- If fltk window created
|
||||||
if #phone_dir == 0 then
|
if #phone_dir == 0 then
|
||||||
device_choice:clear()
|
device_choice:clear()
|
||||||
device_choice:deactivate()
|
device_choice:deactivate()
|
||||||
@@ -72,6 +83,7 @@ if OS ~= 'Windows' then
|
|||||||
mount_point = '/run/user/1000/gvfs'
|
mount_point = '/run/user/1000/gvfs'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not silent_mode then
|
||||||
W, H = 320, 360
|
W, H = 320, 360
|
||||||
|
|
||||||
fl.visual('rgb')
|
fl.visual('rgb')
|
||||||
@@ -85,10 +97,6 @@ bg_img = fl.png_image(my_dir..'/img/bg.png')
|
|||||||
bg_box = fl.box(1, 1, W, H)
|
bg_box = fl.box(1, 1, W, H)
|
||||||
bg_box:image(bg_img)
|
bg_box:image(bg_img)
|
||||||
|
|
||||||
if OS ~= 'Windows' then
|
|
||||||
--fl.box(0, 20, W, 30, 'Точка монтирования:')
|
|
||||||
|
|
||||||
end
|
|
||||||
fl.box(0, 70, W, 30, 'Выберите устройство:')
|
fl.box(0, 70, W, 30, 'Выберите устройство:')
|
||||||
refresh_img = fl.png_image(my_dir..'/img/refresh.png')
|
refresh_img = fl.png_image(my_dir..'/img/refresh.png')
|
||||||
refresh_btn = fl.button(10, 100, 30, 30)
|
refresh_btn = fl.button(10, 100, 30, 30)
|
||||||
@@ -110,4 +118,13 @@ win:done()
|
|||||||
win:show(arg[0], arg)
|
win:show(arg[0], arg)
|
||||||
|
|
||||||
return fl.run()
|
return fl.run()
|
||||||
|
else
|
||||||
|
selected_path = mount_point..'/'..phone_dir[1]..'/Внутренняя\\ память/StardewValley'
|
||||||
|
|
||||||
|
if arg[2] == 'tophone' then
|
||||||
|
to_phone()
|
||||||
|
elseif arg[2] == 'topc' then
|
||||||
|
to_pc()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user