Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix xrandr - squash me to [rebrand] adjust xrandr to use dynamic applica... #22

Merged
merged 1 commit into from
Oct 19, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 13 additions & 22 deletions xbmc/windowing/X11/XRandR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ bool CXRandR::Query(bool force, bool ignoreoff)

m_bInit = true;

std::string envAppBinHome = (std::string)CCompileInfo::GetAppName() + "_BIN_HOME";
StringUtils::ToUpper(envAppBinHome);

if (getenv(envAppBinHome.c_str()) == NULL)
if (getenv("APP_BIN_HOME") == NULL)
return false;

m_outputs.clear();
Expand All @@ -78,11 +75,9 @@ bool CXRandR::Query(bool force, int screennum, bool ignoreoff)
std::string cmd;
std::string appname = CCompileInfo::GetAppName();
StringUtils::ToLower(appname);
std::string envAppBinHome = appname + "_BIN_HOME";
StringUtils::ToUpper(envAppBinHome);
if (getenv(envAppBinHome.c_str()))
if (getenv("APP_BIN_HOME"))
{
cmd = getenv(envAppBinHome.c_str());
cmd = getenv("APP_BIN_HOME");
cmd += "/" + appname + "-xrandr";
cmd = StringUtils::Format("%s -q --screen %d", cmd.c_str(), screennum);
}
Expand Down Expand Up @@ -167,11 +162,10 @@ bool CXRandR::TurnOffOutput(CStdString name)
std::string cmd;
std::string appname = CCompileInfo::GetAppName();
StringUtils::ToLower(appname);
std::string envAppBinHome = appname + "_BIN_HOME";
StringUtils::ToUpper(envAppBinHome);
if (getenv(envAppBinHome.c_str()))

if (getenv("APP_BIN_HOME"))
{
cmd = getenv(envAppBinHome.c_str());
cmd = getenv("APP_BIN_HOME");
cmd += "/" + appname + "-xrandr";
cmd = StringUtils::Format("%s --screen %d --output %s --off", cmd.c_str(), output->screen, name.c_str());
}
Expand Down Expand Up @@ -332,11 +326,10 @@ bool CXRandR::SetMode(XOutput output, XMode mode)
m_currentMode = modeFound.id;
std::string appname = CCompileInfo::GetAppName();
StringUtils::ToLower(appname);
std::string envAppBinHome = appname + "_BIN_HOME";
StringUtils::ToUpper(envAppBinHome);
char cmd[255];
if (getenv(envAppBinHome.c_str()))
snprintf(cmd, sizeof(cmd), "%s/%s-xrandr --screen %d --output %s --mode %s", getenv(envAppBinHome.c_str()),appname.c_str(), outputFound.screen, outputFound.name.c_str(), modeFound.id.c_str());

if (getenv("APP_BIN_HOME"))
snprintf(cmd, sizeof(cmd), "%s/%s-xrandr --screen %d --output %s --mode %s", getenv("APP_BIN_HOME"),appname.c_str(), outputFound.screen, outputFound.name.c_str(), modeFound.id.c_str());
else
return false;
CLog::Log(LOGINFO, "XRANDR: %s", cmd);
Expand Down Expand Up @@ -425,22 +418,20 @@ void CXRandR::LoadCustomModeLinesToAllOutputs(void)
StringUtils::Trim(strModeLine);
std::string appname = CCompileInfo::GetAppName();
StringUtils::ToLower(appname);
std::string envAppBinHome = appname + "_BIN_HOME";
StringUtils::ToUpper(envAppBinHome);

if (getenv(envAppBinHome.c_str()))
if (getenv("APP_BIN_HOME"))
{
snprintf(cmd, sizeof(cmd), "%s/%s-xrandr --newmode \"%s\" %s > /dev/null 2>&1", getenv(envAppBinHome.c_str()),
snprintf(cmd, sizeof(cmd), "%s/%s-xrandr --newmode \"%s\" %s > /dev/null 2>&1", getenv("APP_BIN_HOME"),
appname.c_str(), name.c_str(), strModeLine.c_str());
if (system(cmd) != 0)
CLog::Log(LOGERROR, "Unable to create modeline \"%s\"", name.c_str());
}

for (unsigned int i = 0; i < m_outputs.size(); i++)
{
if (getenv(envAppBinHome.c_str()))
if (getenv("APP_BIN_HOME"))
{
snprintf(cmd, sizeof(cmd), "%s/%s-xrandr --addmode %s \"%s\" > /dev/null 2>&1", getenv(envAppBinHome.c_str()),
snprintf(cmd, sizeof(cmd), "%s/%s-xrandr --addmode %s \"%s\" > /dev/null 2>&1", getenv("APP_BIN_HOME"),
appname.c_str(), m_outputs[i].name.c_str(), name.c_str());
if (system(cmd) != 0)
CLog::Log(LOGERROR, "Unable to add modeline \"%s\"", name.c_str());
Expand Down