Mime types for custom file type - linux

I'm trying to register a custom file type as a mime-type in linux. My custom filetype, with a custom extension, is actually a zip archive containing various xml and other files.
The problem I'm having is that my operating system (kubuntu) won't recognize the file as my custom mime-type but insists on it being a zip file.
I'm not sure where I should start trying to fix my problem. I've used the following mime info file (tugraz-caleydo.sharedmimeinfo):
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="application/x-cal">
<comment>Caleydo Project</comment>
<glob pattern="*.cal"/>
</mime-type>
</mime-info>
My Desktop Entry (caleydo.desktop, correctly registered in /usr/share/applications):
[Desktop Entry]
Version=2.01
Encoding=UTF-8
Name=Caleydo
GenericName=Data Visualization
Comment=Visualization for Molecular Biology
Exec=/usr/bin/caleydo
Icon=/usr/share/pixmaps/caleydo_256.png
StartupNotify=true
Type=Application
Categories=Science;
MimeType=application/x-cal;
And these are the commands I'm trying to use:
sudo xdg-mime install --mode system tugraz-caleydo.sharedmimeinfo
sudo xdg-mime default caleydo.desktop application/x-cal
sudo update-mime-database /usr/share/mime
However, this still gives me:
$ xdg-mime query filetype export_2012.cal
application/zip

I finally found the issue:
the mime info file has to have exactly the name of the mime type. Renaming it to x-cal.xml did the trick.

Related

Xml script: How do we point our own working directory?

<?xml version="1.0" encoding="UTF-8"?>
<attributes>
<attribute name="priority" type="string"/>
<attribute name="hierarchy" type="script"path="$WORK_DIR/pvim2vmgr/python_script/hierarchy.py">
<scriptParam name="subject"/>
<scriptParam name="test_plan"/>
</attribute>
I'm expecting when I set environment cmd in xterm.
setenv WORK_DIR <my_path>
In xml script, it'll recognize my directory ($WORK_DIR).However, it doesn't, is there any cmd for me to implement it?
Purpose of using xml script
I'm using it to obtain information from certain website and generate a csv file. This xml script is running with command line argument.
Reason I want to replace Working directory
When I'm using other person working_dir to generate this xml script, it automatically replace the $WORK_DIR to other person instead of mine.

Trying to create a handler for .maff files in Linux

MAFF files are simply zip files. I'm trying to create a handler for .maff in linux so that when I click on them or type xdg-open x.maff it will call my handler instead of the default which is to open the directory in nautilus. I created an application-x-maff.xml file that contains:
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/x-maff">
<comment>maff type</comment>
<magic priority="100">
<match offset="0" type="string" value="PK\x03\x04" />
</magic>
<glob pattern="*.maff"/>
</mime-type>
</mime-info>
and saved in ~/.local/share/mime/packages. Created also a ~/.local/share/applications/maffapplication.desktop that contains
[Desktop Entry]
Type=Application
MimeType=application/x-maff
Name=Maff Handler
Exec=<my home path>/bin/linux/maffHandler
and executed
% update-mime-database ~/.local/share/mime/packages/
% update-desktop-database ~/.local/share/applications
If I do
% gio info x.maff (filtered)
standard::content-type: application/x-maff
standard::fast-content-type: application/x-maff
and if I do
% gio mime application/x-maff
Registered applications:
maffapplication.desktop
Recommended applications:
maffapplication.desktop
everything seems to be right ... but then xdg-open x.maff does not work, still calls nautilus ... worse yet, if I do
% xdg-mime query filetype x.maff
application/zip
I'm sure I'm missing something ... somehow I need to override this association between the .maff file that starts with the same magic as a zip file to no avail ... I tried all kinds of modifications on the xml file, with and without the magic, nothing works
By the way, if I do
% maffHandler x.maff
it works perfectly and opens the maff file in firefox, I'm willing to share the C++ code of that if anyone is interested
Seems that TDE (Trinity Desktop) does not properly set two important environment variables
setenv XDG_CURRENT_DESKTOP KDE
setenv KDE_SESSION_VERSION 5
Once they are set at .login (unfortunately had to log out and login again) xdg- scripts started working properly and recognizing the MIME types. The other problem is that TDE requires that you manually add the association on Control Center -> TDE Components -> File Associations.
After environment variables properly set for my environment and File Associations set, then it all works perfectly. Thanks

SVG not opening with inkscape command line but opens with gui

I am quite new to inkscape and I would like to process a batch of SVGs using the command line interface with the following command (in the same directory as the SVG):
$ inkscape -D -z NMY.svg
However, when I try to load an SVG with the CLI I get the following warning:
** (inkscape-bin:8875): WARNING **: Can't open file: NMY.svg (doesn't exist)
** (inkscape-bin:8875): WARNING **: Can't open file: NMY.svg (doesn't exist)
** (inkscape-bin:8875): WARNING **: Specified document NMY.svg cannot be opened (does not exist or not a valid SVG file)
However, opening the same SVG from the GUI properly displays the image.
Here is the header SVG in question in case there is something wrong with it:
<?xml version='1.0' encoding='iso-8859-1'?>
<svg version='1.1' baseProfile='full'
xmlns:svg='http://www.w3.org/2000/svg'
xmlns:rdkit='http://www.rdkit.org/xml'
xmlns:xlink='http://www.w3.org/1999/xlink'
xml:space='preserve'
width='250px' height='150px' >
I am using inkscape Inkscape 0.92.2 5c3e80d, 2017-08-06 on MacOS 10.14.
Thanks!
Found the problem, I had to specify the absolute path to the file.

Remote creation of Custom actions in Thunar

I'm using Thunar as file browser for a linux network composed of 100 CentOS 7.2 machines. We are managing the installation of those workstations with a PXE server and SaltStack installation.
I need to create those custom actions during the installation.
Currently, Thunar is installed on every workstations, the script is available on a share but I need to create the custom action on each machine. Open Thunar, Edit > Create custom actions and it launches my script in xterm for the selected folder:
xterm -e "/path/to/my/script.sh %f"
Is there a way to create Thunar's custom actions from command lines or by editing a file so that I will be able to launch them through Salt cmd.run?
Thanks for your help.
I've found out that those Custom actions are store in this file:
cat ~/.config/Thunar/uca.xml
Here is an example of the syntaxe:
<?xml encoding="UTF-8" version="1.0"?>
<actions>
<action>
<icon>script.png</icon>
<name>My custom action</name>
<unique-id>1479309009025049-2</unique-id>
<command>xterm -e "/path/to/my/script.sh %f"</command>
<patterns>*</patterns>
<startup-notify/>
<directories/>
<audio-files/>
<image-files/>
<other-files/>
<text-files/>
<video-files/>
</action>
</actions>
That way, I can create this template file and copy it in the user folder.

How to configure log4j and Selenium Grid?

When I launch a Grid hub using Ant, the logging is all by default on the console. I would like to know if there is a way wherein I can alter the build.xml file of Selenium Grid and include a log4j logger into it. I understand that I can specify a log file to Ant itself using the -logfile option. But this would cause the log file to be overwritten everytime the grid is launched. I want to ensure that the log files are automatically renamed after a threshold is reached for better maintenance. Any help and if possible some examples on how to do it would be greatly appreciated (I am new to using log4j which is why I am asking for some sample for this specific need).
You need to specify the location of the Log4j archive as well as its configuration file when starting up Selenium. In the following example, I've updated the classpath to load the log4j.hub.properties configuration file located in the /etc/selenium directory and the log4j.jar located in the /usr/lib/selenium directory. I've also setup some additional log files:
java -classpath /etc/selenium:/usr/lib/selenium/log4j.jar:/usr/lib/selenium/selenium-server-standalone.jar -Dlog4j.configuration=log4j.hub.properties org.openqa.grid.selenium.GridLauncher -role hub -log /var/log/selenium/hub.debug.log > /var/log/selenium/hub.output.log 2> /var/log/selenium/hub.error.log &
Then you can have something like the following to achieve what you are looking for:
log4j.rootLogger=ALL, file
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=/var/log/selenium/hub.log
log4j.appender.file.Append=true
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} <%p> <%t> %m%n
You might want to look at this page for more information about how Selenium logging is working.

Resources