class qdii::firefox {
    if ($qdii::at_work) {
        $pkgname = 'firefox-esr'
        } else {
            $pkgname = 'firefox'
        }
    if ($qdii::is_desktop) {
        File {
            ensure => file,
            owner  => 'qdii',
            mode   => '0600',
        }
        package { 'firefox':
            ensure => 'latest',
            name => $pkgname,
        }
        file { 'mozilla-directory':
            ensure => 'directory',
            path   => "$qdii::homedir/.mozilla",
            owner  => 'qdii',
        }
        -> file { 'firefox-directory':
            ensure => 'directory',
            path   => "$qdii::homedir/.mozilla/firefox",
            owner  => 'qdii',
        }
        -> file { 'chrome-directory':
            ensure => 'directory',
            path   => "$qdii::homedir/.mozilla/firefox/chrome",
            owner  => 'qdii',
        }
        -> file { 'userChrome':
            ensure => file,
            path   => "$qdii::homedir/.mozilla/firefox/chrome/userChrome.css",
            source => 'puppet:///modules/qdii/dotfiles/userChrome.css',
            owner  => 'qdii',
        }
        -> exec { 'make_userchrome_directory':
            cwd     => "$qdii::homedir/.mozilla/firefox",
            command => "/bin/bash -c 'find . -type d -regex .*default$ -exec mkdir {}/chrome \\;'",
            user    => 'qdii',
        }
        -> exec { 'make_userchrome_directory_esr':
            cwd     => "$qdii::homedir/.mozilla/firefox",
            command => "/bin/bash -c 'find . -type d -regex .*default-esr$ -exec mkdir {}/chrome \\;'",
            user    => 'qdii',
        }
        -> exec { 'copy_userchrome_into_default_profile':
            cwd     => "$qdii::homedir/.mozilla/firefox",
            command => "/bin/bash -c 'find . -type d -regex .*default.*/chrome$ -exec cp chrome/userChrome.css {} \\;'",
            user    => 'qdii',
        }
    }
}
