-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathlibsecretHelper.js
More file actions
39 lines (32 loc) · 1.08 KB
/
libsecretHelper.js
File metadata and controls
39 lines (32 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/gjs
import GLib from 'gi://GLib'
import Secret from 'gi://Secret'
/* This schema is usually defined once globally */
const EXAMPLE_SCHEMA = new Secret.Schema("org.example.Password",
Secret.SchemaFlags.NONE,
{
"number": Secret.SchemaAttributeType.INTEGER,
"string": Secret.SchemaAttributeType.STRING,
"even": Secret.SchemaAttributeType.BOOLEAN,
}
);
/*
* The attributes used to later lookup the password. These
* attributes should conform to the schema.
*/
const attributes = {
"number": "9",
"string": "nine",
"even": "false"
};
function store_password(name, pass) {
Secret.password_store_sync(EXAMPLE_SCHEMA, attributes, Secret.COLLECTION_DEFAULT, name, pass, null);
}
function retrieve_password(name) {
return Secret.password_lookup_sync(EXAMPLE_SCHEMA, attributes, null);
}
// Get the password
let password = "secret" //GLib.spawn_command_line_sync("zenity --password --title='Password' --text='Enter the password to store:'")[1].toString().trim();
store_password("rclone",password);
// Retrieve the password
retrieve_password("Example password");