Skip to content

Commit

Permalink
Fix permissions automatically #540
Browse files Browse the repository at this point in the history
  • Loading branch information
vdesabou committed Nov 10, 2021
1 parent 84f6d90 commit 604746c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 38 deletions.
39 changes: 2 additions & 37 deletions spotify-mini-player/src/action.php
Original file line number Diff line number Diff line change
Expand Up @@ -980,46 +980,11 @@ function main($query, $type, $add_to_option)

return;
} elseif ($other_action == 'fix_permissions') {
logMsg($w, "Info(fix_permissions) is called");
// check for quarantine and remove it if required
exec('/usr/bin/xattr ./fzf', $response);
foreach ($response as $line) {
if (strpos($line, 'com.apple.quarantine') !== false) {
logMsg($w, "Info(fix_permissions) for fzf");
exec('/usr/bin/xattr -d com.apple.quarantine ./fzf', $response);
break;
}
}

// check for quarantine and remove it if required
exec('/usr/bin/xattr ./terminal-notifier.app', $response);
foreach ($response as $line) {
if (strpos($line, 'com.apple.quarantine') !== false) {
logMsg($w, "Info(fix_permissions) for terminal-notifier");
exec('/usr/bin/xattr -d com.apple.quarantine ./terminal-notifier.app', $response);
break;
}
}

exec('/usr/bin/xattr "' . './App/' . $theme_color . '/Spotify Mini Player.app' . '"', $response);
foreach ($response as $line) {
if (strpos($line, 'com.apple.quarantine') !== false) {
logMsg($w, "Info(fix_permissions) for Spotify Mini Player");
exec('/usr/bin/xattr -d com.apple.quarantine "' . './App/' . $theme_color . '/Spotify Mini Player.app' . '"', $response);
break;
}
}
fixPermissions($w);
displayNotificationWithArtwork($w, 'Done', './images/debug.png', 'Fix permissions');
return;
} elseif ($other_action == 'enable_fuzzy_search') {
// check for quarantine and remove it if required
exec('/usr/bin/xattr ./fzf',$response);
foreach($response as $line) {
if (strpos($line, 'com.apple.quarantine') !== false) {
exec('/usr/bin/xattr -d com.apple.quarantine ./fzf',$response);
exit;
}
}
fixPermissions($w);
$ret = updateSetting($w, 'fuzzy_search', 1);
if ($ret == true) {
displayNotificationWithArtwork($w, 'Fuzzy search is now enabled', './images/search.png', 'Settings');
Expand Down
39 changes: 38 additions & 1 deletion spotify-mini-player/src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,43 @@
require_once './src/refreshLibrary.php';
require './vendor/autoload.php';

/**
* fixPermissions function.
*
*/
function fixPermissions($w)
{
$theme_color = getSetting($w, 'theme_color');

// check for quarantine and remove it if required
exec('/usr/bin/xattr ./fzf', $response);
foreach ($response as $line) {
if (strpos($line, 'com.apple.quarantine') !== false) {
logMsg($w, "Info(fix_permissions) for fzf");
exec('/usr/bin/xattr -d com.apple.quarantine ./fzf', $response);
break;
}
}

// check for quarantine and remove it if required
exec('/usr/bin/xattr ./terminal-notifier.app', $response);
foreach ($response as $line) {
if (strpos($line, 'com.apple.quarantine') !== false) {
logMsg($w, "Info(fix_permissions) for terminal-notifier");
exec('/usr/bin/xattr -d com.apple.quarantine ./terminal-notifier.app', $response);
break;
}
}

exec('/usr/bin/xattr "' . './App/' . $theme_color . '/Spotify Mini Player.app' . '"', $response);
foreach ($response as $line) {
if (strpos($line, 'com.apple.quarantine') !== false) {
logMsg($w, "Info(fix_permissions) for Spotify Mini Player");
exec('/usr/bin/xattr -d com.apple.quarantine "' . './App/' . $theme_color . '/Spotify Mini Player.app' . '"', $response);
break;
}
}
}

/**
* getExternalSettings function.
Expand Down Expand Up @@ -7878,7 +7915,7 @@ function checkForUpdate($w, $last_check_update_time, $download = false)
// update workflow_version
updateSetting($w, 'workflow_version', ''.$local_version);
stathat_ez_count('AlfredSpotifyMiniPlayer', 'workflow_installations', 1);

fixPermissions($w);
// open SpotifyMiniPlayer.app for notifications
exec('open "'.'./App/'.$theme_color.'/Spotify Mini Player.app'.'"',$response);
}
Expand Down
2 changes: 2 additions & 0 deletions spotify-mini-player/src/refreshLibrary.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ function refreshLibrary($w, $silent = false) {
return;
}

fixPermissions($w);

$update_type = 'Refresh Library';
if (file_exists($w->data() . '/create_library')) {
$update_type = 'Create Library';
Expand Down

0 comments on commit 604746c

Please sign in to comment.