Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- const Gio = imports.gi.Gio;
- const GLib = imports.gi.GLib;
- async function mount() {
- try {
- // This comes from a 'kdeconnect.sftp' packet
- let file = Gio.File.new_for_uri('sftp://192.168.1.68:1748//storage/emulated/0');
- let mount = new Gio.MountOperation({
- // This is always 'kdeconnect'
- username: 'kdeconnect',
- // This comes from a 'kdeconnect.sftp' packet
- password: '0DLBswxkjjY4bTxpNUvNXGB1X3c9',
- // Save password for session and accept new connections
- password_save: Gio.PasswordSave.FOR_SESSION,
- choice: 0
- });
- // We already know the host, so just accept
- mount.connect('ask-question', (op, message, choices) => {
- op.reply(Gio.MountOperationResult.HANDLED);
- });
- // We set the password, so just accept
- mount.connect('ask-password', (op, message, user, domain, flags) => {
- op.reply(Gio.MountOperationResult.HANDLED);
- });
- // This is the actual call to mount the device
- await new Promise((resolve, reject) => {
- file.mount_enclosing_volume(0, mount, null, (file, res) => {
- try {
- file.mount_enclosing_volume_finish(res);
- } catch (e) {
- logError(e);
- }
- });
- });
- } catch (e) {
- logError(e);
- }
- }
- mount();
- let loop = GLib.MainLoop.new(null, false);
- loop.run();
Add Comment
Please, Sign In to add comment