Welcome, Guest. Please login or register.

Author Topic: Themes  (Read 821 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline sim085Topic starter

  • Hero Member
  • *****
  • Join Date: Aug 2008
  • Posts: 958
Themes
« on: October 19, 2009, 08:27:25 PM »
Hi,

I have been writing the following scripts for the past few days and now they are (mostly) ready. Basically these scripts are nothing special - however they might help someone who (like me) would like an easy way to swap from one theme to another on his/her Workbench 3.1 or before. The scripts must all be put in the same directory (ex: RAM:) . When executing you have to pass parameters to all the scripts such as the Theme name and the Volume you want to backup.

Theme-Backup
example: execute Theme-Backup "Original" "System"

Code: [Select]
.key THEME/A,VOLUME/A
.bra {
.ket }

;check if workbench theme directory exists
IF NOT EXISTS System:Prefs/Themes

echo "Creating 'Themes' home directory inside Prefs directory"

;define the workbench theme directory
makedir System:Prefs/Themes
;copyicon -r Themes System:Prefs/Themes
   
EndIF

;create assignment for themes directory
assign Themes: System:Prefs/Themes

;copy all directories in themes directory to T: and delete them
IF NOT EXISTS T:Themes
makedir T:Themes
EndIF
copy Themes:#? T:Themes all clone QUIET
delete Themes:#? all force QUIET

;check if theme directory already exists
IF NOT EXISTS T:Themes/{THEME}

echo "Creating '{THEME}' directory in themes directory"

;define the theme directory
makedir T:Themes/{THEME}

EndIF

;create assignment for the theme directory
assign Theme{THEME}: T:Themes/{THEME}

;LOOP ALL VOLUMES

;Note - if loop is going to be implemented then do not allow VOLUME
;to be passed as a parameter to this script.

;execute script to backup volume
Execute Theme-BackupVolume {THEME} {VOLUME}

;EndLOOP

;clear assignment
assign Theme{THEME}:

;restore all themes back to theme directory
copy T:Themes/#? Themes: all clone QUIET
delete T:Themes all force QUIET
   
;clear assignment
assign Themes:

Theme-BackupVolume
Called from Theme-Backup

Code: [Select]
.key THEME/A,VOLUME/A
.bra {
.ket }

;check if theme directory already exists
IF EXISTS Theme{THEME}:

;check if volume directory already exists
IF EXISTS Theme{THEME}:{VOLUME}

;delete volume directory in theme directory
delete Theme{THEME}:{VOLUME} all force QUIET

EndIF

echo "Creating volume '{VOLUME}:' directory in theme directory"

;create volume directory in theme directory
makedir Theme{THEME}:{VOLUME}
assign Theme{THEME}{VOLUME}: Theme{THEME}:{VOLUME}

echo "Building volume {VOLUME}: directory structure"

;create script in T: to create directory structure in theme directory
list >T:Theme{THEME}{VOLUME}CreateDirs {VOLUME}: all dirs p=#? lformat="IF NOT EXISTS *"Theme{THEME}%p%m*"*n   makedir *"Theme{THEME}%p%m*"*nEndIF*n*n"
execute T:Theme{THEME}{VOLUME}CreateDirs
delete T:Theme{THEME}{VOLUME}CreateDirs QUIET

echo "Copying volume {VOLUME}: icons"

;create script in T: to move all current icons to the volume directory in theme directory
list >T:Theme{THEME}{VOLUME}CopyIcons {VOLUME}: all files p=#?.info lformat="copyicon -r -f -p *"%p%m*" *"Theme{THEME}%p%m*""
execute T:Theme{THEME}{VOLUME}CopyIcons  
delete T:Theme{THEME}{VOLUME}CopyIcons QUIET  

echo "Volume {VOLUME}: icons backup completed!"

;clear assignment
assign Theme{THEME}{VOLUME}:

ELSE

;inform user that theme directory does not exist
echo "Theme with name '{THEME}' does not exist!"

EndIF

Theme-Deploy
example: Execute Theme-Deploy "Original"

Code: [Select]
.key THEME/A
.bra {
.ket }

;check if wanted theme exists or not
IF EXISTS System:Prefs/Themes/{THEME}

;define the themes and theme directory
assign Themes: System:Prefs/Themes
assign Theme{THEME}: Themes:{THEME}

echo "Deploying theme with name '{THEME}'"

;execute script to deploy theme volume.
list >T:Theme{THEME}{VOLUME}Deploy Theme{THEME}: dirs p=#? lformat="execute Theme-DeployVolume {THEME} %m"
execute T:Theme{THEME}{VOLUME}Deploy
delete T:Theme{THEME}{VOLUME}Deploy QUITE  

;clear assignment(s)
assign Theme{THEME}{VOLUME}:
assign Themes:

ELSE

echo "Theme '{THEME}' is not installed"

EndIF

Theme-DeployVolume
Called from Theme-Deploy

Code: [Select]
.key THEME/A,VOLUME/A
.bra {
.ket }

;check if wanted theme exists or not
IF EXISTS System:Prefs/Themes/{THEME}/{VOLUME}

echo "Deploying volume {VOLUME}: icons"

;crate assignment for volume directory
assign Theme{THEME}{Volume}: Theme{THEME}:{VOLUME}

;create script in T: to move all current icons to the volume directory in theme directory
list >T:Theme{THEME}{VOLUME}DeployIcons {VOLUME}: all files p=#?.info lformat="IF EXISTS *"Theme{THEME}%p%n*"*n   copyicon -r -p -f *"Theme{THEME}%p%m*" *"%p%m*"*nELSE*n   echo *"Icon for %p%m not found*"*nEndIF"
execute T:Theme{THEME}{VOLUME}DeployIcons
delete T:Theme{THEME}{VOLUME}DeployIcons QUIET  

;Note: rather then use echo, in about list better append line to a log file.

;clear assignment
assign Theme{THEME}{Volume}:

echo "Ready"

ELSE

echo "Volume '{VOLUME}' is not part of theme '{THEME}'"

EndIF

As I said the scripts are nothing special - but seem to work on my Workbench 3.1 (altough some clutter is left in my RAM:) Anyone who would like to change/add anything is more then welcome :)

I must say it was nice to program something on the A500 - altough it is really to find coding resources for this machine - so in that sense I really wanted to thank all the people that helped me on these forums :)

Regards,
Sim085