GNOME Shell Extension Install possible without Restart? - gnome-shell

I have written a small GNOME Shell extension, that I want to distribute to some collegues.
For this I created a RPM. After the installation a restart of GNOME-Shell is needed to make the extension visible, so it can be enabled. Either by using <ALT-F2> followed by r when using X11 or log out and in when using Wayland.
Only after this restart the extension is visible in GNOME-Tweaks or can be activated using gnome-extensions enable ....
I was told that there might be a way to make the extension known to GNOME-Shell without restart. I searched around, but didn't find anything.
So: Can a GNOME-Shell extension be installed in a way that no restart is needed before it can be activated?
Environment is GNOME-Shell 3.34 & 3.36 on Fedora 31 & 32.

This will enable the extension as if it was coming from ego. Replace global.userdatadir with global.datadir and PER_USER with SYSTEM if the extension is in /usr/share/gnome-shell/extensions/.
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const ExtensionUtils = imports.misc.extensionUtils;
const Main = imports.ui.main;
// Here, the directory must be in ~/.local/share/gnome-shell/extensions.
function installFromLocal(uuid) {
let dir = Gio.File.new_for_path(GLib.build_filenamev([global.userdatadir, 'extensions', uuid]));
let manager = Main.extensionManager;
try {
let extension = manager.createExtensionObject(uuid, dir, ExtensionUtils.ExtensionType.PER_USER);
manager.loadExtension(extension);
if (!manager.enableExtension(uuid))
throw new Error('Cannot add %s to enabled extensions gsettings key'.format(uuid));
} catch (e) {
let extension = Main.extensionManager.lookup(uuid);
if (extension)
Main.extensionManager.unloadExtension(extension);
throw new Error('Error while installing %s: %s (%s)'.format(uuid, 'LoadExtensionError', e));
}
}

Related

Cannot Create New Directory in MacOS app

I am working on a mac app. I have been struggling to create a directory in "Desktop" on Mac OS. I am working on High Sierra. It was working fine, but suddenly the app is unable to create a directory in Desktop. I get the following permission error. I am using Xcode 9.3 and swift 4.1.
Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “TestDir” in the folder “Desktop”." UserInfo={NSFilePath=/Users/sj/Library/Containers/com.user.TestSync/Data/Desktop/TestDir, NSUnderlyingError=0x60400044cc60 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"
Here is my code:
class DBManager: NSObject {
static func getDirectoryPath() -> URL {
let homeDirectory = URL(fileURLWithPath: NSHomeDirectory())
let desktopPath = homeDirectory.appendingPathComponent("Desktop")
let databaseFolder = desktopPath.appendingPathComponent("TestDir")
return databaseFolder
}
static func createFolderIfNotExist() {
let databaseFolder = DBManager.getDirectoryPath()
if !FileManager().fileExists(atPath: databaseFolder.path) {
do {
try FileManager.default.createDirectory(atPath: databaseFolder.path, withIntermediateDirectories: true, attributes: nil)
} catch {
print(error)
}
}
}
}
The code works fine if I am to create a directory inside "Documents". But for some reason, I am not able to create inside Desktop even if I have provided read/write access for Desktop to everyone. I have also included the screenshot of the directory where I have to create one.
I tried to create a directory inside "Downloads" but ended with same permission issue. But, again I was successful to create directory inside "Library". So, it seems that the OS is not giving permission to create inside alias directory since both Desktop and Downloads are alias.
Any help is highly appreciated.
That is because your macOS Application is running in the "App Sandbox", check your "Capabilities" tab in the target settings.
~/Library/Containers/%BundleID%/Data/Desktop is a soft link to the user's desktop, and you have no write permissions (depending on your entitlements file not even read permissions).
Depending on your use case you can
disable the sandbox mode
let the user pick a folder by opening an "Open" dialog (then you can write to this)
enable read/write in some other protected user folder (like Downloads, etc.) or
create the TestDir directly in your home directory without using any soft linked folder
Besides what mentioned by #ChaosCoder, we also need set NSOpenPanel.canCreateDirectories to true:
panel.canCreateDirectories = true
Delete the App Sandbox data from your Capabilities.
Click on your project in your file navigator, then your project in the TARGETS tab, then make sure "Signing & Capabilities" is selected, then "ALL" then double click the "x" next to "App Sandbox".

Meteor and graphicsMagic on Windows

I'm trying to run meteor app developed under MacOS on Windows.
Have this problem:
WARNING: cfs:graphicsmagick could not find "graphicsMagic" or
"imageMagic" on the system.
I just checked PATH to see if I could find the GraphicsMagick or
ImageMagic unix/mac os/windows binaries on your system, I failed.
Why:
1. I may be blind or naive, help making me smarter
2. You havent added the path to the binaries
3. You havent actually installed GraphicsMagick or ImageMagick
* Make sure "$PATH" environment is configured "PATH:/path/to/binaries" *
Installation hints:
* Mac OS X "brew install graphicsmagick" or "brew install imagemagick"
* Linux download rpm or use packagemanager
* Centos "yum install GraphicsMagick"* Windows download the installer and run
I've installed GraphicsMagick and ImageMagic, checked PATH.
In cmd gm command runs GraphicsMagick, but still this problem remain in meteor.
The cfs:graphicsmagick module is designed to work on windows. This is the script that looks for graphicsmagick. I've modified it to work with node and increased the verbosity to help you debug the issue:
var graphicsmagick = false;
var imagemagick = false;
var fs = require("fs"); //or Npm.require("fs") if you're running this script with meteor
// Split the path by : for linux
// Split the path by ; for windows
var sep = /^win/.test(process.platform) ? ';' : ':';
var binaryPaths = process.env['PATH'].split(sep);
// XXX: we should properly check if we can access the os temp folder - since
// gm binaries are using this and therefore may fail?
// XXX: we could push extra paths if the `gm` library check stuff like:
// $MAGIC_HOME The current version does not check there
// $MAGICK_HOME (GraphicsMagick docs)
// We check to see if we can find binaries
for (var i = 0; i < binaryPaths.length; i++) {
var binPath = binaryPaths[i];
console.log("Looking in", binPath)
// If we have not found GraphicsMagic
if (!graphicsmagick) {
// Init
var gmPath = path.join(binPath, 'gm');
var gmExePath = path.join(binPath, 'gm.exe');
// Check to see if binary found
graphicsmagick = fs.existsSync(gmPath) || fs.existsSync(gmExePath);
// If GraphicsMagic we dont have to check for ImageMagic
// Since we prefer GrapicsMagic when selecting api
if (!graphicsmagick && !imagemagick) {
// Init paths to check
var imPath = path.join(binPath, 'convert');
var imExePath = path.join(binPath, 'convert.exe');
// Check to see if binary found
imagemagick = fs.existsSync(imPath) || fs.existsSync(imExePath);
}
}
}
console.log("Found GraphicsMagick", graphicsmagick)
console.log("Found ImageMagick", imagemagick)
When you run it it will give you a path that it is looking in, in the through all PATH variables from the environment variable.
Look for the imagemagick installation you have and check that it matches up. If you run the script with Meteor make sure to change Npm.require("fs") from require('fs').
The check is very thorough looking for the gm.exe or convert.exe, if you have it installed you will have to find out why it is not being detected.

How do we manually fix "ResourceRules.plist: cannot read resources" error after xcode 6.1 upgrade?

We are having the same issue found here, here, here and here
Basically we upgraded to xcode 6.1 and our build are getting the "ResourceRules.plist: cannot read resources" error.
We have a Jenkins server that does our ios builds for us. We are using the Xcode plugin on Jenkins to do the actual build and signing. Any thoughts on how we can make this change without manually opening xcode and doing this solution found on the other answers:
Click on your project > Targets > Select your target > Build Settings >
Code Signing Resource Rules Path
and add :
$(SDKROOT)/ResourceRules.plist
I'm very new to Xcode and iOS build in general. I have found the project.pbxproj file inside the Unity-iPhone.xcodeproj file. It looks like this contains the build settings under the /* Begin XCBuildConfiguration section */ section it lists what looks like similar build properties foundin Xcode, however I do not see anything like "Code Signing Resource Rules Path".
Does anyone have experience manually editing this file? Is that a bad idea in general?
Thanks
If you're using Jenkins with the XCode plugin, you can modify the 'Code Signing Resource Rules Path' variable by adding:
"CODE_SIGN_RESOURCE_RULES_PATH=$(SDKROOT)/ResourceRules.plist"
to the
'Custom xcodebuild arguments' setting for the XCode plugin.
This fix does not require the XCode GUI.
I encountered the same problem. Nicks solution does work, but is requiring additional dependencies. You don't need the heavy-handed npm xcode module for this. Just add a line to this file:
$PROJECT_ROOT/platforms/ios/cordova/build.xcconfig
CODE_SIGN_RESOURCE_RULES_PATH=$(SDKROOT)/ResourceRules.plist
Note that before XCode 6.1.1, this needed to be specified as "$(SDKROOT)/ResourceRules.plist" (notice the quotes).
If you are running this inside automated build systems such as Jenkins and wont't/can't use any XCode GUI, just create a small Cordova hook, leveraging npm's fs.appendFile, at this location:
$PROJECT_ROOT/hooks/before_build/ios_resourcerules.js (make sure it has chmod +x)
#! /usr/local/bin/node
var fs = require("fs");
fs.appendFileSync('build.xcconfig', '\nCODE_SIGN_RESOURCE_RULES_PATH = $(SDKROOT)/ResourceRules.plist', function (err) {
if (err) throw err;
console.log('CODE_SIGN_RESOURCE_RULES_PATH added to Cordova iOS build configuration.');
});
This will might be merged in an upcoming Cordova release, so the hook will become unnecessary (i'm creating a see this PR for Cordova-iOS).
In case the above JavaScript snippet fails to execute due to a "wrong argument" failure, replace the file's content as follows:
#!/bin/bash
if [ ! -f ./build.xcconfig ]; then
echo "[ERROR] hook befor_build/ios_resourcerules.sh cannot execute, ./build/xcconfig not found in $PWD"
exit 1
fi
echo '// (CB-7872) Solution for XCode 6.1 signing errors related to resource envelope format deprecation' >> ./build.xcconfig
echo 'CODE_SIGN_RESOURCE_RULES_PATH=$(SDKROOT)/ResourceRules.plist' >> ./build.xcconfig
echo 'CODE_SIGN_RESOURCE_RULES_PATH added to Cordova iOS build configuration.'
If you want to get really crazy, you can directly update PackageApplication.
# In /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/PackageApplication
my #codesign_args = ("/usr/bin/codesign", "--force", "--preserve-metadata=identifier,entitlements,resource-rules",
"--sign", $opt{sign},
"--resource-rules=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/ResourceRules.plist");
# OLD: "--resource-rules=$destApp/ResourceRules.plist");
I was already hacking this script to accept a keychain arg, so it made sense for me. Note I'm not using the Xcode Jenkins plugin -- I'm using Jenkins but running all the build commands from a script.
After the new release of XCode 7 on 23rd Sept 2015, Apple started rejecting any application that is using CODE_SIGN_RESOURCE_RULES_PATH, making the Jenkins build automatically rejected. However, setting CODE_SIGN_RESOURCE_RULES_PATH=$(SDKROOT)/ResourceRules.plist into the Custom xcodebuild arguments causes a build failure.
This answer resolved the issue: https://stackoverflow.com/a/32762413/5373468
This is clearly a bug that Apple forgot to fix a while ago, as this article is also highlighting: http://cutting.io/posts/packaging-ios-apps-from-the-command-line/
I had EXACTLY the same problem, as you have. We are building our iOS app on Jenkins, so we couldn't manually set "Code Signing Resource Rules Path".
I have wrote a small NodeJS file which does the job for me (see the code below).
The script use a nice NodeJS package called xcode which helps me with the parsing of the xcode.xcodeproj file.
I don't know if you are using Cordova/Phonegap or what you are using, but if you are can just copy the code and make a Cordova hook. If not I'm sure you can execute the file from Jenkins, with some small changes.
Anyways, I hope this script will help you:
#!/usr/bin/env node
var CODE_SIGN_RESOURCE_RULES_PATH = '"$(SDKROOT)/ResourceRules.plist"';
var fs = require("fs");
var path = require("path");
var xcode = require('xcode');
var projectRoot = process.argv[2];
function getProjectName(protoPath) {
var cordovaConfigPath = path.join(protoPath, 'www', 'config.xml');
var content = fs.readFileSync(cordovaConfigPath, 'utf-8');
return /<name>([\s\S]*)<\/name>/mi.exec(content)[1].trim();
}
function run(projectRoot) {
var projectName = getProjectName(projectRoot);
var xcodeProjectName = projectName + '.xcodeproj';
var xcodeProjectPath = path.join(projectRoot, 'platforms', 'ios', xcodeProjectName, 'project.pbxproj');
var xcodeProject;
if (!fs.existsSync(xcodeProjectPath)) {
return;
}
xcodeProject = xcode.project(xcodeProjectPath);
console.log('Setting Code Sign Resource Rules Path for ' + projectName + ' to: [' + CODE_SIGN_RESOURCE_RULES_PATH + '] ...');
xcodeProject.parse(function(error){
if(error){
console.log('An error occured during parsing of [' + xcodeProjectPath + ']: ' + JSON.stringify(error));
}else{
var configurations = nonComments(xcodeProject.pbxXCBuildConfigurationSection());
for (config in configurations) {
var buildSettings = configurations[config].buildSettings;
buildSettings['CODE_SIGN_RESOURCE_RULES_PATH'] = CODE_SIGN_RESOURCE_RULES_PATH;
}
fs.writeFileSync(xcodeProjectPath, xcodeProject.writeSync(), 'utf-8');
console.log('[' + xcodeProjectPath + '] now has Code Signing Resource Rules Path set to:[' + CODE_SIGN_RESOURCE_RULES_PATH + '] ...');
}
});
}
var COMMENT_KEY = /_comment$/;
function nonComments(obj) {
var keys = Object.keys(obj),
newObj = {}, i = 0;
for (i; i < keys.length; i++) {
if (!COMMENT_KEY.test(keys[i])) {
newObj[keys[i]] = obj[keys[i]];
}
}
return newObj;
}
run(projectRoot);
We are using Unity + Jenkins for auto builds.
You can achieve with post process cs scripts; however; for quick (and dirty fix) you can apply following bash command after Unity but before xcode:
sed -i '' 's/CONFIGURATION_BUILD_DIR/CODE_SIGN_RESOURCE_RULES_PATH = "\$(SDKROOT)\/ResourceRules\.plist";\'$'\n CONFIGURATION_BUILD_DIR/g' /Users/admin/Jenkins/workspace/PROJECTNAME/Build/PROJECTNAME/Unity-iPhone.xcodeproj/project.pbxproj

JavaFX. How to run processing from terminal OSX

EDITED:----
I need to batch process a number of processing sketch files from my JavaFX application. The following code, below, works on Windows. I would like to get it running on a Mac, but not sure how.
My workflow is as follows:
//as the user for the processing-java.exe file
processingJavaProrgramFile = fileChooser.showOpenDialog(stage);
if (processingJavaProrgramFile != null) {
processingJavaProrgramPath = processingJavaProrgramFile.getPath();
}
//ask the user for the processing sketch folder
processingSketchDir = directoryChooser.showDialog(stage);
if (processingSketchDir != null) {
sketchPath = processingSketchDir.getPath();
}
//java run time exec method to compile sketch in user folder using through processing-java.exe
Runtime.getRuntime().exec(
processingJavaProrgramPath +
" --force --run --sketch=" +
sketchPath + " --output=" +
sketchPath+File.separator +
"temp"
);
How do I get it to run on Mac? For one, the Mac version does not have a processing-java.exe. Should it be a different workflow? If so, how do I let the application know whether it is running on a Windows or a Mac OS so that it runs the appropriate method?
Ok found the solution to both my questions.
To get the OS type, I used method here
To run processing with same code on the mac, I need to:
from processing, go to tools menu and install "processing-java". This install it into the system somehow. So in the Mac case, users do not need to select the path where processing-java is like in Windows (select the processing-java.exe). On the mac, users would only need to select the output folder.

Cloud9 tries to recreate .settings file

I've installed Cloud9 IDE on my linux machine in order to play around with it a bit (I had to use nodejs 0.8 because cloud9 uses a package that depends on node-waf, which is no longer supported by higher versions of nodejs).
I can start it up without problems, however when I try to access Cloud9 via browser, it constantly gives me the error message: File already exists.. Here's a trace from the log:
Error: File already exists.
at module.exports.from (/home/xyz/repos/cloud9/node_modules/vfs-local/localfs.js:678:35)
at Object.fs.exists [as oncomplete] (fs.js:91:19)
Relevant code section:
exists(topath, function(exists){
if (options.overwrite || !exists) {
// Rename the file
fs.rename(frompath, topath, function (err) {
if (err) return callback(err);
// Rename metadata
if (options.metadata !== false) {
rename(WSMETAPATH + from, {
to: WSMETAPATH + to,
metadata: false
}, function(err){
callback(null, meta);
});
}
});
}
else {
var err = new Error("File already exists.");
err.code = "EEXIST";
callback(err);
}
When the error occurs, the topath variable is set to the workspace settings file (/home/xyz/repos/cloud9/workspace/.settings)
Has anyone else had an error like this? How can I resolve it?
thx in advance
Reinstalling cloud9
First option, maybe you could try using this workaround installation procedure:
https://github.com/ajaxorg/cloud9/issues/2904#issuecomment-22518669
Second option, if you are willing to always use an older node-version for running cloud9 as you indicated, I used the following installation procedure and it worked (assuming you already installed nvm). Then you can still use the cloud9.sh-file for starting:
git clone git://github.com/ajaxorg/cloud9.git
cd cloud9
nvm install 0.8.8
sed -i -e 's/~//g' package.json
npm config set ca=""
npm install
sed -i s/connect.session.file/connect.session.memory/ configs/default.js
Not sure if 0.8.8 is the best node-version for cloud9 but it works for me :)
Last step seems necessary because of https://github.com/ajaxorg/cloud9/issues/2005#issuecomment-11372587 :)
Then before starting cloud9 you always have to enter:
nvm use 0.8.8
Or you set 0.8.8 as the default node version if you don't use node much otherwise:
nvm alias default 0.8.8
Fix problem without reinstalling
Third option, if you don't want to repeat the installation procedure you could try just reinstalling the vfs-local-module in the cloud9 directory:
npm install vfs-local#0.3.4
Haven't tested this though :)

Resources