Code Sample |
#!/bin/lua -- Written by Jaap Broekhuizen aka Jaapz -- This script is released under the terms of the GPL2 License --iconthemeswitch.lua ---Switch to a different icon theme! --Variables home = os.getenv("HOME").."/" backup = 1 icondir = "/usr/share/dfm/icons/" --Main w = fltk:Fl_Window(250,125,"Icon Theme Switcher") w:callback( function(w) os.exit(0) end) text = fltk:Fl_Box(110,0,30,30,[[Click browse to select the tar.gz file where the icons are located.]]) text:labelfont(1) text:labelsize(11) output = fltk:Fl_Output(5,35,170,25) browseBtn = fltk:Fl_Button(180,35,65,25,"Browse") browseBtn:callback( function(browseBtn) icontarball = fltk.fl_file_chooser("Select tarball", "Types (*.tar.gz)",home) output:value(icontarball) end) deleteOrig = fltk:Fl_Round_Button(5,70,20,20,"Delete old icons") deleteOrig:type(fltk.FL_RADIO_BUTTON) deleteOrig:selection_color(fltk.FL_BLUE) deleteOrig:labelfont(1) deleteOrig:labelsize(13) deleteOrig:callback( function(deleteOrig) backup = 0 end) backupOrig = fltk:Fl_Round_Button(125,70,20,20,"Backup old icons") backupOrig:type(fltk.FL_RADIO_BUTTON) backupOrig:selection_color(fltk.FL_BLUE) backupOrig:labelfont(1) backupOrig:labelsize(13) backupOrig:callback( function(keepOrig) backup = 1 end) okBtn = fltk:Fl_Return_Button(5,95,50,25,"OK") okBtn:callback( function(okBtn) if icontarball == nil then fltk:fl_message("No filename is given, terminating!") os.exit(1) end if backup == 1 then os.execute("sudo tar -zcvf ~/iconbackup.tar.gz " ..icondir.. "*") end os.execute("sudo tar -zxvf " ..icontarball.. " -C " ..icondir) fltk:fl_message("All icons in " ..icontarball.. " are added/copied to " ..icondir.. "!") os.exit(0) end) cancelBtn = fltk:Fl_Button(60,95,60,25,"Cancel") cancelBtn:callback( function(cancelBtn) os.exit(0) end) helpBtn = fltk:Fl_Button(195,95,50,25,"Help") helpBtn:callback( function(helpBtn) fltk:fl_message([[You can change your icon theme by using this tool. Just select the tarball (.tar.gz) where you have your icons located, and click the ok-button. Then restart your window manager.]]) end) backupOrig:value(1) w:show() Fl:run() |
Code Sample |
... icondir = "/usr/share/dfm/icons/" .... backupOrig = fltk:Fl_Round_Button(125,70,20,20,"Backup old icons") backupOrig:type(fltk.FL_RADIO_BUTTON) backupOrig:selection_color(fltk.FL_BLUE) backupOrig:labelfont(1) backupOrig:labelsize(13) backupOrig:callback( function(keepOrig) backup = 1 end) okBtn = fltk:Fl_Return_Button(5,95,50,25,"OK") okBtn:callback( function(okBtn) if icontarball == nil then fltk:fl_message("No filename is given, terminating!") os.exit(1) end if backup == 1 then os.execute("sudo tar -zcvf ~/iconbackup.tar.gz " ..icondir.. "*") end os.execute("sudo tar -zxvf " ..icontarball.. " -C " ..icondir) fltk:fl_message("All icons in " ..icontarball.. " are added/copied to " ..icondir.. "!") os.exit(0) end) ... |