I wrote this tiny script to swap out colors on the Numix theme for Ubuntu Gnome:
<?php
$oldColor = $argv[1];
$newColor = $argv[2];
// defaults
// $oldColor = 'd64937';
// $newColor = 'f66153';
$path = '/usr/share/themes/Numix/gtk-3.0/gtk-dark.css';
$fileRead = fopen($path, 'r');
$contents = fread($fileRead, filesize($path));
$newContents = str_replace($oldColor, $newColor, $contents);
$fileWrite = fopen($path, 'w');
fwrite($fileWrite, $newContents);
fclose($fileWrite);
?>
The script works as intended so long as I pass the two arguments.
- How do I set defaults for the arguments?
- Should I refactor maybe making use of file_put_contents()?