How to get the gnome icon name from a folder path in a Cinnamon applet - applet

I created a "Places" Cinnamon applet (a drop down list filled with folders).
And I would like to get the gnome icon name of a specific folder path. For instance, I would like to get the gnome icon name from the music folder "/home/USER/Music" which would be "folder-music".
I found something interesting in Gio :
const Gio = imports.gi.Gio;
var directory_file = Gio.file_new_for_path("/home/USER/Music");
var icon_names = directory_file.query_info('standard::symbolic-icon', 0, null).get_symbolic_icon().get_names();
But "get_symbolic_icon().get_names()" returns a String Array with more than 1 icon name.
For instance "/home/USER/Music" returns
folder-music-symbolic
folder-music
folder
As there is not really documentation, I would like to know if someone knows how to get the gnome icon name from a folder path ?

Related

How to get path for currently open tab file's root path

Tried to get project folder path in multi root workspace condition in visual studio code but facing very difficult to find the path.
Below script only will work single root workspace But How to change for multi root workspace.
var vscode = require("vscode");
var path = require("path");
exports.activate = context => {
const searchoption =
vscode.commands.registerCommand('extension.search', () => {
let folderPath = vscode.workspace.rootPath; // get the open file's project folder path
});
}
Instead of workspace.rootPath, use workspace.workspaceFolders to get all of the folders.
But the title of your question refers to the "currently open tab". That isn't a meaningful concept in the activate function, which only runs when the extension first initializes. You'll want to instead write, say, a command handler (see the extension tutorial), and within that handler, use window.activeTextEditor, and eventually call window.getWorkspaceFolder.

How to create a folder under "/sys/class/thermal/"

Is it possible to develop a Linux device driver which creates a folder under "/sys/class/thermal" without ACPI or Device Tree changes ?
I could create a folder under the "/sys/kernel" or "/sys/firmware" like this.
kobj_ref = kobject_create_and_add("my_device", kernel_kobj); // /sys/kernel
kobj_ref = kobject_create_and_add("my_device", firmware_kobj); // /sys/firmware
But I couldn't find an object, representing the "/sys/class/thermal", or an API to convert the file path to kobject.
Thank you

How can I create an array from files in a project group in Swift

If I have a group in a project called 'sounds', how can I create an array from files in that group? I think this is probably not quite the same as looking in a physical path on disk.
I tried the following:
var docsPath = NSBundle.mainBundle().resourcePath! + "/sounds";
let fileManager = NSFileManager.defaultManager()
var error: NSError?
var docsArray = fileManager.contentsOfDirectoryAtPath(docsPath, error:&error)
println(docsArray) // outputs nil
The sounds are not in a physical folder on disk but is there a method to address the group by name?
The group was created by right-clicking the project tree and selecting 'New Group'
In Xcode the yellow folders are virtual folders without an equivalent in the file system. To create a real (blue) folder drag a folder containing the sound files into the project tree and select "Create folder references" in the dialog window.
To append a path component to a path I'd recommend to use the designated method
let docsPath = NSBundle.mainBundle().resourcePath!.stringByAppendingPathComponent("sounds")

How does the ManifestEditor get the list of extensions of a plugin?

I am currently developing a plug-in that will get the list of every extensions of any given plug-in(s).
My problem is that these information are inside the plugin.xml and I have no clue on how to get them without parsing the file.
I've been looking at the Eclipse's Manifest Editor but I can not find how it gets the list of extensions.
To make it short, here is an example of the Manifest Editor with the extension tab selected:
And I'd like to get a List<String> that will hold the names of these extension points.
You can get the extensions used by a plugin from the extensions registry using something like:
IExtensionRegistry reg = Platform.getExtensionRegistry();
Bundle bundle = Platform.getBundle("plugin id");
String id = Long.toString(bundle.getBundleId());
String name = bundle.getSymbolicName();
IContributor contributor = new RegistryContributor(id, name, null, null);
IExtension [] extensions = reg.getExtensions(contributor);

How to include another assembly in a Windows Phone 8 XAP

I would like to include another assembly in my XAP for Windows Phone without referencing it directly (like a plugin system) so I can load it at runtime and activate types from it but I can't find any kind of reference on this.
I mostly found out questions regarding how to load it once included but how to (correctly) include it, no.
You can add a compiled assembly (.dll file) to your WP8 project and set the file Build Action to 'Content'. Then you can try to load it as so :
var folder = await StorageFolder.GetFolderFromPathAsync(Path.Combine(Windows.ApplicationModel.Package.Current.InstalledLocation.Path, "Plugins", "Services"));
var files = await folder.GetFilesAsync();
var firstFile = files.FirstOrDefault();
var assy = Assembly.LoadFrom(firstFile.Path);
But Assembly.LoadFrom will fail since it's unsupported. You can still use this to load other binary content but not code.
All you can do is reference all 'plugins' or whatever assemblies you might need and not directly reference any type from these assemblies. By 'reference the assemblies' I mean right click on references (in the WP8 project) and "Add reference...".
You can then do this :
var assy = Assembly.Load("MyCompany.MyProject.WhateverAssembly");
var tp = typeof(IService);
var x = ass.GetTypes().Where(t => t.IsClass && tp.IsAssignableFrom(t)).SingleOrDefault();
Activator.CreateInstance(x);
Not very elegant but I could call it a workaround.