-
Notifications
You must be signed in to change notification settings - Fork 0
/
icon_save.php
executable file
·46 lines (38 loc) · 1.27 KB
/
icon_save.php
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
40
41
42
43
44
45
46
#!/usr/bin/env php
<?php
/**
* icon_save
*
* Autogenerate bash script of desktop icon positions.
*
* @author Martin Latter
* @copyright Martin Latter 14/09/2019
* @version 0.01
* @license GNU GPL version 3.0 (GPL v3); http://www.gnu.org/licenses/gpl.html
* @link https://github.com/Tinram/Linux-Scripts.git
*/
exec('gvfs-info -a metadata::nemo-icon-position ~/Desktop/*', $sIconDetails);
$iIDlen = count($sIconDetails);
$sFilename = 'icon_restore';
$sGVFS = '';
for ($i = 0; $i < $iIDlen; $i += 3)
{
$iIndex = strpos($sIconDetails[$i], 'Desktop/');
$sIconName = substr($sIconDetails[$i], $iIndex + 8);
$sCoords = trim($sIconDetails[$i + 2]);
$sCoords = str_replace('nemo-icon-position:', 'nemo-icon-position', $sCoords);
$sGVFS .= 'gvfs-set-attribute -t string ~/Desktop/' . $sIconName . ' ' . $sCoords . PHP_EOL;
}
$sFileHeader = '#!/bin/bash
# autogenerated file from icon_save (' . date('Y-m-d H:i:s') . ')
# execute to revert desktop icon positions, then press F5' . PHP_EOL;
$iF = file_put_contents($sFilename, $sFileHeader . $sGVFS);
chmod($sFilename, 0700);
if ($iF)
{
echo $sFilename . ' successfully saved' . PHP_EOL;
}
else
{
echo 'ERROR: file could not be saved!' . PHP_EOL;
}